summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-03-27 18:01:15 +0000
committerKarl Berry <karl@freefriends.org>2020-03-27 18:01:15 +0000
commitfc18b20e99383e7ec65d47839e7763f74508d847 (patch)
tree110a07058e0869b6cf263906231e94321e4d8ad7
parent800ba8c247a36cc7b28181c8bbe40e6265956f0d (diff)
tl-update-ctan-mirrors: rewrite to avoid losing last entry; add -v option; update mirror list
git-svn-id: svn://tug.org/texlive/trunk@54581 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/tlpkg/bin/tl-update-ctan-mirrors98
-rw-r--r--Master/tlpkg/installer/ctan-mirrors.pl4
2 files changed, 52 insertions, 50 deletions
diff --git a/Master/tlpkg/bin/tl-update-ctan-mirrors b/Master/tlpkg/bin/tl-update-ctan-mirrors
index f4bd33b8ddf..8d59a406e6c 100755
--- a/Master/tlpkg/bin/tl-update-ctan-mirrors
+++ b/Master/tlpkg/bin/tl-update-ctan-mirrors
@@ -1,25 +1,34 @@
#!/usr/bin/env perl
# $Id$
-# Copyright 2011-2018 Norbert Preining
+# Copyright 2011-2020 Norbert Preining
# This file is licensed under the GNU General Public License version 2
# or any later version.
#
# Write parsable list of active CTAN mirrors; run from tl-update-auto cron.
# Needed input:
-# http://ctan.org/mirrors (CTAN.sites, README.mirrors)
+# http://ctan.org/mirrors (aka CTAN.sites and README.mirrors)
# rsync://comedy.dante.de/MirMon/mirmon.state
use strict;
$^W = 1;
use Data::Dumper;
+my $prg;
+my $verbose = 0;
+
exit (&main ());
sub main {
- if (@ARGV != 2) {
- die "Usage: $0 CTAN_SITES MIRMON_STATE.\n";
+ if (@ARGV != 2 && @ARGV != 3) {
+ die "Usage: $0 [-v] CTAN_SITES MIRMON_STATE.\n";
}
-
+ ($prg = $0) =~ s,^.*/,,;
+
+ if ($ARGV[0] eq "-v") {
+ $verbose = 1;
+ shift @ARGV;
+ }
+
my %good_urls = read_mstate($ARGV[1]);
my %ctan_sites = read_readme_mirror($ARGV[0], \%good_urls);
$Data::Dumper::Indent = 1;
@@ -43,7 +52,9 @@ sub read_mstate {
= split (' ');
if ($status_last_probe eq "ok") {
$good_urls{$m} = 1;
+ #warn "probe ok $m\n";
} else {
+ #warn "probe not ok $m\n";
$good_urls{$m} = 0;
}
}
@@ -59,72 +70,59 @@ sub read_mstate {
sub read_readme_mirror {
my ($ctan_sites,$good_urls_ref) = @_;
my %mirrors;
- my ($continent, $country, $mirror, %protocols);
open (CTAN_SITES,"<$ctan_sites") || die "$0: open($ctan_sites) failed: $!\n";
+
+ my ($continent,$country,$mirror);
while (<CTAN_SITES>) {
chomp;
- if (m/^ (Africa|Asia|Oceania|Europe|North America|South America)/) {
- my $save_continent = $1;
- #warn "got continent $save_continent\n";
- if (defined($mirror)) {
- for my $p (keys %protocols) {
- add_mirror(\%mirrors,$continent,$country,$mirror,$p,$protocols{$p},
- $good_urls_ref);
- }
- }
- $continent = $save_continent;
- $mirror = undef;
- $country = undef;
- %protocols = ();
- next;
- }
- next if ! defined $continent;
+ if (m/^ (Africa|Asia|Oceania|Europe|North America|South America)/) {
+ $continent = $1;
+ warn "got continent $continent\n" if $verbose;
+
+ } elsif (m/^ ([-a-zA-Z0-9.]+) \((.*)\)\s*$/) {
+ $mirror = $1;
+ $country = $2;
+ # make many names a little shorter
+ $country =~ s/^The //;
+ warn " got country $country, with mirror $mirror\n" if $verbose;
- if (m/^ ([-a-zA-Z0-9.]+) \((.*)\)\s*$/) {
- my $save_mirror = $1;
- my $save_country = $2;
- # make country names more reasonable
- $save_country =~ s/^The //;
- if (defined($mirror)) {
- for my $p (keys %protocols) {
- add_mirror(\%mirrors,$continent,$country,$mirror,$p,$protocols{$p},
- $good_urls_ref);
- }
- }
- $mirror = $save_mirror;
- $country = $save_country;
- %protocols = ();
- next;
- }
- next if ! defined($mirror);
+ } elsif (m!^ +URL: (ftp|https?|rsync)://([-a-zA-Z0-9.]+)/([-\w/]*)!) {
+ next if $1 eq "rsync"; # we can't use rsync, so skip
+ my $protocol = $1;
+ my $ppath = "$2/$3";
+ add_mirror(\%mirrors, $continent, $country, $mirror, $protocol, $ppath,
+ $good_urls_ref);
- if (m!^ URL: (ftp|https?|rsync)://([-a-zA-Z0-9.]+)/([-\w/]*)!) {
- $protocols{$1} = "$2/$3";
- next;
+ } else {
+ last if /^Please send updates/; # quite at final blurb
+ warn "$prg: ignored CTAN.sites url: $_\n" if /URL:/;
+ # some other kind of line, e.g., ==== or blank. Silently Ignore.
}
- #warn "ignored >>$_<<\n";
}
die "no ctan mirrors found in $ctan_sites" if keys %mirrors == 0;
return %mirrors;
}
-
+# Subroutine for read_readme_mirror.
+#
sub add_mirror {
my ($mirref,$continent,$country,$mirror,$p,$ppath,$good_urls_ref) = @_;
my $url = "$p://$ppath";
+ #warn "considering $url ($continent $country)";
+
if (exists $good_urls_ref->{$url}) {
if ($good_urls_ref->{$url}) {
- #$mirref->{$continent}{$country}{$mirror}{'protocols_path'}{$p} = $ppath;
$mirref->{$continent}{$country}{$url} = 1;
+ warn "ok: $url\n" if $verbose;
} else {
- printf STDERR "$0: mirror seems to be dead, skipped: $url\n";
+ warn "probe not ok, skipped: $url\n" if $verbose;
}
} else {
- # CTAN people leave out ftp/rsync, and intentionally let the
- # CTAN.sites file stay unchanged even when something is removed from
- # mirmon, on occasion. So don't complain about it.
- #printf STDERR "$0: mirror not in mirmon file, skipped: $url\n";
+ # CTAN.sites has many more urls than mirmon, so don't worry about it.
+ warn "not in mirmon file, skipped: $url\n" if $verbose;
+ # Also the mirmon file has some old urls that aren't in CTAN.sites,
+ # so don't worry about that direction either, on occasion.
}
}
diff --git a/Master/tlpkg/installer/ctan-mirrors.pl b/Master/tlpkg/installer/ctan-mirrors.pl
index c6a9ea9782a..33d15794e6c 100644
--- a/Master/tlpkg/installer/ctan-mirrors.pl
+++ b/Master/tlpkg/installer/ctan-mirrors.pl
@@ -166,6 +166,7 @@ $mirrors = {
},
'USA' => {
'http://ctan.math.illinois.edu/' => 1,
+ 'http://ctan.math.utah.edu/ctan/tex-archive/' => 1,
'http://ctan.math.washington.edu/tex-archive/' => 1,
'http://ctan.mirrors.hoobly.com/' => 1,
'http://mirror.las.iastate.edu/tex-archive/' => 1,
@@ -186,6 +187,9 @@ $mirrors = {
'South America' => {
'Brazil' => {
'http://linorg.usp.br/CTAN/' => 1
+ },
+ 'Chile' => {
+ 'http://ctan.dcc.uchile.cl/' => 1
}
}
};