summaryrefslogtreecommitdiff
path: root/dh_strip
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2017-12-16 13:25:36 +0000
committerNiels Thykier <niels@thykier.net>2017-12-16 13:25:36 +0000
commit6dfb3f5321d9ca32e1e1ce6bb8f2af6ed69560f0 (patch)
tree7d4102622b6dd3b65ef1dff581dab2fe36edc01a /dh_strip
parent6503cf535c01726cb63f17f4c67499233103a175 (diff)
downloaddebhelper-6dfb3f5321d9ca32e1e1ce6bb8f2af6ed69560f0.tar.gz
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@thykier.net>
Diffstat (limited to 'dh_strip')
-rwxr-xr-xdh_strip30
1 files changed, 17 insertions, 13 deletions
diff --git a/dh_strip b/dh_strip
index 6261c83d..420031ba 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}) {