[debhelper-devel] [debhelper] 07/09: dh_strip: Re-use file(1) output to determine build-id

Niels Thykier nthykier at moszumanska.debian.org
Wed Jun 15 20:29:17 UTC 2016


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

nthykier pushed a commit to branch master
in repository debhelper.

commit 6942cb4f951cb69b46dd741c715de724eea5943a
Author: Niels Thykier <niels at thykier.net>
Date:   Wed Jun 15 17:58:30 2016 +0000

    dh_strip: Re-use file(1) output to determine build-id
    
    Might as well, since it can save a fork+exec for readelf.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog |  3 +++
 dh_strip         | 32 +++++++++++++++++---------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index ba895dc..950f0b3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -41,6 +41,9 @@ debhelper (9.20160403+unreleased) UNRELEASED; urgency=medium
   * dh_strip: Unconditionally pass --enable-deterministic-archives
     to strip for static libs as the stable version of binutils
     supports it.
+  * dh_strip: Use file(1) to determine the build-id when
+    available.  This saves an readelf call for every binary in
+    the package.
 
  -- Niels Thykier <niels at thykier.net>  Sat, 09 Apr 2016 09:20:32 +0000
 
diff --git a/dh_strip b/dh_strip
index 72f340a..4f561ff 100755
--- a/dh_strip
+++ b/dh_strip
@@ -241,25 +241,27 @@ sub testfile {
 
 sub make_debug {
 	my ($file, $tmp, $desttmp, $use_build_id) = @_;
+	my ($debug_path, $debug_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 ($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) {
-		$debug_path=$desttmp."/usr/lib/debug/.build-id/$1/$2.debug";
-		$debug_build_id="${1}${2}";
-		push(@build_ids, $debug_build_id);
-	}
-	elsif ($use_build_id > 1) {
-		# For dbgsyms, we need build-id (else it will not be
-		# co-installable).
-		return;
+	my $file_info = get_file_type($file);
+	return unless $file_info =~ /not stripped/;
+
+	if ($use_build_id) {
+		if ($file_info =~ m/BuildID\[sha1]\s*=\s*([0-9a-f]{2})([0-9a-f]+)/ or
+			  `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";
+			$debug_build_id="${1}${2}";
+			push(@build_ids, $debug_build_id);
+		} elsif ($use_build_id > 1) {
+			# For dbgsyms, we need build-id (else it will not be
+			# co-installable).
+			return if $use_build_id > 1;
+		}
 	}
-	else {
+	if (not $debug_path) {
+		# Either not using build_id OR no build-id available
 		my ($base_file)=$file=~/^\Q$tmp\E(.*)/;
 		$debug_path=$desttmp."/usr/lib/debug/".$base_file;
 	}

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