[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

using cdn.debian.net with choose-mirror

Somehow I was not aware of cdn.debian.net until recently, but it seems
solid and good in the 3 countries I've tried it from. In particular in
the US, it's more reliable than using the http.us.debian.org rotation,
because it detects and disables failing mirrors. Its weighted load
balancing also seems good; it seems to pick fast mirrors.

I'd like it to be at least an option in choose-mirror. Possibly the default
for countries that it supports well[1]. Probably not the only choice,
since that would introduce a single point of failure. Maybe eventually,
the default and only prompt to choose a mirror if it fails.

The attached patch will, once cdn.debian.net is added to Mirrors.masterlist,
make choose-mirror include it as a choice in the list of mirrors for
all the countries the data says it supports.

For now I've sorted it below push-primary and push-secondary mirrors,
but above leaf mirrors. So it's not the default choice for most countries.

see shy jo

[1] cdn.debian.net does not include all countries that have Debian
    mirrors. For example, Costa Rica has a mirror that it does not
    include for whatever reason. I'm unsure if it directs Costa Rican
    users to a mirror in a nearby country.
diff --git a/packages/choose-mirror/debian/changelog b/packages/choose-mirror/debian/changelog
index f85efd1..d01a1a3 100644
--- a/packages/choose-mirror/debian/changelog
+++ b/packages/choose-mirror/debian/changelog
@@ -1,3 +1,13 @@
+choose-mirror (2.34) UNRELEASED; urgency=low
+  * Support entries in Mirrors.masterlist of "Type: GeoIP", which have
+    a Countries field listing all countries the GeoIP mirror supports well.
+  * For now, GeoIP mirrors are listed above Leaf mirrors, but after
+    Push-Primary and Push-Secondary mirrors. We may later choose to
+    change the ordering so cdn.debian.net is used by default.
+ -- Joey Hess <joeyh@debian.org>  Sat, 29 May 2010 19:19:00 -0400
 choose-mirror (2.33) unstable; urgency=low
   * Correctly move progress bar to 100% after reading suites.
diff --git a/packages/choose-mirror/mirrorlist b/packages/choose-mirror/mirrorlist
index c5b6996..1444bf6 100755
--- a/packages/choose-mirror/mirrorlist
+++ b/packages/choose-mirror/mirrorlist
@@ -80,12 +80,13 @@ for (my $id = 0; $id < @data; $id++) {
-# Poor man's mirror rating system: push-primary, push* (-secondary), others
+# Poor man's mirror rating system: push-primary, push* (-secondary), geoip, others
 foreach my $id (0..$#data) {
 	my $rating=0;
 	if (exists $data[$id]->{type}) {
-	        $rating=1 if $data[$id]->{type} =~ /push/i;
-                $rating=2 if $data[$id]->{type} =~ /push-primary/i;
+	        $rating=1 if $data[$id]->{type} =~ /geoip/i;
+	        $rating=2 if $data[$id]->{type} =~ /push/i;
+                $rating=3 if $data[$id]->{type} =~ /push-primary/i;
@@ -132,15 +133,23 @@ else {
 	print OUT "static struct mirror_t mirrors_$type\[] = {\n";
 	my $q='"';
 	foreach my $id (sort { $data[$b]->{rating} <=> $data[$a]->{rating} } 0..$#data) {
-		next unless exists $data[$id]->{"archive-$type"} and
-			    exists $data[$id]->{country};
-		if (! exists $data[$id]->{'archive-architecture'}) {
-			print STDERR "warning: missing archive-architecture for mirror ".$data[$id]->{site}."; assuming it contains all architectures.\n";
+		my @cc;
+		if (exists $data[$id]->{type} && $data[$id]->{type} =~/geoip/i) {
+			@cc=split(' ', $data[$id]->{countries});
+		}
+		else {
+			@cc=$data[$id]->{country};
+		}
+		foreach my $cc (@cc) {
+			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, $q.$cc.$q,
+					$q.$data[$id]->{"archive-$type"}.$q),
+				  "},\n";
-		print OUT "\t{",
-			  join(", ", $q.$data[$id]->{site}.$q, $q.$data[$id]->{country}.$q,
-				$q.$data[$id]->{"archive-$type"}.$q),
-			  "},\n";
 	print OUT "\t{NULL, NULL, NULL}\n";
 	print OUT "};\n";

Attachment: signature.asc
Description: Digital signature

Reply to: