[debhelper-devel] [debhelper] 01/01: dh_builddeb: Generate the correct filename for udebs

Niels Thykier nthykier at moszumanska.debian.org
Sun Aug 30 15:00:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit 1f93dad8a0e54733b3abd747b1d4735c40426a79
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Aug 30 16:59:21 2015 +0200

    dh_builddeb: Generate the correct filename for udebs
    
    dpkg-gencontrol does not include "Package-Type" in the control file
    (see #575059, #452273) for political reasons.
    
    dh_builddeb used to guess the "correct" filename, but it fell short
    when dpkg-gencontrol -V was used.  The best solution so far: Let
    dpkg-deb build the deb and have dh_builddeb fix the extension.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog |  5 +++++
 dh_builddeb      | 45 ++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 557e8e6..a718d82 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,11 @@ debhelper (9.20150811+unreleased) UNRELEASED; urgency=medium
   * dh_gencontrol/dh_builddeb: Temporarily stop building ddebs
     for udebs as dpkg-gencontrol and dpkg-deb does not agree
     the default file extension for these.
+  * dh_builddeb: Generate udebs with the correct filename even
+    when "-V" is passed to dpkg-gencontrol.  This relies on
+    dpkg-deb getting everything but the extension correct
+    (see #575059, #452273 for why it does not produce the
+     correct extesion).  (Closes: #516721, #677353)
 
   [ Paul Tagliamonte ]
   * dh_gencontrol: Put debug debs back in the "debug" section.
diff --git a/dh_builddeb b/dh_builddeb
index 939ea24..f314e5a 100755
--- a/dh_builddeb
+++ b/dh_builddeb
@@ -93,6 +93,33 @@ sub default_compressor_args {
 	return (@{$default_comp}, @args);
 }
 
+sub build_and_rename_deb {
+	my ($package, $destdir, $cmd, $rename_sub) = @_;
+	my $build_dir = "debian/.debhelper/scratch-space/build-${package}";
+	my ($dpkg_filename, $desired_filename);
+	if ( ! -d $build_dir) {
+		install_dir($build_dir);
+	}
+	doit(@${cmd}, $build_dir);
+	opendir(my $fd, $build_dir);
+	for my $name (readdir($fd)) {
+		next if $name eq '.' or $name eq '..';
+		if ($dpkg_filename) {
+			error("\"@{$cmd}\" produced two debs: $dpkg_filename and $name");
+		}
+		$dpkg_filename = $name;
+	}
+	closedir($fd);
+	local $_ = $dpkg_filename;
+	$rename_sub->();
+	$desired_filename = $_;
+	if ($desired_filename ne $dpkg_filename) {
+		print "\tRenaming $dpkg_filename to $desired_filename\n";
+	}
+	doit('mv', '-f', "${build_dir}/${dpkg_filename}",
+		 "${destdir}/${desired_filename}");
+}
+
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $pid=fork();
 	if (! defined $pid) {
@@ -140,11 +167,23 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 	else {
 		my $filename=$dh{FILENAME};
+		my @cmd = qw(dpkg-deb -z1 -Zxz -Sextreme);
+		push(@cmd, @{$dh{U_PARAMS}}) if $dh{U_PARAMS};
+		push(@cmd, '--build', $tmp);
 		if (! $filename) {
-			$filename="/".udeb_filename($package);
+			# dpkg-gencontrol does not include "Package-Type" in the
+			# control file (see #575059, #452273) for political
+			# reasons.
+			#
+			# dh_builddeb used to guess the "correct" filename, but it
+			# fell short when dpkg-gencontrol -V was used.  The best
+			# solution so far: Let dpkg-deb build the deb and
+			# have dh_builddeb fix the extension.
+			build_and_rename_deb($package, $dh{DESTDIR}, \@cmd,
+								 sub { s/\.deb$/\.udeb/g });
+		} else {
+			doit(@cmd, $dh{DESTDIR}.$filename);
 		}
-		doit("dpkg-deb", "-z1", "-Zxz", "-Sextreme",
-			@{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$filename);
 	}
 	exit 0;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list