[debhelper-devel] [debhelper] 03/07: dh_strip: Refactor build-id recording

Niels Thykier nthykier at moszumanska.debian.org
Sat Aug 22 17:35:36 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 7e65a95bb2dddcbf8a0d446d85cdd8010ede668e
Author: Niels Thykier <niels at thykier.net>
Date:   Sat Aug 22 19:31:18 2015 +0200

    dh_strip: Refactor build-id recording
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 dh_strip | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/dh_strip b/dh_strip
index 2d34572..30eb570 100755
--- a/dh_strip
+++ b/dh_strip
@@ -9,7 +9,6 @@ dh_strip - strip executables, shared libraries, and some static libraries
 use strict;
 use warnings;
 use File::Find;
-use File::Path 'make_path';
 use Debian::Debhelper::Dh_Lib;
 
 =head1 SYNOPSIS
@@ -169,9 +168,9 @@ sub get_file_type {
 }
 
 # Check if a file is an elf binary, shared library, or static library,
-# for use by File::Find. It'll fill the following 3 arrays with anything
-# it finds:
-my (@shared_libs, @executables, @static_libs);
+# for use by File::Find. It'll fill the 3 first arrays with anything
+# it finds.  The @build_ids will be the collected build-ids (if any)
+my (@shared_libs, @executables, @static_libs, @build_ids);
 sub testfile {
 	return if -l $_ or -d $_; # Skip directories and symlinks always.
 	
@@ -228,8 +227,7 @@ sub make_debug {
 	return unless get_file_type($file) =~ /not stripped/;
 
 	my ($base_file)=$file=~/^\Q$tmp\E(.*)/;
-	my $debug_path;
-	my $debug_build_id;
+	my ($debug_path, $debug_build_id);
 
 	if ($use_build_id &&
 	    `LC_ALL=C readelf -n $file`=~ /^\s+Build ID: ([0-9a-f]{2})([0-9a-f]+)$/m) {
@@ -256,17 +254,7 @@ sub make_debug {
 	}
 
 	if ($use_build_id) {
-		my $debugpackagename=$package;
-		if (ref $dh{DEBUGPACKAGES}) {
-			$debugpackagename=@{$dh{DEBUGPACKAGES}}[0];
-		}
-
-		my $internal_path = "debian/.debhelper/${debugpackagename}";
-		make_path($internal_path) if ! -d $internal_path;
-		my $path = "${internal_path}/ddeb-build-ids";
-		open(my $fd, '>>', $path) or error("open $path failed: $!");
-		print {$fd} "$debug_build_id ";
-		close($fd) or error("close $path failed: $!");
+		push(@build_ids, $debug_build_id);
 	}
 
 	# No reason for this to be executable.
@@ -316,7 +304,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			$use_build_id = 2;
 		}
 	}
-	@shared_libs=@executables=@static_libs=();
+	@shared_libs=@executables=@static_libs=@build_ids=();
 	find(\&testfile,$tmp);
 
 	foreach (@shared_libs) {
@@ -362,6 +350,20 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			close($fd) or error("close $path failed: $!");
 		}
 	}
+	if (@build_ids && ($use_build_id > 1 || ref($dh{DEBUGPACKAGES}))) {
+		my ($dir, $path);
+		if ($use_build_id > 1) {
+			$dir = "debian/.debhelper/${package}";
+		} else {
+			my $dbg_pkg = @{$dh{DEBUGPACKAGES}}[0];
+			$dir = "debian/.debhelper/${dbg_pkg}";
+		}
+		$path = "${dir}/ddeb-build-ids";
+		install_dir($dir) if ! -d $dir;
+		open(my $fd, '>>', $path) or error("open $path failed: $!");
+		print {$fd} join(q{ }, @build_ids) . "\n";
+		close($fd) or error("close $path failed: $!");
+	}
 }
 
 =head1 SEE ALSO

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