Bug#1100413: dpkg-source: Imprecise check for 3.0 (git) submodule existence

Guillem Jover <[email protected]>
Newsgroups gmane.linux.debian.devel.dpkg.bugs
Message-ID <aJwp-HXqZBMDKa_T__8907.67386169813$1755065007$gmane$org@thunder.hadrons.org>
Hi!

On Thu, 2025-03-13 at 16:25:16 +0100, Daniel Gröber wrote:
> Package: dpkg-dev
> Version: 1.21.22
> Severity: normal
> X-Debbugs-Cc: [email protected]

> I'm trying to use source/format 3.0 (git) to share a git-bundle of some WIP
> packaging changes with another DD.
> 
> The package in question rubs dpkg-source the wrong way:
> 
>      dpkg-source: error: git repository yosys uses submodules; this is not yet supported
> 
> However the packaging repo itself doesn't have submodules initialized so I
> don't think there is any real problem.
> 
> Looking at Dpkg/Source/Package/V3/Git.pm the check is simply based on the
> presence of the .gitmodules config file.
> 
> I believe the correct logic to check if submodules are actually in-use in
> the current repo would be to check if `git submodule status` returns
> non-empty output.
> 
> What do you think?

Yes, this makes sense, thanks! Would the attached patch work for you?

Thanks,
Guillem
0001-Dpkg-Source-Package-V3-Git-Use-git-submodule-for-its.patch (text/x-diff, 1.8 KB)
From f02e7b35f2669f8db251b269a5fb180fb99096e0 Mon Sep 17 00:00:00 2001
From: Guillem Jover <[email protected]>
Date: Wed, 13 Aug 2025 07:47:07 +0200
Subject: [PATCH] =?UTF-8?q?Dpkg::Source::Package::V3::Git:=20Use=20=C2=ABg?=
 =?UTF-8?q?it=20submodule=C2=BB=20for=20its=20status?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Instead of only relying on the .gitmodules being non-empty, call
«git submodule status --recursive» to check whethere there is any
submodule in use.

Suggested-by: Daniel Gröber <[email protected]>
Closes: #1100413
---
 scripts/Dpkg/Source/Package/V3/Git.pm | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/scripts/Dpkg/Source/Package/V3/Git.pm b/scripts/Dpkg/Source/Package/V3/Git.pm
index 3d4d8b3da..723424c8d 100644
--- a/scripts/Dpkg/Source/Package/V3/Git.pm
+++ b/scripts/Dpkg/Source/Package/V3/Git.pm
@@ -41,6 +41,7 @@ use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::Exit qw(push_exit_handler pop_exit_handler);
 use Dpkg::Path qw(find_command);
+use Dpkg::IPC;
 use Dpkg::Source::Functions qw(erasedir);
 
 use parent qw(Dpkg::Source::Package);
@@ -70,8 +71,19 @@ sub _check_workdir {
                  'specified'), $srcdir);
     }
     if (-s "$srcdir/.gitmodules") {
-        error(g_('git repository %s uses submodules; this is not yet supported'),
-              $srcdir);
+        my $stdout;
+
+        spawn(
+            exec => [ qw(git submodule status --recursive) ],
+            chdir => $srcdir,
+            wait_child => 1,
+            to_string => \$stdout,
+        );
+        if (length $stdout) {
+            error(g_('git repository %s uses submodules; ' .
+                     'this is not yet supported'),
+                  $srcdir);
+        }
     }
 
     return 1;
-- 
2.50.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.