[debhelper-devel] [debhelper] 01/07: Add experimental .ddeb support

Niels Thykier nthykier at moszumanska.debian.org
Sat May 2 09:51:10 UTC 2015


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

nthykier pushed a commit to annotated tag 9.20150501+ddebs
in repository debhelper.

commit 74f267a3ca6e2cf635fc45eecc94c31ad65080e8
Author: Niels Thykier <niels at thykier.net>
Date:   Fri Apr 3 23:16:26 2015 +0200

    Add experimental .ddeb support
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm | 26 ++++++++++++++++++++------
 dh_builddeb                |  7 +++++++
 dh_clean                   |  3 +++
 dh_gencontrol              | 33 ++++++++++++++++++++++++++++++++-
 dh_md5sums                 | 17 +++++++++++++++--
 dh_strip                   | 27 ++++++++++++++++++---------
 6 files changed, 95 insertions(+), 18 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 4740f0e..c0da230 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -21,7 +21,7 @@ use vars qw(@ISA @EXPORT %dh);
 	    &dpkg_architecture_value &sourcepackage &make_symlink
 	    &is_make_jobserver_unavailable &clean_jobserver_makeflags
 	    &cross_command &set_buildflags &get_buildoption
-	    &install_dh_config_file
+	    &install_dh_config_file &ddeb_filename
 	    &install_file &install_prog &install_lib &install_dir
 );
 
@@ -944,15 +944,29 @@ sub is_udeb {
 	return $package_types{$package} eq 'udeb';
 }
 
-# Generates the filename that is used for a udeb package.
-sub udeb_filename {
-	my $package=shift;
-	
+sub _xdeb_filename {
+	my ($package, $ext, $actual_name) = @_;
+
 	my $filearch=package_arch($package);
 	isnative($package); # side effect
 	my $version=$dh{VERSION};
 	$version=~s/^[0-9]+://; # strip any epoch
-	return "${package}_${version}_$filearch.udeb";
+	$actual_name = $package if not defined($actual_name);
+	return "${actual_name}_${version}_${filearch}.${ext}";
+}
+
+# Generates the filename that is used for a udeb package.
+sub udeb_filename {
+	my ($package) = @_;
+
+	return _xdeb_filename($package, 'udeb');
+}
+
+# Generates the filename that is used for a ddeb package.
+sub ddeb_filename {
+	my ($package) = @_;
+
+	return _xdeb_filename($package, 'ddeb', "${package}-dbgsym");
 }
 
 # Handles #DEBHELPER# substitution in a script; also can generate a new
diff --git a/dh_builddeb b/dh_builddeb
index 42e8a98..7129627 100755
--- a/dh_builddeb
+++ b/dh_builddeb
@@ -105,6 +105,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		}
 	}
 	if (! is_udeb($package)) {
+		my $ddeb_tmpdir = "debian/.debhelper/${package}/ddeb-root";
+		if ( -d $ddeb_tmpdir) {
+			my $ddeb_filename = '/' . ddeb_filename($package);
+			doit("dpkg-deb", "-z1", "-Zxz", "-Sextreme",
+				@{$dh{U_PARAMS}}, "--build", $ddeb_tmpdir, $dh{DESTDIR}.$ddeb_filename);
+		}
+
 		doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$dh{FILENAME});
 	}
 	else {
diff --git a/dh_clean b/dh_clean
index e1bee78..0158e6e 100755
--- a/dh_clean
+++ b/dh_clean
@@ -92,6 +92,9 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		unless excludefile($tmp);
 }
 
+# Remove internal state data
+doit('rm', '-rf', 'debian/.debhelper/');
+
 # Remove all debhelper logs.
 if (! $dh{D_FLAG} && ! $dh{K_FLAG}) {
 	complex_doit("rm","-f","debian/*.debhelper.log");
diff --git a/dh_gencontrol b/dh_gencontrol
index 77a73b5..725d3c7 100755
--- a/dh_gencontrol
+++ b/dh_gencontrol
@@ -44,9 +44,13 @@ init(options => {
 	"dpkg-gencontrol-params=s", => \$dh{U_PARAMS},
 });
 
+
+my $src_pkg;
+
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $tmp=tmpdir($package);
 	my $ext=pkgext($package);
+	my $ddeb_tmp = "debian/.debhelper/${package}/ddeb-root";
 
 	my $substvars="debian/${ext}substvars";
 	
@@ -68,8 +72,35 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		complex_doit("echo misc:Pre-Depends= >> $substvars");
 	}
 	
+
+	if ( -d $ddeb_tmp) {
+		my $arch = package_arch($package);
+		my $ddeb_filename = ddeb_filename($package);
+		$src_pkg = sourcepackage() if not defined($src_pkg);
+		# Remove and override more or less every standard field.
+		my @ddeb_options = (qw(
+			-UPre-Depends -URecommends -USuggests -UEnhances -UProvides -UEssential
+			-UReplaces -UBreaks -UConflicts
+			-DPriority=extra
+			),
+			 "-DPackage=${package}-dbgsym",
+			 "-DDepends=${package}:${arch} (= \${binary:Version})",
+			 "-DDescription=Debug symbols for ${package}",
+			 "-DSource=${src_pkg}",
+			 "-n${ddeb_filename}",
+		);
+		if ( ! -d "${ddeb_tmp}/DEBIAN" ) {
+			install_dir("${ddeb_tmp}/DEBIAN");
+                }
+		doit("dpkg-gencontrol", "-p${package}", "-l$changelog", "-T$substvars",
+			"-P${ddeb_tmp}",@{$dh{U_PARAMS}}, @ddeb_options);
+
+		doit("chmod","0644","${ddeb_tmp}/DEBIAN/control");
+		doit("chown","0:0","${ddeb_tmp}/DEBIAN/control");
+	}
+
 	# Generate and install control file.
-	doit("dpkg-gencontrol", "-p$package", "-l$changelog", "-T$substvars", 
+	doit("dpkg-gencontrol", "-p$package", "-l$changelog", "-T$substvars",
 		"-P$tmp",@{$dh{U_PARAMS}});
 
 	# This chmod is only necessary if the user sets the umask to
diff --git a/dh_md5sums b/dh_md5sums
index a212004..521fa66 100755
--- a/dh_md5sums
+++ b/dh_md5sums
@@ -50,7 +50,8 @@ init(options => {
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	next if is_udeb($package);
-	
+
+	my $ddeb_tmp = "debian/.debhelper/${package}/ddeb-root";
 	my $tmp=tmpdir($package);
 
 	if (! -d "$tmp/DEBIAN") {
@@ -83,7 +84,19 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 	else {
 		doit("chmod", "0644", "$tmp/DEBIAN/md5sums");
-		doit("chown","0:0","$tmp/DEBIAN/md5sums");
+		doit("chown", "0:0", "$tmp/DEBIAN/md5sums");
+	}
+	if ( -d $ddeb_tmp) {
+		$find = "find . -type f ! -regex './DEBIAN/.*' -printf '%P\\0'";
+		complex_doit("(cd $ddeb_tmp >/dev/null ; $find | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums) >/dev/null");
+		# If the file's empty, no reason to waste inodes on it.
+		if (-z "${ddeb_tmp}/DEBIAN/md5sums") {
+			doit('rm', '-f', "${ddeb_tmp}/DEBIAN/md5sums");
+		}
+		else {
+			doit('chmod', '0644', "${ddeb_tmp}/DEBIAN/md5sums");
+			doit('chown', '0:0', "${ddeb_tmp}/DEBIAN/md5sums");
+		}
 	}
 }
 
diff --git a/dh_strip b/dh_strip
index 1ffaaf7..a23b614 100755
--- a/dh_strip
+++ b/dh_strip
@@ -153,20 +153,22 @@ sub testfile {
 }
 
 sub make_debug {
-	my $file=shift;
-	my $tmp=shift;
-	my $desttmp=shift;
-	
+	my ($file, $tmp, $desttmp, $use_build_id) = @_;
+
 	# Don't try to copy debug symbols out if the file is already
 	# stripped.
 	return unless get_file_type($file) =~ /not stripped/;
 
 	my ($base_file)=$file=~/^\Q$tmp\E(.*)/;
 	my $debug_path;
-	if (! compat(8) && 
+	if ($use_build_id &&
 	    `LC_ALL=C readelf -n $file`=~ /^\s+Build ID: ([0-9a-f]{2})([0-9a-f]+)$/m) {
 		$debug_path=$desttmp."/usr/lib/debug/.build-id/$1/$2.debug"
 	}
+	elsif ($use_build_id > 1) {
+		# For ddebs, we need build-id (else it will not be co-installable).
+		return;
+	}
 	else {
 		$debug_path=$desttmp."/usr/lib/debug/".$base_file;
 	}
@@ -196,7 +198,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 
 	# Support for keeping the debugging symbols in a detached file.
 	my $keep_debug=$dh{K_FLAG};
-	my $debugtmp=$tmp;
+	my $debugtmp;
+	my $use_build_id = compat(8) ? 0 : 1;
 	if (! compat(4)) {
 		if (ref $dh{DEBUGPACKAGES}) {
 			$keep_debug=1;
@@ -215,12 +218,18 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			$debugtmp=tmpdir($package."-dbg");
 		}
 	}
-	
+	if ($ENV{'DH_BUILD_DDEBS'} and package_arch($package) ne 'all') {
+		$debugtmp = "debian/.debhelper/${package}/ddeb-root";
+		$keep_debug = 1;
+		$use_build_id = 2;
+	} else {
+		$debugtmp = $tmp;
+	}
 	@shared_libs=@executables=@static_libs=();
 	find(\&testfile,$tmp);
 
 	foreach (@shared_libs) {
-		my $debug_path = make_debug($_, $tmp, $debugtmp) if $keep_debug;
+		my $debug_path = make_debug($_, $tmp, $debugtmp, $use_build_id) if $keep_debug;
 		# Note that all calls to strip on shared libs
 		# *must* include the --strip-unneeded.
 		doit($strip,"--remove-section=.comment",
@@ -229,7 +238,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 	
 	foreach (@executables) {
-		my $debug_path = make_debug($_, $tmp, $debugtmp) if $keep_debug;
+		my $debug_path = make_debug($_, $tmp, $debugtmp, $use_build_id) if $keep_debug;
 		doit($strip,"--remove-section=.comment",
 			"--remove-section=.note",$_);
  		attach_debug($_, $debug_path) if defined $debug_path;

-- 
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