From aec43c7830a63c5cc82c699f4490862af0d91958 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 5 Jun 2010 16:31:31 +0000 Subject: various changes: - install-tl: try to add /systems/texlive/tlnet if initial download does not succeed - TLDownload errorcount/enable/disable support (used in install-tl) - TLUtils: check for TLDownload enabled status - TLPDB: remove warning about unsuccessfull download of .tlpdb, it is now in tlmgr (where it was already) and install-tl. git-svn-id: svn://tug.org/texlive/trunk@18756 c570f23f-e606-0410-a88d-b1316a301751 --- Master/install-tl | 37 +++++++++++++++- Master/texmf/scripts/texlive/tlmgr.pl | 2 +- Master/tlpkg/TeXLive/TLDownload.pm | 79 +++++++++++++++++++++++++++++++++++ Master/tlpkg/TeXLive/TLPDB.pm | 18 +------- Master/tlpkg/TeXLive/TLUtils.pm | 2 +- 5 files changed, 119 insertions(+), 19 deletions(-) diff --git a/Master/install-tl b/Master/install-tl index d21bc841204..bd24f67ac5b 100755 --- a/Master/install-tl +++ b/Master/install-tl @@ -1227,7 +1227,42 @@ sub load_tlpdb { info("Loading $master/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName\n"); $tlpdb=TeXLive::TLPDB->new(root => "$master"); if (!defined($tlpdb)) { - die "$0: Could not load TeX Live Database from $master, goodbye.\n"; + my $do_die = 1; + # if that failed, and: + # - we are installing from the network + # - the location string does not contain "tlnet" + # then we simply add "/systems/texlive/tlnet" in case someone just + # gave an arbitrary CTAN mirror address without the full path + if ($media eq "NET" && $location !~ m/tlnet/) { + tlwarn("First attempt for net installation failed.\n"); + tlwarn("Location string does not contain \"tlnet\",\n"); + tlwarn("so we retry adding \"/systems/texlive/tlnet\".\n"); + $location .= "/systems/texlive/tlnet"; + $master = $location; + # + # since we change location, we reset the error count of the + # download object + $::tldownload_server->enable if (defined($::tldownload_server)); + # + $tlpdb=TeXLive::TLPDB->new(root => "$master"); + if (!defined($tlpdb)) { + tlwarn("Also that one did not help.\n"); + tlwarn(<option("install_docfiles"); diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index 966a1b6ab9d..8ab3cc79796 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -4260,7 +4260,7 @@ http://tug.org/texlive/doc/install-tl.html (or in the output of install-tl --help). END_NO_INTERNET - # above text duplicated in TLPDB.pm, sorry. + # above text duplicated in install-tl $tlmediasrc = TeXLive::TLMedia->new(-location => $location, -tlpdbfile => $loc_copy_of_remote_tlpdb); diff --git a/Master/tlpkg/TeXLive/TLDownload.pm b/Master/tlpkg/TeXLive/TLDownload.pm index 1977c2023fe..27370da4855 100644 --- a/Master/tlpkg/TeXLive/TLDownload.pm +++ b/Master/tlpkg/TeXLive/TLDownload.pm @@ -20,6 +20,7 @@ sub module_revision { return $_modulerevision; } +my $MAX_ERRORCOUNT = 5; # since Net::HTTP and Net::FTP are shipped by the same packages # we only test for Net::HTTP, if that fails, let us know ;-) @@ -46,16 +47,73 @@ sub new env_proxy => 1, ); $self->{'ua'} = $ua; + $self->{'enabled'} = 1; + $self->{'errorcount'} = 0; bless $self, $class; return $self; } + +sub enabled +{ + my $self = shift; + return $self{'enabled'}; +} +sub disabled +{ + my $self = shift; + return (!$self{'enabled'}); +} +sub enable +{ + my $self = shift; + $self{'enabled'} = 1; + # also reset the error conter + $self->reset_errorcount; +} +sub disable +{ + my $self = shift; + $self{'enabled'} = 0; +} +sub errorcount +{ + my $self = shift; + if (@_) { $self->{'errorcount'} = shift } + return $self->{'errorcount'}; +} +sub incr_errorcount +{ + my $self = shift; + return(++$self->{'errorcount'}); +} +sub decr_errorcount +{ + my $self = shift; + if ($self->errorcount > 0) { + return(--$self->{'errorcount'}); + } else { + return($self->errorcount(0)); + } +} +sub reset_errorcount +{ + my $self = shift; + $self->{'errorcount'} = 0; +} sub get_file { my ($self, $url, $out, $size) = @_; # + # automatically disable if error count is getting too big + if ($self->errorcount > $MAX_ERRORCOUNT) { + $self->disable; + } + # return if disabled + return if $self->disabled; + # my $realout = $out; my ($outfh, $outfn); if ($out eq "|") { @@ -64,6 +122,7 @@ sub get_file } my $response = $self->{'ua'}->get($url, ':content_file' => $realout); if ($response->is_success) { + $self->decr_errorcount; if ($out ne "|") { return 1; } else { @@ -74,6 +133,7 @@ sub get_file } else { tlwarn("TLDownload::get_file: response error:\n"); tlwarn(" " . $response->status_line . "\n"); + $self->incr_errorcount; return; } } @@ -95,6 +155,14 @@ C -- TeX Live Download abstraction module $TeXLive::TLDownload::net_lib_avail my $dl = TeXLive::TLDownload->new(); $dl->get_file($relpath, $output [, $expected_size ]); + if ($dl->enabled) ... + if ($dl->disabled) ... + $dl->enable; + $dl->disable; + $dl->errorcount([n]); + $dl->incr_errorcount; + $dl->decr_errorcount; + $dl->reset_errorcount; =head1 DESCRIPTION @@ -108,6 +176,17 @@ C<$TeXLive::TLDownload::net_lib_avail> accordingly. Please see C for details, in a nut shell one can specify proxies by setting C_proxy> variables. +=head2 Automatic disabling + +The TLDownload module implements some automatic disabling feature. +Every time a download did not succeed an internal counter (errorcount) +is increased, everytime it did succeed it is decreased (to a minimum of 0). +If the number of error goes above the maximal error count, the download +object will be disabled and get_file always returns undef. + +In this cases the download can be reset with the reset_errorcount and +enable function. + =head1 SEE ALSO LWP diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm index 8993105264c..2138e4e4179 100644 --- a/Master/tlpkg/TeXLive/TLPDB.pm +++ b/Master/tlpkg/TeXLive/TLPDB.pm @@ -293,22 +293,8 @@ sub from_file { } } until (!$ret); if (! $found) { - tlwarn("$0: Could not load packages from\n"); - tlwarn(" $path\n"); - if ($path =~ m,/2008(/|$),) { - # have to do this differently in 09/10, since the path will be the same. - tlwarn("TeX Live 2008 is no longer available for updates.\n") - } else { - tlwarn(<enabled) { if (($ret = $::tldownload_server->get_file($url, $dest))) { debug("downloading file via permanent connection succeeded\n"); return $ret; -- cgit v1.2.3