diff options
author | Niels Thykier <niels@thykier.net> | 2016-06-15 17:58:30 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2016-06-15 20:20:30 +0000 |
commit | 6942cb4f951cb69b46dd741c715de724eea5943a (patch) | |
tree | d11516899c458cf79bd24ad08ba846399fa93c38 | |
parent | 6b5663cc2ddfd73308653dad17874ec9fd7a825a (diff) | |
download | debhelper-6942cb4f951cb69b46dd741c715de724eea5943a.tar.gz |
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@thykier.net>
-rw-r--r-- | debian/changelog | 3 | ||||
-rwxr-xr-x | dh_strip | 32 |
2 files changed, 20 insertions, 15 deletions
diff --git a/debian/changelog b/debian/changelog index ba895dce..950f0b3d 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@thykier.net> Sat, 09 Apr 2016 09:20:32 +0000 @@ -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; } |