Bug#879130: choose-mirror: empty mirror list on non released architectures
Hello,
Samuel Thibault, le mer. 13 nov. 2019 00:12:50 +0100, a ecrit:
> I have significantly reworked and simplified the patch:
I have modified it a bit to fix the "directory" value in the manual
configuration, which should be /debian-ports/
That is useful for the case when there is no mirror for the ports
architecture (which is e.g. the case for hurd-i386 ATM).
I could test it with success on hurd-i386 with a mirror for the arch,
on hurd-i386 without a mirror for the arch, and on linux-amd64 (thus
non-port), it behave fine.
Any red flag before I commit?
Samuel
> - avoid creating several files at the same time
> - always create usr/lib/choose-mirror/port_architecture to make rules
> much simpler.
> - use a single variable $archive that normally contains 'archive' but
> can be set to 'ports'.
>
> so that we end up only doing this in mirrorlist:
>
> - set $archive to 'archive' by default
> - loop for the architecture in a Ports-architecture field, if so set
> $archive to 'ports'.
> - replace 'archive' with $archive in the strings.
> - create the port_architecture containing either 0 or 1 when requested to
>
> I tried to build with on amd64 and on hurd-i386, I am getting the expected results:
> - /usr/lib/choose-mirror/port_architecture contains 0 on amd64 and 1 on
> hurd-i386.
> - The choose-mirror binary contains the full mirror list on amd64, it
> contains only deb.debian.org on hurd-i386.
>
> Does anybody think of anything else I should check before I commit this?
diff --git a/Makefile b/Makefile
index b4a7ecc..e10c167 100644
--- a/Makefile
+++ b/Makefile
@@ -86,7 +86,10 @@ debian/httpslist-countries: $(MASTERLIST) debian/iso_3166.tab
debian/ftplist-countries: $(MASTERLIST) debian/iso_3166.tab
./mirrorlist ftplist $^
-debian/choose-mirror-bin.templates: $(MASTERLIST) $(templates) debian/httplist-countries debian/httpslist-countries debian/ftplist-countries debian/iso_3166.tab
+debian/port_architecture: $(MASTERLIST) debian/iso_3166.tab
+ ./mirrorlist port_architecture $^
+
+debian/choose-mirror-bin.templates: $(MASTERLIST) $(templates) debian/httplist-countries debian/httpslist-countries debian/ftplist-countries debian/iso_3166.tab debian/port_architecture
# Grab ISO codes from iso-codes package
./get-iso-codes
# Build the templates
@@ -132,6 +135,7 @@ clean:
rm -f demo demo.templates
rm -rf debian/iso-codes/ debian/pobuild*/
rm -f debian/iso_3166.tab
+ rm -f debian/port_architecture
reallyclean: clean
rm -f debian/choose-mirror-bin.templates
diff --git a/debian/choose-mirror-bin.install b/debian/choose-mirror-bin.install
index 7a92821..568306a 100644
--- a/debian/choose-mirror-bin.install
+++ b/debian/choose-mirror-bin.install
@@ -1 +1,2 @@
choose-mirror bin
+debian/port_architecture usr/lib/choose-mirror
diff --git a/mirrorlist b/mirrorlist
index 0a811b2..f3b6925 100755
--- a/mirrorlist
+++ b/mirrorlist
@@ -104,12 +104,28 @@ foreach my $id (0..$#data) {
$data[$id]->{rating}=$rating;
}
+# Defaults for released architectures
+my $archive = 'archive';
+
+# Is $hostarch a port architecture ?
+# Such architectures appear in a Ports-architecture: field
+foreach my $id (0..$#data) {
+ if (exists $data[$id]->{'ports-architecture'}) {
+ my @arches = split ' ', $data[$id]->{'ports-architecture'};
+ my %arches = map { $_ => 1 } @arches;
+ if (exists $arches{$hostarch} or exists $arches{'!'.$hostarch}) {
+ $archive = 'ports';
+ last;
+ }
+ }
+}
+
# Filter out mirrors that don't carry the target architecture.
my @newdata;
foreach my $id (0..$#data) {
- if (exists $data[$id]->{'archive-architecture'} &&
- $data[$id]->{'archive-architecture'} ne "any") {
- my @arches = split ' ', $data[$id]->{'archive-architecture'};
+ if (exists $data[$id]->{"$archive-architecture"} &&
+ $data[$id]->{"$archive-architecture"} ne "any") {
+ my @arches = split ' ', $data[$id]->{"$archive-architecture"};
if (grep /^!/, @arches) {
my %notarches = map { substr($_, 1) => 1 } grep /^!/, @arches;
next if exists $notarches{$hostarch};
@@ -126,7 +142,7 @@ if ($type =~ /(.*)list/) {
my $type=$1;
open (LIST, ">debian/${type}list-countries") or die "debian/${type}list-countries: $!";
foreach my $id (0..$#data) {
- next unless exists $data[$id]->{"archive-$type"} and
+ next unless exists $data[$id]->{"$archive-$type"} and
exists $data[$id]->{country};
my $cc = $data[$id]->{country};
die "Error: country code '$cc' does not occur in iso-3166 table"
@@ -138,6 +154,15 @@ if ($type =~ /(.*)list/) {
}
close LIST;
}
+elsif ($type eq "port_architecture") {
+ open(OUT,"> debian/port_architecture") || die "Unable to write debian/port_architecture\n";
+ if ($archive eq 'ports') {
+ print OUT "1";
+ } else {
+ print OUT "0";
+ }
+ close OUT;
+}
else {
open (OUT, ">mirrors_$type.h") or die "mirrors_$type.h: $!";
print OUT "/* Automatically generated; do not edit. */\n";
@@ -154,13 +179,13 @@ else {
else {
$cc=$q.$data[$id]->{country}.$q;
}
- next unless exists $data[$id]->{"archive-$type"} and defined $cc;
- if (! exists $data[$id]->{'archive-architecture'}) {
- print STDERR "warning: missing archive-architecture for mirror ".$data[$id]->{site}."; assuming it contains all architectures.\n";
+ next unless exists $data[$id]->{"$archive-$type"} and defined $cc;
+ if (! exists $data[$id]->{"$archive-architecture"}) {
+ print STDERR "warning: missing $archive-architecture for mirror ".$data[$id]->{site}."; assuming it contains all architectures.\n";
}
print OUT "\t{",
join(", ", $q.$data[$id]->{site}.$q, $cc,
- $q.$data[$id]->{"archive-$type"}.$q),
+ $q.$data[$id]->{"$archive-$type"}.$q),
"},\n";
}
print OUT "\t{NULL, NULL, NULL}\n";
diff --git a/mktemplates b/mktemplates
index 8240550..b0c9d6f 100755
--- a/mktemplates
+++ b/mktemplates
@@ -15,6 +15,18 @@ if [ -z "$DEB_HOST_ARCH" ]; then
DEB_HOST_ARCH="$(dpkg-architecture -qDEB_HOST_ARCH)"
fi
+if [ "$(cat debian/port_architecture)" = 1 ]; then
+ set_debian_ports() {
+ perl -pe 'if (m,http/directory$,) { $found = 1; } elsif ($found and /^Default:/) { s/\/debian\/$/\/debian-ports\//; $found = 0; }' | \
+ perl -pe 'if (m,https/directory$,) { $found = 1; } elsif ($found and /^Default:/) { s/\/debian\/$/\/debian-ports\//; $found = 0; }' | \
+ perl -pe 'if (m,ftp/directory$,) { $found = 1; } elsif ($found and /^Default:/) { s/\/debian\/$/\/debian-ports\//; $found = 0; }'
+ }
+else
+ set_debian_ports() {
+ cat
+ }
+fi
+
# Get the English names for the country codes in the list
country_names() {
# Ensure commas in country names end up escaped
@@ -46,6 +58,7 @@ printf "Insert the lists of choices into the templates file..."
echo
done
) | debian/templates-build.pl "$DEB_HOST_ARCH" | \
+ set_debian_ports | \
perl -pe 'if (m,http/countries$,) { $found = 2; } elsif ($found and /^Choices-C:/ && length "'"$HTTPCODECHOICES"'") { s/$/, '"$HTTPCODECHOICES"'/; $found -= 1; } elsif ($found and /^__Choices:/ && length "'"$HTTPCHOICES"'") { s/$/'"$HTTPCHOICES"'/; $found -= 1; }' | \
perl -pe 'if (m,https/countries$,) { $found = 2; } elsif ($found and /^Choices-C:/ && length "'"$HTTPSCODECHOICES"'") { s/$/, '"$HTTPSCODECHOICES"'/; $found -= 1; } elsif ($found and /^__Choices:/ && length "'"$HTTPSCHOICES"'") { s/$/'"$HTTPSCHOICES"'/; $found -= 1; }' | \
perl -pe 'if (m,ftp/countries$,) { $found = 2; } elsif ($found and /^Choices-C:/ && length "'"$FTPCODECHOICES"'") { s/$/, '"$FTPCODECHOICES"'/; $found -= 1; } elsif ($found and /^__Choices:/ && length "'"$FTPCHOICES"'") { s/$/'"$FTPCHOICES"'/; $found -= 1; }' \
Reply to: