texlive[70877] Master/tlpkg/bin/tl-update-ctan-mirrors: count good

commits+karl at tug.org commits+karl at tug.org
Sun Apr 7 00:29:01 CEST 2024


Revision: 70877
          https://tug.org/svn/texlive?view=revision&revision=70877
Author:   karl
Date:     2024-04-07 00:29:01 +0200 (Sun, 07 Apr 2024)
Log Message:
-----------
count good mirrors, quit if fewer than 50.

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tl-update-ctan-mirrors

Modified: trunk/Master/tlpkg/bin/tl-update-ctan-mirrors
===================================================================
--- trunk/Master/tlpkg/bin/tl-update-ctan-mirrors	2024-04-06 21:10:26 UTC (rev 70876)
+++ trunk/Master/tlpkg/bin/tl-update-ctan-mirrors	2024-04-06 22:29:01 UTC (rev 70877)
@@ -86,6 +86,7 @@
 
   open (CTAN_SITES,"<$ctan_sites") || die "$0: open($ctan_sites) failed: $!\n";
 
+  my $nmirrors = 0;
   my ($continent,$country,$mirror);
   while (<CTAN_SITES>) {
     chomp;
@@ -102,10 +103,11 @@
 
     } elsif (m!^ +URL: (ftp|https?|rsync)://([-a-zA-Z0-9.]+)/([-\w/]*)!) {
       next if $1 eq "rsync"; # we can't use rsync, so skip
+      next if $1 eq "ftp";   # ftp not well supported anymore, skip
       my $protocol = $1;
       my $ppath = "$2/$3";
-      add_mirror(\%mirrors, $continent, $country, $mirror, $protocol, $ppath,
-                 $good_urls_ref);
+      $nmirrors += &maybe_add_mirror(\%mirrors, $continent, $country, $mirror,
+                                     $protocol, $ppath, $good_urls_ref);
 
     } else {
       last if /^Please send updates/; # quite at final blurb
@@ -114,28 +116,36 @@
     }
   }
 
-  die "no ctan mirrors found in $ctan_sites" if keys %mirrors == 0;
+  die "too few ($nmirrors) ctan mirrors found in $ctan_sites"
+    if $nmirrors < 50; # if tons have failed, probably better to preserve list
+  warn "$nmirrors mirrors found in $ctan_sites.\n" if $verbose;
+
   return %mirrors;
 }
 
-# Subroutine for read_readme_mirror.
+# Subroutine for read_readme_mirror to check $P://$PPATH.
+# Return 1 if ok, 0 else.
 # 
-sub add_mirror {
+sub maybe_add_mirror {
   my ($mirref,$continent,$country,$mirror,$p,$ppath,$good_urls_ref) = @_;
   my $url = "$p://$ppath";
-  #warn "considering $url ($continent $country)";
+  warn "  considering $url ($continent $country)\n" if $verbose > 1;
+  my $ok = 0;
   
   if (exists $good_urls_ref->{$url}) {
     if ($good_urls_ref->{$url}) {
       $mirref->{$continent}{$country}{$url} = 1;
-      warn "  ok: $url\n" if $verbose > 1;
+      warn "   ok: $url\n" if $verbose > 1;
+      $ok = 1;
     } else {
-      warn "  probe not ok, skipped: $url\n" if $verbose;
+      warn "   probe not ok, skipped: $url\n" if $verbose;
     }
   } else {
     # CTAN.sites has many more urls than mirmon, so don't worry about it.
-    warn "  not in mirmon file, skipped: $url\n" if $verbose > 1;
+    warn "   not in mirmon file, skipped: $url\n" if $verbose > 1;
     # Also the mirmon file has some old urls that aren't in CTAN.sites,
     # so don't worry about that direction either, on occasion.
   }
+  
+  return $ok;
 }



More information about the tex-live-commits mailing list.