diff options
author | Norbert Preining <norbert@preining.info> | 2021-05-02 03:03:15 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-05-02 03:03:15 +0000 |
commit | db2a2e7b5c4ca1335618a0b5f5c574229bf459f6 (patch) | |
tree | d0f4c73e3a871ce1ff86e9e94ac3bcca055bf6e5 /systems/texlive/tlnet/tlpkg/TeXLive | |
parent | 33ca54806c387d16002fc16e31418d3a28c2dd63 (diff) |
CTAN sync 202105020303
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/TeXLive')
-rw-r--r-- | systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm | 6 | ||||
-rw-r--r-- | systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm | 66 |
2 files changed, 58 insertions, 14 deletions
diff --git a/systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm b/systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm index 4f73cb75f0..4a0fb53bfb 100644 --- a/systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm +++ b/systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm @@ -1,6 +1,6 @@ -# $Id: TLCrypto.pm 58709 2021-04-03 12:05:04Z preining $ +# $Id: TLCrypto.pm 59044 2021-05-01 22:05:56Z karl $ # TeXLive::TLCrypto.pm - handle checksums and signatures. -# Copyright 2016-2020 Norbert Preining +# Copyright 2016-2021 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. @@ -12,7 +12,7 @@ use TeXLive::TLConfig; use TeXLive::TLUtils qw(debug ddebug win32 which platform conv_to_w32_path tlwarn tldie); -my $svnrev = '$Revision: 58709 $'; +my $svnrev = '$Revision: 59044 $'; my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown"; sub module_revision { return $_modulerevision; } diff --git a/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm b/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm index 384e6d9a32..8b437b1b0b 100644 --- a/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm +++ b/systems/texlive/tlnet/tlpkg/TeXLive/TLUtils.pm @@ -1,4 +1,4 @@ -# $Id: TLUtils.pm 58961 2021-04-22 00:55:07Z preining $ +# $Id: TLUtils.pm 59044 2021-05-01 22:05:56Z karl $ # TeXLive::TLUtils.pm - the inevitable utilities for TeX Live. # Copyright 2007-2021 Norbert Preining, Reinhard Kotucha # This file is licensed under the GNU General Public License version 2 @@ -6,7 +6,7 @@ package TeXLive::TLUtils; -my $svnrev = '$Revision: 58961 $'; +my $svnrev = '$Revision: 59044 $'; my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown"; sub module_revision { return $_modulerevision; } @@ -2910,7 +2910,7 @@ Return C</dev/null> on Unix and C<nul> on Windows. =cut sub nulldev { - return (&win32)? 'nul' : '/dev/null'; + return (&win32()) ? 'nul' : '/dev/null'; } =item C<get_full_line ($fh)> @@ -3913,26 +3913,68 @@ 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. +Use C<curl> if it is listed as a C<working_downloader>, else C<wget>, +else give up. We can't support arbitrary downloaders here, as we do for +regular package downloads, since certain options have to be set and the +output has to be parsed. + +We try invoking the program three times (hardwired). =cut sub query_ctan_mirror { + my @working_downloaders = @{$::progs{'working_downloaders'}}; + ddebug("query_ctan_mirror: working_downloaders: @working_downloaders\n"); + if (TeXLive::TLUtils::member("curl", @working_downloaders)) { + return query_ctan_mirror_curl(); + } elsif (TeXLive::TLUtils::member("wget", @working_downloaders)) { + return query_ctan_mirror_wget(); + } else { + return; + } +} + +# curl will follow the redirect chain for us. +# +sub query_ctan_mirror_curl { + my $max_trial = 3; + for (my $i = 1; $i <= $max_trial; $i++) { + # -L -> follow redirects + # -s -> silent + # -w -> what to output after completion + my $cmd = "$::progs{'curl'} -Ls " + . "-o " . nulldev() . " " + . "-w '%{url_effective}' " + . "--connect-timeout $NetworkTimeout " + . "--max-time $NetworkTimeout " + . $TeXLiveServerURL; + ddebug("query_ctan_mirror_curl: cmd: $cmd\n"); + my $url = `$cmd`; + if (length $url) { + # remove trailing slashes + $url =~ s,/*$,,; + ddebug("query_ctan_mirror_curl: returning url: $url\n"); + return $url; + } + sleep(1); + } + return; +} + +sub query_ctan_mirror_wget { my $wget = $::progs{'wget'}; if (!defined ($wget)) { - tlwarn("query_ctan_mirror: Programs not set up, trying wget\n"); + tlwarn("query_ctan_mirror_wget: Programs not set up, trying wget\n"); $wget = "wget"; } # we need the verbose output, so no -q. # do not reduce retries here, but timeout still seems desirable. my $mirror = $TeXLiveServerURL; - my $cmd = "$wget $mirror --timeout=$NetworkTimeout -O " - . (win32() ? "nul" : "/dev/null") . " 2>&1"; + my $cmd = "$wget $mirror --timeout=$NetworkTimeout " + . "-O " . nulldev() . " 2>&1"; + ddebug("query_ctan_mirror_wget: cmd is $cmd\n"); - # # since we are reading the output of wget to find a mirror # we have to make sure that the locale is unset my $saved_lcall; @@ -3950,6 +3992,7 @@ sub query_ctan_mirror { foreach (@out) { if (m/^Location: (\S*)\s*.*$/) { (my $mhost = $1) =~ s,/*$,,; # remove trailing slashes since we add it + ddebug("query_ctan_mirror_wget: returning url: $mhost\n"); return $mhost; } } @@ -4013,9 +4056,10 @@ sub check_on_working_mirror { sub give_ctan_mirror_base { # only one backbone has existed for a while (2018). - my @backbone = qw!http://www.ctan.org/tex-archive!; + my @backbone = qw!https://www.ctan.org/tex-archive!; # start by selecting a mirror and test its operationality + ddebug("give_ctan_mirror_base: calling query_ctan_mirror\n"); my $mirror = query_ctan_mirror(); if (!defined($mirror)) { # three times calling mirror.ctan.org did not give anything useful, |