[debhelper-devel] [debhelper] 05/05: dh_strip: Fix bug generating Build-Id field with --dbg-package

Niels Thykier nthykier at moszumanska.debian.org
Sat Dec 16 13:34:17 UTC 2017


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

nthykier pushed a commit to branch master
in repository debhelper.

commit 6dfb3f5321d9ca32e1e1ce6bb8f2af6ed69560f0
Author: Niels Thykier <niels at thykier.net>
Date:   Sat Dec 16 13:25:36 2017 +0000

    dh_strip: Fix bug generating Build-Id field with --dbg-package
    
    The problem occurred because we overrode the list of recorded
    build-ids after each package.  This works perfectly fine for dbgsym
    packages as they always have a 1:1 with the original package.
    However, a manual --dbg-package can host debug symbols for multiple
    binary packages.
    
    There are two paths to triggering this issue:
    
      dh_strip -p pkg1 -p pkg2 --dbg-package=foo-dbg
    
    and:
    
      dh_strip -p pkg1 --dbg-package=foo-dbg
      dh_strip -p pkg2 --dbg-package=foo-dbg
    
      (This case was observed in krb5/1.15.2-2 where it loops over most of
      the packages and calls dh_strip on each of them with the same
      --dbg-package parameter.)
    
    They fundamentally have the same issue and fix but the second case is
    slightly more involved (as we have to merge with the previous run).
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog |  3 +++
 dh_gencontrol    |  1 +
 dh_strip         | 30 +++++++++++++++++-------------
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 17ebdc5..6538b81 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ debhelper (10.10.10) UNRELEASED; urgency=medium
     parameters in "maintscript" parameters in compat 10 and newer.
     In compat 12, this is an error.  Thanks to Andreas Beckmann for
     the suggestions.  (Closes: #882626)
+  * dh_strip: Fix bug where the Build-Id field would not be properly
+    filled when using --dbg-package.  Thanks to Paul Wise for finding
+    and reporting the bug.  (Closes: #884152)
 
   [ Translations ]
   * Update Portuguese translation (Américo Monteiro)
diff --git a/dh_gencontrol b/dh_gencontrol
index 8552dc3..524b581 100755
--- a/dh_gencontrol
+++ b/dh_gencontrol
@@ -183,6 +183,7 @@ sub read_dbgsym_file {
 		open(my $fd, '<', $dbgsym_path)
 			or error("open $dbgsym_path failed: $!");
 		chomp($result = <$fd>);
+		$result =~ s/\s++$//;
 		close($fd);
 	}
 	return $result;
diff --git a/dh_strip b/dh_strip
index 6261c83..420031b 100755
--- a/dh_strip
+++ b/dh_strip
@@ -245,6 +245,16 @@ sub testfile {
 	}
 }
 
+sub write_buildid_file {
+	my ($package, $build_ids) = @_;
+	my $dir = "debian/.debhelper/${package}";
+	my $path = "${dir}/dbgsym-build-ids";
+	install_dir($dir);
+	open(my $fd, '>>', $path) or error("open $path failed: $!");
+	print {$fd} join(q{ }, sort(@{$build_ids})) . ' ';
+	close($fd) or error("close $path failed: $!");
+}
+
 # I could just use `file $_[0]`, but this is safer
 sub get_file_type {
 	my ($file, $cache_ok) = @_;
@@ -337,7 +347,7 @@ sub process_packages {
 				$use_build_id = 2;
 			}
 		}
-		%file_output=@shared_libs=@executables=@static_libs=@build_ids=();
+		%file_output=@shared_libs=@executables=@static_libs=();
 		find({
 			wanted => \&testfile,
 			no_chdir => 1,
@@ -387,20 +397,14 @@ sub process_packages {
 				close($fd) or error("close $path failed: $!");
 			}
 		}
-		if (@build_ids && ($use_build_id > 1 || $dh{DEBUGPACKAGE})) {
-			my ($dir, $path);
-			if ($use_build_id > 1) {
-				$dir = "debian/.debhelper/${package}";
-			} else {
-				$dir = "debian/.debhelper/$dh{DEBUGPACKAGE}";
-			}
-			$path = "${dir}/dbgsym-build-ids";
-			install_dir($dir);
-			open(my $fd, '>>', $path) or error("open $path failed: $!");
-			print {$fd} join(q{ }, sort(@build_ids)) . "\n";
-			close($fd) or error("close $path failed: $!");
+		if ($use_build_id > 1 and @build_ids) {
+			write_buildid_file($package, \@build_ids);
+			@build_ids = ();
 		}
 	}
+	if (@build_ids and $dh{DEBUGPACKAGE}) {
+		write_buildid_file($dh{DEBUGPACKAGE}, \@build_ids);
+	}
 }
 
 if ($dh{DEBUGPACKAGE}) {

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