diff --git a/find-dbgsym-packages b/find-dbgsym-packages index 9c2544d..1a91aa0 100755 --- a/find-dbgsym-packages +++ b/find-dbgsym-packages @@ -81,12 +81,13 @@ %build_ids = get_build_ids_from_file($arg); } + my %debs_from_id = get_debs_from_ids(keys %build_ids); foreach my $id (keys %build_ids) { my ($path, $name) = @{$build_ids{$id}}; next if $name =~ $vdso_regexp; - my @p = get_debs_from_id($id); + my @p = @{$debs_from_id{$id} // []}; if (scalar @p == 0) { @p = get_debs_from_path($path); if (scalar @p == 0) { @@ -318,15 +319,23 @@ return parse_eu_unstrip($output); } -sub get_debs_from_id -{ - my ($id) = @_; - +sub get_debs_from_ids +{ + my $id_regexp = join('|', @_); + my %map; my $output; - $output = capturex([0, 1], qw(grep-aptavail --no-field-names --show-field Package --field Build-IDs --pattern), $id); - - my %pkgs = map { $_ => 1 } split(/\n/, $output); - return sort keys %pkgs; + $output = capturex([0, 1], qw(grep-aptavail --no-field-names --show-field Package --show-field Build-IDs --field Build-IDs --eregex --pattern), $id_regexp); + while ($output =~ /\G(\S+)\n(\S+(?: \S+)*)\n\n/gc) { + my $pkg = $1; + my $ids = $2; + while ($ids =~ m/\b($id_regexp)\b/g) { + push @{$map{$1}}, $pkg; + } + } + if (length $output != (pos $output // 0)) { + die "Cannot parse grep-aptavail output"; + } + return %map; } sub get_debs_from_path