Skip to content
Snippets Groups Projects
Commit 207bb465 authored by Ryan Gonzalez's avatar Ryan Gonzalez
Browse files

dh_setup_copyright: Don't use the apt cache to find source package names

The OBS builders don't have any source lists set up, so `apt-cache
showsrc` never finds any results. Instead, we can rely on dpkg-query to
extract the info, along with some adjustments to get the correct version
value.

https://phabricator.apertis.org/T9756



Signed-off-by: default avatarRyan Gonzalez <ryan.gonzalez@collabora.com>
parent f4ebdf6c
No related branches found
No related tags found
1 merge request!25dh_setup_copyright: Don't use the apt cache to find source package names
Pipeline #690764 canceled
debhelper (13.11.4+apertis3) apertis; urgency=medium
* dh_setup_copyright: Don't use the apt cache to find source package names
-- Ryan Gonzalez <ryan.gonzalez@collabora.com> Thu, Nov 14 2023 15:12:00 -0600
debhelper (13.11.4+apertis2) apertis; urgency=medium
* dh_setup_copyright: Save source package names for external files
......
......@@ -126,22 +126,19 @@ sub find_source_package_for_package {
my $cached = $packages_to_srcpackages_cache{$package};
return @$cached if defined $cached;
my $stanza = `apt-cache showsrc "$package"`;
my ($srcpackage) = $stanza =~ /Package: (.*)/;
my ($srcversion) = $stanza =~ /Version: (.*)/;
return undef if !defined $srcpackage || !defined $srcversion;
my ($binpkgs) = $stanza =~ /Binary: (.*)/;
for my $binpkg (split /,\s*/, $binpkgs) {
my $existing = $packages_to_srcpackages_cache{$binpkg};
if (defined $existing) {
print STDERR "WARNING: $binpkg is tied to multiple source packages:",
" '$existing->[0]' and '$srcpackage'\n";
} else {
$packages_to_srcpackages_cache{$binpkg} = [$srcpackage, $srcversion];
}
}
my ($version, $srcpackage, $srcversion) =
`dpkg-query -f '\${Version} \${Source}' -W '$package'`
# Note that the source version *might* be in the Source field, so make
# sure to extract it if so.
=~ /(\S+) (\S+)(?: \((.*)\))?/;
$srcpackage ||= $package;
$srcversion ||= $version;
return undef if !defined $srcversion;
# Strip off the build suffix.
$srcversion =~ s/(apertis(?:\d+))b.*/$1/;
$packages_to_srcpackages_cache{$package} = [$srcpackage, $srcversion];
($srcpackage, $srcversion);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment