diff options
author | Karl Berry <karl@freefriends.org> | 2010-05-26 00:42:10 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-05-26 00:42:10 +0000 |
commit | 5dcb9e985b81b0d874de7ac08a4c659ab66d6f8e (patch) | |
tree | 6108899d6dce88217f87f86e1c54c4fc67fef480 /Master/tlpkg/TeXLive | |
parent | 105b9323011f96263aa658dab3bbd1b472025359 (diff) |
doc tweaks
git-svn-id: svn://tug.org/texlive/trunk@18498 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive')
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index b2a8108cce2..812f00ee7ce 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -102,7 +102,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure BEGIN { use Exporter (); - use vars qw( @ISA @EXPORT_OK @EXPORT); + use vars qw(@ISA @EXPORT_OK @EXPORT); @ISA = qw(Exporter); @EXPORT_OK = qw( &platform @@ -3084,35 +3084,24 @@ sub setup_persistent_downloads return 0; } -=item C<give_ctan_mirror()> - -=item C<give_ctan_mirror_base()> - -Return the specific mirror chosen from the generic CTAN auto-redirecting -default (specified in L<$TLConfig::TexLiveServerURL>) if possible, else -the default url again. - -By default these functions only return http mirrors. If after several -trials of contacting mirror.ctan.org still no http mirror is found, -one of the three backbone nodes are choosen by chance. + +=item C<query_ctan_mirror()> -If ftp mirrors should be allowed pass in C<'-allow-ftp' => 1> as arguments. +Return a particular mirror given by the generic CTAN auto-redirecting +default (specified in L<$TLConfig::TexLiveServerURL>) if we get a +response, else the empty string. Neither C<TL_DOWNLOAD_PROGRAM> nor <TL_DOWNLOAD_ARGS> is honored (see L<download_file>), since certain options have to be set to do the job and the program has to be C<wget> since we parse the output. -The B<_base> variant returns the mirror without any TeX Live specific -location added while the other variant gives the location of the -TeX Live net distribution on the respective mirror. - =cut sub query_ctan_mirror { my $wget = $::progs{'wget'}; if (!defined ($wget)) { - tlwarn ("give_ctan_mirror: Programs not set up, trying wget\n"); + tlwarn("query_ctan_mirror: Programs not set up, trying wget\n"); $wget = "wget"; } @@ -3121,13 +3110,12 @@ sub query_ctan_mirror my $mirror = $TeXLiveServerURL; my $cmd = "$wget $mirror --timeout=60 -O " . (win32() ? "nul" : "/dev/null") . " 2>&1"; - # - # we try 3 times to get a mirror from mirror.ctan.org in case it is - # not working + + # we try 3 times to get a mirror from mirror.ctan.org in case we have + # bad luck with what gets returned. my $max_trial = 3; - my $i = 1; my $mhost; - while ($i <= 3) { + for (my $i = 1; $i <= $max_trial; $i++) { my @out = `$cmd`; # analyze the output for the mirror actually selected. foreach (@out) { @@ -3136,28 +3124,33 @@ sub query_ctan_mirror return $mhost; } } - $i++; sleep(1); } + # we are still here, so three times we didn't get a mirror, give up # and return undefined return; } -# check if the mirror is working +=item C<check_on_working_mirror($mirror)> + +Check if MIRROR is functional. + +=cut + sub check_on_working_mirror { my $mirror = shift; my $wget = $::progs{'wget'}; if (!defined ($wget)) { - tlwarn ("give_ctan_mirror: Programs not set up, trying wget\n"); + tlwarn ("check_on_working_mirror: Programs not set up, trying wget\n"); $wget = "wget"; } # # the test is currently not completely correct, because we do not - # use the LWP if it is set up for it, but I am currently to lazy - # to program it + # use the LWP if it is set up for it, but I am currently too lazy + # to program it, # so try wget and only check for the return value # please KEEP the / after $mirror, some ftp mirrors do give back # an error if the / is missing after ../CTAN/ @@ -3169,19 +3162,21 @@ sub check_on_working_mirror return ($ret ? 0 : 1); } +=item C<give_ctan_mirror_base()> + + 1. get a mirror (retries 3 times to contact mirror.ctan.org) + - if no mirror found, use one of the backbone servers + - if it is an http server return it (no test is done) + - if it is a ftp server, continue + 2. if the ftp mirror is good, return it + 3. if the ftp mirror is bad, search for http mirror (5 times) + 4. if http mirror is found, return it (again, no test,) + 5. if no http mirror is found, return one of the backbone servers + +=cut + sub give_ctan_mirror_base { - # - # operation: - # 1. get a mirror (this retries 3 times to contact mirror.ctan.org) - # - if no mirror has been given, use one of the backbone servers - # - if it is an http server return it (no test!) - # - if it is a ftp server, continue below - # 2. if the ftp mirror is good, return it - # 3. if the ftp mirror is bad, search for http mirror (5 times) - # 4. if http mirror is found, return it (no test!) - # 5. if no http mirror is found return one of the backbone servers - my @backbone = qw!http://www.ctan.org/tex-archive http://www.tex.ac.uk/tex-archive http://dante.ctan.org/tex-archive!; @@ -3195,29 +3190,30 @@ sub give_ctan_mirror_base return $backbone[int(rand($#backbone + 1))]; } - if ($mirror =~ m!^http://!) { + if ($mirror =~ m!^http://!) { # if http mirror, assume good and return. return $mirror; } # we are still here, so we got a ftp mirror from mirror.ctan.org if (check_on_working_mirror($mirror)) { - return $mirror; + return $mirror; # ftp mirror is working, return. } - # we are still here, so the ftp mirror failed, retry to find an http one + + # we are still here, so the ftp mirror failed, retry and hope for http. + # theory is that if one ftp fails, probably all ftp is broken. my $max_mirror_trial = 5; - my $try = 1; - while ($try <= $max_mirror_trial) { + for (my $try = 1; $try <= $max_mirror_trial; $try++) { my $m = query_ctan_mirror(); debug("querying mirror, got " . (defined($m) ? $m : "(nothing)") . "\n"); if (defined($m) && $m =~ m!^http://!) { - return $m; + return $m; # got http this time, assume ok. } - # sleep Nsecs to make mirror happy, but only if we are not ready to return - $try++; - sleep(1) if ($try <= $max_mirror_trial); + # sleep to make mirror happy, but only if we are not ready to return + sleep(1) if $try < $max_mirror_trial; } + # 5 times contacting the mirror service did not return a http server, - # use one of the backbone servers + # use one of the backbone servers. debug("no mirror found ... randomly selecting backbone\n"); return $backbone[int(rand($#backbone + 1))]; } |