texlive[62016] Master: More resilient installation

commits+preining at tug.org commits+preining at tug.org
Mon Feb 14 07:44:19 CET 2022


Revision: 62016
          http://tug.org/svn/texlive?view=revision&revision=62016
Author:   preining
Date:     2022-02-14 07:44:19 +0100 (Mon, 14 Feb 2022)
Log Message:
-----------
More resilient installation

split installation of packages into two stages: first those which
are absolutely necessary for the installation process to continue
(fmtutil, updmap, tlmgr, ...), and those which are just normal
packages which can be installed afterwards for fixing.

For now, the option --continue needs to be passed.

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

Modified: trunk/Master/install-tl
===================================================================
--- trunk/Master/install-tl	2022-02-14 00:48:33 UTC (rev 62015)
+++ trunk/Master/install-tl	2022-02-14 06:44:19 UTC (rev 62016)
@@ -298,6 +298,8 @@
 my $opt_version = 0;
 my $opt_warn_checksums = 1;
 my $opt_font;
+# we might want to set this to 1 ...? TODO
+my $opt_continue = 0;
 # unusual cases:
 $::opt_select_repository = 0;
 our $opt_in_place = 0;
@@ -317,6 +319,9 @@
 # do not debug translations by default
 $::debug_translation = 0;
 
+# List of packages that failed to install but we continued due to --continue
+@::installation_failed_packages = ();
+
 # before we try to interact with the user, we need to know whether or not
 # install-tl was called from an external gui. This gui will start install-tl
 # with "-from_ext_gui" as its first command-line option.
@@ -361,6 +366,7 @@
 # now the others
 GetOptions(
            "all-options"                 => \$::opt_all_options,
+           "continue"                    => \$opt_continue,
            "custom-bin=s"                => \$opt_custom_bin,
            "debug-translation"           => \$::debug_translation,
            "fancyselector",
@@ -716,6 +722,19 @@
   }
   printf STDOUT "Installed on platform %s at %s\n",
       $vars{'this_platform'}, $vars{'TEXDIR'} if ($opt_gui eq 'extl');
+
+  if (@::installation_failed_packages) {
+    print <<EOF;
+*************** WARNING *************************
+The following list of inessential packages have failed to install
+  @::installation_failed_packages
+You can fix this by running
+  tlmgr update --all --reinstall-forcibly-removed
+to complete the installation. Doing this immediately might not work
+and the command needs to be called later on.
+************************************************
+EOF
+  }
 }
 exit $status;
 
@@ -2107,24 +2126,31 @@
 } # read_profile
 
 sub do_install_packages {
-  # let's install the critical packages first, since they are the most
-  # likely to fail (so let's fail early), and nothing is usable without them.
+  # We split installation of packages into two stages:
+  # - first critical packages, those absolutely necessary for working
+  # - all the other packages, that can be also installed afterwards
+  #   via tlmgr
+  # If something fails in the first group, we stop the installation.
+  # If something fails in the second group:
+  #   - if --continue is given, try to continue install
+  #   - if --continue is not given, terminate (behaviour till now)
+  #
+  my @criticalwhat = ();
   my @what = ();
-  foreach my $package (sort {
-      if ($a =~ /$CriticalPackagesRegexp/) {
-        if ($b =~ /$CriticalPackagesRegexp/) {
-          return $a cmp $b; # both critical
-        } else {
-          return -1; # critical before non-critical
-        }
-      } elsif ($b =~ /$CriticalPackagesRegexp/) {
-        return 1; # critical before non-critical 
-      } else {
-        return $a cmp $b;
-      }
-    } keys %install) {
-    push (@what, $package) if ($install{$package} == 1);
+  my @surely_fail_packages = @CriticalPackagesList;
+  # texlive-scripts are necessary for mktexlsr, updmap, fmtutil, ...
+  # the installation cannot continue without those
+  # TODO for Windows ... what else is needed? luatex?
+  push @surely_fail_packages, "texlive-scripts";
+  for my $package (keys %install) {
+    if (member($package, @surely_fail_packages)) {
+      push @criticalwhat, $package if ($install{$package} == 1);
+    } else {
+      push @what, $package if ($install{$package} == 1);
+    }
   }
+  @criticalwhat = sort @criticalwhat;
+  @what = sort @what;
   # temporary unset the localtlpdb options responsible for
   # running all kind of postactions, since install_packages
   # would call them without the PATH already set up
@@ -2132,9 +2158,15 @@
   $localtlpdb->option ("desktop_integration", "0");
   $localtlpdb->option ("file_assocs", "0");
   $localtlpdb->option ("post_code", "0");
-  if (!install_packages($tlpdb,$media,$localtlpdb,\@what,
+  if (!install_packages($tlpdb,$media,$localtlpdb,\@criticalwhat,
                         $vars{'tlpdbopt_install_srcfiles'},
-                        $vars{'tlpdbopt_install_docfiles'})) {
+                        $vars{'tlpdbopt_install_docfiles'},
+                        0)
+      ||
+      !install_packages($tlpdb,$media,$localtlpdb,\@what,
+                        $vars{'tlpdbopt_install_srcfiles'},
+                        $vars{'tlpdbopt_install_docfiles'},
+                        $opt_continue)) {
     my $profile_name = "installation.profile";
     create_profile($profile_name);
     tlwarn("Installation failed.\n");

Modified: trunk/Master/tlpkg/TeXLive/TLUtils.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLUtils.pm	2022-02-14 00:48:33 UTC (rev 62015)
+++ trunk/Master/tlpkg/TeXLive/TLUtils.pm	2022-02-14 06:44:19 UTC (rev 62016)
@@ -73,7 +73,7 @@
   TeXLive::TLUtils::create_language_def($tlpdb,$dest,$localconf);
   TeXLive::TLUtils::create_language_lua($tlpdb,$dest,$localconf);
   TeXLive::TLUtils::time_estimate($totalsize, $donesize, $starttime)
-  TeXLive::TLUtils::install_packages($from_tlpdb,$media,$to_tlpdb,$what,$opt_src, $opt_doc)>);
+  TeXLive::TLUtils::install_packages($from_tlpdb,$media,$to_tlpdb,$what,$opt_src, $opt_doc, $continue);
   TeXLive::TLUtils::do_postaction($how, $tlpobj, $do_fileassocs, $do_menu, $do_desktop, $do_script);
   TeXLive::TLUtils::announce_execute_actions($how, @executes, $what);
   TeXLive::TLUtils::add_symlinks($root, $arch, $sys_bin, $sys_man, $sys_info);
@@ -1579,7 +1579,7 @@
 }
 
 
-=item C<install_packages($from_tlpdb, $media, $to_tlpdb, $what, $opt_src, $opt_doc)>
+=item C<install_packages($from_tlpdb, $media, $to_tlpdb, $what, $opt_src, $opt_doc, $continue)>
 
 Installs the list of packages found in C<@$what> (a ref to a list) into
 the TLPDB given by C<$to_tlpdb>. Information on files are taken from
@@ -1588,12 +1588,15 @@
 C<$opt_src> and C<$opt_doc> specify whether srcfiles and docfiles should be
 installed (currently implemented only for installation from uncompressed media).
 
+If C<$continue> is trueish, installation failure of non-critical packages
+will be ignored.
+
 Returns 1 on success and 0 on error.
 
 =cut
 
 sub install_packages {
-  my ($fromtlpdb,$media,$totlpdb,$what,$opt_src,$opt_doc) = @_;
+  my ($fromtlpdb,$media,$totlpdb,$what,$opt_src,$opt_doc, $opt_continue) = @_;
   my $container_src_split = $fromtlpdb->config_src_container;
   my $container_doc_split = $fromtlpdb->config_doc_container;
   my $root = $fromtlpdb->root;
@@ -1670,7 +1673,12 @@
     info("$infostr\n");
     # return false if download failed again
     if (!$fromtlpdb->install_package($package, $totlpdb)) {
-      return 0;
+      if ($opt_continue) {
+        push @::installation_failed_packages, $package;
+        tlwarn("Failed to install $package, but continue anyway!\n");
+      } else {
+        return 0;
+      }
     }
     $donesize += $tlpsizes{$package};
   }



More information about the tex-live-commits mailing list.