Discussion:
Bug#870166: multistrap: Fails if more than one section with the same keyring
Johannes Schauer
2017-07-30 17:25:04 UTC
Permalink
Package: multistrap
Version: 2.2.9
Severity: normal
Tags: patch

Steps to reproduce:

Create a config file where multiple sections have the same keyring entry
with the same keyring package name. The result will be that one of the
earlier loop iterations removes the package name that is used in later
iterations. The solution is to only iterate over unique package names:

diff --git a/multistrap b/usr/sbin/multistrap
index d7955cd..a3dfe62 100755
--- a/multistrap
+++ b/usr/sbin/multistrap
@@ -267,7 +267,9 @@ foreach my $aptsrc (@debootstrap) {
}
}
my $k;
-foreach my $pkg (values %keyrings) {
+my @unique_keyrings = values %keyrings;
+uniq_sort(\@unique_keyrings);
+foreach my $pkg (@unique_keyrings) {
next if (not defined $pkg);
next if ("" eq "$pkg");
$k .= "$pkg ";
@@ -275,7 +277,7 @@ foreach my $pkg (values %keyrings) {
if ((defined $k) and (not defined $noauth)) {
printf (_g("I: Downloading %s\n"), $k);
system ("apt-get -y download $k");
- foreach my $keyring_pkg (values %keyrings) {
+ foreach my $keyring_pkg (@unique_keyrings) {
next if (not defined $keyring_pkg);
my @files=();
my $file = `find ./ -name "${keyring_pkg}_*_all.deb"|grep -m1 $keyring_pkg`;
@@ -377,7 +379,7 @@ foreach my $sect (sort keys %packages) {
}
}
chomp($str);
-foreach my $keystr (values %keyrings) {
+foreach my $keystr (@unique_keyrings) {
next if (not defined $keystr);
$str .= " " . $keystr . " ";
}

Loading...