texlive[53343] Master/tlpkg/TeXLive/TLUtils.pm: Automatically retry

commits+preining at tug.org commits+preining at tug.org
Tue Jan 7 11:55:10 CET 2020


Revision: 53343
          http://tug.org/svn/texlive?view=revision&revision=53343
Author:   preining
Date:     2020-01-07 11:55:10 +0100 (Tue, 07 Jan 2020)
Log Message:
-----------
Automatically retry to download packages again later if failed (by Yusuke Terada)

I often encounter the following error during network installation of TeX Live.

```
TLPDB::_install_package: downloading did not succeed
Installation failed.
```
This occurs irregularly, that is, at which package the installation aborts
varies every time. So, it is probably due to some random network troubles.

Once the error occurs, the entire installation aborts there, and users should
retry from the beginning. So I have tried implementing a workaround in the
installation routine based on Hironobu Yamashita's suggestion. His idea is:

If download of some packages fails, skip them and store them in @packs_again.
After the installation of other packages completed, retry to install the
packages stored in @packs_again.
If it fails again, the installation process is to be aborted this time around.
However, if the errors are due to random network troubles, the probability of
an error occurring twice on the same package should be quite small.
As an experiment, I tried raising network troubles intentionally during network
installation. This workaround seems to work well.

Modified Paths:
--------------
    trunk/Master/tlpkg/TeXLive/TLUtils.pm

Modified: trunk/Master/tlpkg/TeXLive/TLUtils.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLUtils.pm	2020-01-07 00:55:22 UTC (rev 53342)
+++ trunk/Master/tlpkg/TeXLive/TLUtils.pm	2020-01-07 10:55:10 UTC (rev 53343)
@@ -1,6 +1,6 @@
 # $Id$
 # TeXLive::TLUtils.pm - the inevitable utilities for TeX Live.
-# Copyright 2007-2019 Norbert Preining, Reinhard Kotucha
+# Copyright 2007-2020 Norbert Preining, Reinhard Kotucha
 # This file is licensed under the GNU General Public License version 2
 # or any later version.
 
@@ -1520,6 +1520,7 @@
     $totalsize += $tlpsizes{$p};
   }
   my $starttime = time();
+  my @packs_again; # packages that we failed to download and should retry later
   foreach my $package (@packs) {
     my $tlpobj = $tlpobjs{$package};
     my $reloc = $tlpobj->relocated;
@@ -1532,8 +1533,22 @@
     foreach my $h (@::install_packages_hook) {
       &$h($n,$totalnr);
     }
-    # return false if something went wrong
+    # push $package to @packs_again if download failed
     if (!$fromtlpdb->install_package($package, $totlpdb)) {
+      tlwarn("TLUtils::install_packages: Failed to install $package\n"
+             ."Will be retried later.\n");
+      push @packs_again, $package;
+    } else {
+      $donesize += $tlpsizes{$package};
+    }
+  }
+  # try to download packages in @packs_again again
+  foreach my $package (@packs_again) {
+    my $infostr = sprintf("Retrying to install: $package [%dk]",
+                     int($tlpsizes{$package}/1024) + 1);
+    info("$infostr\n");
+    # return false if download failed again
+    if (!$fromtlpdb->install_package($package, $totlpdb)) {
       return 0;
     }
     $donesize += $tlpsizes{$package};



More information about the tex-live-commits mailing list