[debhelper-devel] [debhelper] 01/01: Add debug build ids to the Binary package's control file
Niels Thykier
nthykier at moszumanska.debian.org
Mon Aug 17 16:32:17 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 69a8a6dc5b3e26fb2f1cc75619e4a5742540d48e
Author: Paul Tagliamonte <paultag at debian.org>
Date: Mon Aug 17 18:21:37 2015 +0200
Add debug build ids to the Binary package's control file
This will add `X-Build-Ids` to debug debs, which will be a space
separated list of build ids provided by this package. This will allow
tools to work out which .deb will provide the build-id required to
install symbols for a given coredump.
Signed-off-by: Niels Thykier <niels at thykier.net>
---
debian/changelog | 2 ++
dh_gencontrol | 22 ++++++++++++++++------
dh_strip | 21 ++++++++++++++++-----
3 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 6922be6..64470af 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,8 @@ debhelper (9.20150811+unreleased) UNRELEASED; urgency=medium
[ Paul Tagliamonte ]
* dh_gencontrol: Put debug debs back in the "debug" section.
+ * dh_strip/dh_gencontrol: Add a space separated list of
+ build-ids.
-- Paul Tagliamonte <paultag at debian.org> Fri, 14 Aug 2015 21:25:16 +0200
diff --git a/dh_gencontrol b/dh_gencontrol
index 1abf91c..7512545 100755
--- a/dh_gencontrol
+++ b/dh_gencontrol
@@ -83,6 +83,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
if ( -d $ddeb_tmp) {
my $multiarch = package_multiarch($package);
my $replaces = read_ddeb_migration($ddeb_info_dir);
+ my $build_ids = read_ddeb_build_ids($ddeb_info_dir);
# Remove and override more or less every standard field.
my @ddeb_options = (qw(
@@ -92,6 +93,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
"-DPackage=${package}-dbgsym",
"-DDepends=${package} (= \${binary:Version})",
"-DDescription=Debug symbols for ${package}",
+ "-DX-Build-Ids=${build_ids}",
);
# Disable multi-arch unless the original package is an
# multi-arch: same package. In all other cases, we do not
@@ -129,19 +131,27 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
doit("chown","0:0","$tmp/DEBIAN/control");
}
-sub read_ddeb_migration {
- my ($ddeb_info_dir) = @_;
- my $ddeb_migration = "${ddeb_info_dir}/ddeb-migration";
+sub read_ddeb_file {
+ my ($ddeb_info_file, $ddeb_info_dir) = @_;
+ my $ddeb_path = "${ddeb_info_dir}/${ddeb_info_file}";
my $result;
- if (-f $ddeb_migration) {
- open(my $fd, '<', $ddeb_migration)
- or error("open $ddeb_migration failed: $!");
+ if (-f $ddeb_path) {
+ open(my $fd, '<', $ddeb_path)
+ or error("open $ddeb_path failed: $!");
chomp($result = <$fd>);
close($fd);
}
return $result;
}
+sub read_ddeb_migration {
+ return read_ddeb_file('ddeb-migration', @_);
+}
+
+sub read_ddeb_build_ids {
+ return read_ddeb_file('ddeb-build-ids', @_);
+}
+
=head1 SEE ALSO
L<debhelper(7)>
diff --git a/dh_strip b/dh_strip
index be82691..0cb98eb 100755
--- a/dh_strip
+++ b/dh_strip
@@ -186,7 +186,7 @@ sub testfile {
# Does its filename look like a shared library?
# - *.cmxs are OCaml native code shared libraries
- # - *.node are also native ELF binaries (for node-js)
+ # - *.node are also native ELF binaries (for node-js)
if (m/.*\.(?:so.*?|cmxs|node)$/) {
# Ok, do the expensive test.
my $type=get_file_type($_);
@@ -220,7 +220,7 @@ sub testfile {
}
sub make_debug {
- my ($file, $tmp, $desttmp, $use_build_id) = @_;
+ my ($file, $tmp, $desttmp, $use_build_id, $package) = @_;
# Don't try to copy debug symbols out if the file is already
# stripped.
@@ -228,9 +228,12 @@ sub make_debug {
my ($base_file)=$file=~/^\Q$tmp\E(.*)/;
my $debug_path;
+ my $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_path=$desttmp."/usr/lib/debug/.build-id/$1/$2.debug";
+ $debug_build_id=$2;
}
elsif ($use_build_id > 1) {
# For ddebs, we need build-id (else it will not be co-installable).
@@ -250,6 +253,14 @@ sub make_debug {
# Compat 9 OR a ddeb.
doit($objcopy, "--only-keep-debug", "--compress-debug-sections", $file, $debug_path);
}
+
+ if ($use_build_id) {
+ my $path = "debian/.debhelper/${package}/ddeb-build-ids";
+ open(my $fd, '>>', $path) or error("open $path failed: $!");
+ print {$fd} "$debug_build_id ";
+ close($fd) or error("close $path failed: $!");
+ }
+
# No reason for this to be executable.
doit("chmod", "0644", $debug_path);
return $debug_path;
@@ -301,7 +312,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
find(\&testfile,$tmp);
foreach (@shared_libs) {
- my $debug_path = make_debug($_, $tmp, $debugtmp, $use_build_id) if $keep_debug;
+ my $debug_path = make_debug($_, $tmp, $debugtmp, $use_build_id, $package) if $keep_debug;
# Note that all calls to strip on shared libs
# *must* include the --strip-unneeded.
doit($strip,"--remove-section=.comment",
@@ -310,7 +321,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
foreach (@executables) {
- my $debug_path = make_debug($_, $tmp, $debugtmp, $use_build_id) if $keep_debug;
+ my $debug_path = make_debug($_, $tmp, $debugtmp, $use_build_id, $package) if $keep_debug;
doit($strip,"--remove-section=.comment",
"--remove-section=.note",$_);
attach_debug($_, $debug_path) if defined $debug_path;
--
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