use Debian::DistroInfo if available

This commit is contained in:
Johannes 'josch' Schauer 2020-11-28 00:46:48 +01:00
parent b2ea7b230f
commit b7e257871d
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -3925,8 +3925,17 @@ sub get_sourceslist_by_suite {
$sourceslist .= "deb$signedby $mirror $suite-updates $compstr\n"; $sourceslist .= "deb$signedby $mirror $suite-updates $compstr\n";
# the security mirror changes, starting with bullseye # the security mirror changes, starting with bullseye
# https://lists.debian.org/87r26wqr2a.fsf@43-1.org # https://lists.debian.org/87r26wqr2a.fsf@43-1.org
my $distro_info = '/usr/share/distro-info/debian.csv'; my $bullseye_or_later = 0;
if (-f $distro_info) { my $distro_info = '/usr/share/distro-info/debian.csv';
eval { require Debian::DistroInfo; };
if (!$@) {
# libdistro-info-perl is installed
my $debinfo = DebianDistroInfo->new();
if ($debinfo->version($suite, 0) >= 11) {
$bullseye_or_later = 1;
}
} elsif (-f $distro_info) {
# distro-info-data is installed
open my $fh, '<', $distro_info open my $fh, '<', $distro_info
or error "cannot open $distro_info: $!"; or error "cannot open $distro_info: $!";
my $i = 0; my $i = 0;
@ -3960,23 +3969,22 @@ sub get_sourceslist_by_suite {
} }
close $fh; close $fh;
if ($matching_version >= 11) { if ($matching_version >= 11) {
# starting from bullseye use $bullseye_or_later = 1;
$sourceslist
.= "deb$signedby $secmirror $suite-security" . " $compstr\n";
} else {
$sourceslist
.= "deb$signedby $secmirror $suite/updates" . " $compstr\n";
} }
} else { } else {
# neither libdistro-info-perl nor distro-info-data is installed
if (any { $_ eq $suite } ('bullseye', 'bookworm')) { if (any { $_ eq $suite } ('bullseye', 'bookworm')) {
# starting from bullseye use $bullseye_or_later = 1;
$sourceslist
.= "deb$signedby $secmirror $suite-security" . " $compstr\n";
} else {
$sourceslist
.= "deb$signedby $secmirror $suite/updates" . " $compstr\n";
} }
} }
if ($bullseye_or_later) {
# starting from bullseye use
$sourceslist
.= "deb$signedby $secmirror $suite-security" . " $compstr\n";
} else {
$sourceslist
.= "deb$signedby $secmirror $suite/updates" . " $compstr\n";
}
} }
return $sourceslist; return $sourceslist;
} }