Codebase list debian-goodies / b369493
Search for likely debug symbols packages based on the library path Various packages have bad meta-data about Build-Ids or are old-style manual -dbg packages with no meta-data. By searching which binary and source package the library path is from, it is possible to guestimate fairly accurate debug symbols packages. Paul Wise 6 years ago
2 changed file(s) with 69 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
8181
8282 Files: find-dbgsym-packages
8383 Copyright: 2017 Stefan Fritsch <sf@debian.org>
84 2017 Paul Wise <pabs@debian.org>
8485 License: GPL-2+
8586
8687 Files: find-dbgsym-packages.pod
33 # program/library.
44 #
55 # Copyright (C) 2017 Stefan Fritsch <sf@debian.org>
6 # Copyright (C) 2017 Paul Wise <pabs@debian.org>
67 #
78 # This program is free software; you can redistribute it and/or modify
89 # it under the terms of the GNU General Public License as published by
4041 }
4142
4243 foreach my $id (keys %build_ids) {
43 my $name = $build_ids{$id};
44 my ($path, $name) = @{$build_ids{$id}};
4445
4546 next if $name =~ /^linux-vdso[.]so[.]/;
4647
4748 my @p = get_debs_from_id($id);
4849 if (scalar @p == 0) {
49 warn "Cannot find debug package for $name ($id)\n";
50 @p = get_debs_from_path($path);
51 if (scalar @p == 0) {
52 warn "Cannot find debug package for $name ($id)\n";
53 }
5054 } elsif (scalar @p > 1) {
5155 warn "Multiple packages for $name ($id): @p\n";
5256 }
7983 \s+
8084 ([[:xdigit:]]{40} [@] 0x[[:xdigit:]]+ | - )
8185 \s+
82 \S+
86 (\S+)
8387 \s+
8488 (\S+)
8589 \s+
8690 (\S.*)
8791 $}ix) {
8892 my $id = $1;
89 my $debug = $2;
90 my $name = $3;
93 my $path = $2;
94 my $debug = $3;
95 my $name = $4;
9196 if ($debug ne '-') {
9297 next;
9398 }
102107 } else {
103108 die "BUG: id='$id'";
104109 }
105 $ids{$id} = $name;
110 if ($path eq '-' || $path eq '.') {
111 $path = $name;
112 $path =~ s{ \(deleted\)$}{};
113 }
114 $ids{$id} = [$path, $name];
106115 } else {
107116 warn "Cannot parse eu-unstrip output: '$line'\n";
108117 }
141150
142151 my %pkgs = map { $_ => 1 } split(/\n/, $output);
143152 return sort keys %pkgs;
153 }
154
155 sub get_debs_from_path
156 {
157 my ($path) = @_;
158
159 my $output;
160 eval {
161 ($output, undef) = capturex(qw(dpkg-query --search --), $path);
162 };
163 if ($@) {
164 return;
165 }
166
167 my %pkgs = ();
168 foreach my $line (split(/\n/, $output)) {
169 if ($line =~ /^(.*): /) {
170 $pkgs{$1} = 1;
171 } else {
172 warn "Cannot parse dpkg-query output: '$line'\n";
173 }
174 }
175 my @pkgs = sort keys %pkgs;
176 my @strip_pkgs = map { s{:.*}{}; s{\d.*$}{}r } @pkgs;
177
178 eval {
179 ($output, undef) = capturex(qw(dpkg-query --showformat ${source:Package}\n --show --), @pkgs);
180 };
181 if ($@) {
182 return;
183 }
184
185 my %dbg_pkgs = ();
186 foreach my $src_pkg (split(/\n/, $output)) {
187 my $output;
188 eval {
189 $output = capturex(qw(grep-aptavail --no-field-names --show-field Package --field Package --pattern -dbg --and --whole-pkg --field Source:Package --pattern), $src_pkg);
190 };
191 if ($@) {
192 warn "No dbg package for source '$src_pkg'\n";
193 next;
194 }
195 my %src_dbg_pkgs = map { $_ => 1 } split(/\n/, $output);
196 my @src_dbg_pkgs = keys %src_dbg_pkgs;
197 my @src_strip_pkgs = map { my $pkg = $_; grep { /^$pkg-dbg/ } @src_dbg_pkgs } @pkgs;
198 @src_strip_pkgs = map { my $pkg = $_; grep { /^$pkg.*-dbg/ } @src_dbg_pkgs } @pkgs unless @src_strip_pkgs;
199 @src_strip_pkgs = map { my $pkg = $_; grep { /^$pkg-dbg/ } @src_dbg_pkgs } @strip_pkgs unless @src_strip_pkgs;
200 @src_strip_pkgs = map { my $pkg = $_; grep { /^$pkg.*-dbg/ } @src_dbg_pkgs } @strip_pkgs unless @src_strip_pkgs;
201 @src_dbg_pkgs = @src_strip_pkgs if @src_strip_pkgs;
202 map { $dbg_pkgs{$_} = 1; } @src_dbg_pkgs;
203 };
204
205 return sort keys %dbg_pkgs;
144206 }
145207
146208 sub is_core_file