texlive[43829] Master/install-tl: scheme/collection computation fix

commits+preining at tug.org commits+preining at tug.org
Sun Apr 16 04:13:52 CEST 2017


Revision: 43829
          http://tug.org/svn/texlive?view=revision&revision=43829
Author:   preining
Date:     2017-04-16 04:13:52 +0200 (Sun, 16 Apr 2017)
Log Message:
-----------
scheme/collection computation fix when profile is used for seeding

Modified Paths:
--------------
    trunk/Master/install-tl

Modified: trunk/Master/install-tl
===================================================================
--- trunk/Master/install-tl	2017-04-16 02:13:45 UTC (rev 43828)
+++ trunk/Master/install-tl	2017-04-16 02:13:52 UTC (rev 43829)
@@ -202,6 +202,7 @@
 # if we find a file installation.profile we ask the user whether we should
 # continue with the installation
 # note, we are in the installer directory.
+my %profiledata;
 if (-r "installation.profile") {
   my $pwd = Cwd::getcwd();
   print "ABORTED TL INSTALLATION FOUND: installation.profile (in $pwd)\n";
@@ -1623,38 +1624,49 @@
       if $do_die;
   }
   # set the defaults to what is specified in the tlpdb
-  $vars{'option_install_docfiles'} = $tlpdb->option("install_docfiles");
-  $vars{'option_install_srcfiles'} = $tlpdb->option("install_srcfiles");
-  $vars{'option_create_formats'} = $tlpdb->option("create_formats");
-  $vars{'option_autobackup'} = $tlpdb->option("autobackup");
-  $vars{'option_backupdir'} = $tlpdb->option("backupdir");
-  $vars{'instopt_letter'} = defined($tlpdb->option("paper"))
-    && ($tlpdb->option("paper") eq "letter" ? 1 : 0);
-  # below, we really mean (start) menu integration.
-  # 2016: always menu shortcuts, never desktop shortcuts, whatever the setting
-  # 2017: new option value 2: launcher instead of menu.
-  # in portable case, shortcuts sanitized away elsewhere
-  $vars{'option_desktop_integration'} = $tlpdb->option("desktop_integration");
-  $vars{'option_desktop_integration'} = 1 if win32();
-  $vars{'option_w32_multi_user'} = $tlpdb->option("w32_multi_user");
-  # we have to make sure that this option is set to 0 in case
-  # that a non-admin is running the installations program
-  $vars{'option_w32_multi_user'} = 0 if (win32() && !admin());
-  $vars{'option_file_assocs'} = $tlpdb->option("file_assocs");
-  $vars{'option_post_code'} = $tlpdb->option("post_code");
-  $vars{'option_sys_bin'} = $tlpdb->option("sys_bin");
-  $vars{'option_sys_man'} = $tlpdb->option("sys_man");
-  $vars{'option_sys_info'} = $tlpdb->option("sys_info");
+  # since we might have loaded values via a -profile-seed,
+  # make sure that we don't overwrite default values
+  for my $o (keys %TeXLive::TLConfig::TLPDBOptions) {
+    $vars{"option_$o"} = $tlpdb->option($o)
+      if (!defined($profiledata{"option_$o"}));
+  }
+  if (win32()) {
+    # below, we really mean (start) menu integration.
+    # 2016: always menu shortcuts, never desktop shortcuts, whatever the setting
+    # 2017: new option value 2: launcher instead of menu.
+    # in portable case, shortcuts sanitized away elsewhere
+    $vars{'option_desktop_integration'} = 1;
+    # we have to make sure that this option is set to 0 in case
+    # that a non-admin is running the installations program
+    $vars{'option_w32_multi_user'} = 0 if (!admin());
+  }
 
+  # select scheme: either $vars{'selected_scheme'} or $default_scheme
   # check that the default scheme is actually present, otherwise switch to
   # scheme-minimal
-  if (!defined($tlpdb->get_package($default_scheme))) {
+  my $selscheme =
+    (defined($vars{'selected_scheme'}) ? $vars{'selected_scheme'} : $default_scheme);
+  if (!defined($tlpdb->get_package($selscheme))) {
     if (!defined($tlpdb->get_package("scheme-minimal"))) {
-      die("Aborting, cannot find either $default_scheme or scheme_minimal");
+      die("Aborting, cannot find either $selscheme or scheme_minimal");
     }
     $default_scheme = "scheme-minimal";
     $vars{'selected_scheme'} = $default_scheme;
   }
+  # make sure that we update %vars for collection_* if only selected_scheme
+  # is there, but no collection information
+  my $found_collection = 0;
+  for my $k (keys(%vars)) {
+    if ($k =~ m/^collection-/) {
+      $found_collection = 1;
+      last;
+    }
+  }
+  if (!$found_collection) {
+    for my $p ($tlpdb->get_package($vars{'selected_scheme'})->depends) {
+      $vars{$p} = 1 if ($p =~ m/^collection-/);
+    }
+  }
   return 1;
 } # load_tlpdb
 
@@ -1662,21 +1674,26 @@
   foreach my $pkg ($tlpdb->list_packages) {
     my $tlpobj = $tlpdb->{'tlps'}{$pkg};
     if ($tlpobj->category eq "Collection") {
-      $vars{"$pkg"}=0;
+      $vars{"$pkg"} = 0 if (!defined($vars{$pkg}));
       ++$vars{'n_collections_available'};
       push (@collections_std, $pkg);
     }
   }
-  my $scheme_tlpobj = $tlpdb->get_package($default_scheme);
+  my $selscheme = ($vars{'selected_scheme'} || $default_scheme);
+  my $scheme_tlpobj = $tlpdb->get_package($selscheme);
   if (defined ($scheme_tlpobj)) {
     $vars{'n_collections_selected'}=0;
     foreach my $dependent ($scheme_tlpobj->depends) {
       if ($dependent=~/^(collection-.*)/) {
         $vars{"$1"}=1;
-        ++$vars{'n_collections_selected'};
       }
     }
   }
+  for my $c (keys(%vars)) {
+    if ($c =~ m/^collection-/ && $vars{$c}) {
+      ++$vars{'n_collections_selected'};
+    }
+  }
   if ($vars{"binary_win32"}) {
     $vars{"collection-wintools"} = 1;
     ++$vars{'n_collections_selected'};
@@ -1762,6 +1779,8 @@
   foreach my $key (sort keys %vars) {
     print $fh "$key $vars{$key}\n"
         if $save_cols and $key=~/^collection/ and $vars{$key}==1;
+    # we don't save option_location
+    next if ($key eq "option_location");
     print $fh "$key $vars{$key}\n" if $key =~ /^option_/;
     print $fh "$key $vars{$key}\n" if $key =~ /^instopt_/;
     print $fh "$key $vars{$key}\n" if defined($path_keys{$key});
@@ -1777,6 +1796,9 @@
   my %opts = @_;
   open PROFILE, "<$profilepath"
     or die "$0: Cannot open profile $profilepath for reading.\n";
+  # %pro is used to see whether there are non-recognized keys,
+  # while %profiledata is used to make sure that the values
+  # from the tlpdb do not overwrite -seed-profile values.
   my %pro;
   while (<PROFILE>) {
     chomp;
@@ -1784,6 +1806,7 @@
     next if m/^[[:space:]]*#/; # skip comment lines
     my ($k,$v) = split (" ", $_, 2); # value might have spaces
     $pro{$k} = $v;
+    $profiledata{$k} = $v;
   }
   foreach (keys %vars) {
     # clear out collections from var, just to be sure
@@ -1801,6 +1824,9 @@
     if (m/^option_/) {
       my $o = $_;
       $o =~ s/^option_//;
+      # we do not support setting the location in the profile
+      # could be done, but might be tricky ..
+      next if ($o eq 'location');
       if (defined($TeXLive::TLConfig::TLPDBOptions{$o})) {
         $vars{$_} = $pro{$_};
         delete($pro{$_});
@@ -1807,17 +1833,14 @@
       }
       next;
     }
-    if (defined($path_keys{$_}) || m/^selected_scheme$/) {
+    if (defined($path_keys{$_}) || 
+        m/^selected_scheme$/    ||
+        m/^binary_/             ||
+        m/^collection-/) {
       $vars{$_} = $pro{$_};
       delete($pro{$_});
       next;
     }
-    if (m/^binary_/) {
-      # we do not do any checking of validity of binaries!
-      $vars{$_} = $pro{$_};
-      delete($pro{$_});
-      next;
-    }
   }
   # if there are still keys in the %pro array, some unknown keys have
   # been written in the profile, bail out
@@ -1836,11 +1859,23 @@
       last;
     }
   }
-  # if at least one collection has been defined return here
-  return if $coldefined;
   # if we are in seed mode, do not try to load remote db as it is 
   # not initialized by now
   return if $opts{'seed'};
+  #
+  # check whether the collections are actually present in case of
+  # changes on the server
+  foreach my $k (keys %pro) {
+    if ($k =~ m/^collection-/) {
+      if (!defined($tlpdb->get_package($k))) {
+        tlwarn("The profile references a non-existing collection: $k\n");
+        tlwarn("Exiting.\n");
+        exit(1);
+      }
+    }
+  }
+  # if at least one collection has been defined return here
+  return if $coldefined;
   # since no collections have been defined in the profile, we
   # set those to be installed on which the scheme depends
   my $scheme=$tlpdb->get_package($vars{'selected_scheme'});
@@ -1911,20 +1946,9 @@
     my $final_loc = ($media eq 'NET' ? $location : abs_path($location));
     $localtlpdb->option ("location", $final_loc);
   }
-  $localtlpdb->option ("autobackup", $vars{'option_autobackup'});
-  $localtlpdb->option ("backupdir", $vars{'option_backupdir'});
-  $localtlpdb->option ("create_formats", $vars{'option_create_formats'} ? "1" : "0");
-  $localtlpdb->option (
-    "desktop_integration", $vars{'option_desktop_integration'});
-  $localtlpdb->option ("file_assocs", $vars{'option_file_assocs'});
-  $localtlpdb->option ("post_code", $vars{'option_post_code'} ? "1" : "0");
-  $localtlpdb->option ("sys_bin", $vars{'option_sys_bin'});
-  $localtlpdb->option ("sys_info", $vars{'option_sys_info'});
-  $localtlpdb->option ("sys_man", $vars{'option_sys_man'});
-  $localtlpdb->option ("install_docfiles", $vars{'option_install_docfiles'} ? "1" : "0");
-  $localtlpdb->option ("install_srcfiles", $vars{'option_install_srcfiles'} ? "1" : "0");
-  $localtlpdb->option (
-    "w32_multi_user", $vars{'option_w32_multi_user'} ? "1" : "0");
+  for my $o (keys %TeXLive::TLConfig::TLPDBOptions) {
+    $localtlpdb->option ($o, $vars{"option_$o"});
+  }
   my @archs;
   foreach (keys %vars) {
     if (m/^binary_(.*)$/ ) {
@@ -2609,8 +2633,9 @@
 interaction, that is, a batch (unattended) install.
 
 A I<profile> file contains all the values needed to perform an
-installation.  After a normal installation has finished, a profile for
-that exact installation is written to the file
+installation.  From the text menu one can select 'P' to save the
+current setup as profile. Furthermore, after a normal installation
+has finished, a profile for that exact installation is written to the file
 DEST/tlpkg/texlive.profile.  That file can be given as the argument to
 C<-profile> to redo the exact same installation on a different system,
 for example.  Alternatively, you can use a custom profile, most easily
@@ -2631,6 +2656,51 @@
 C<TEXMFLOCAL>, C<TEXMFSYSCONFIG>, C<TEXMFSYSVAR>) suffices to install
 the medium scheme with all default options.
 
+The list of allowed keys in a profile is given below. 
+For more detailed explanations on the meaning of the options
+consult the TeX Live installation manual. Values are either
+C<0>, C<1>, or strings.
+
+=over 8
+
+=item B<installer options> (those with prefix C<instopt_>)
+
+C<instopt_portable> (default 0, see C<-portable>), 
+C<instopt_letter> (default 0, selecting letter size instead of a4), 
+C<instopt_adjustrepo> (default 1, adjust remote repository to CTAN
+mirror after installation),
+C<instopt_write18_restricted> (default 1, enable write8 for a restricted
+set of programs),
+C<instopt_path> (default 0 on Unix, 1 on Windows, adjust PATH environment).
+
+=item B<tlpdb options> (those with prefix C<option_>)
+
+The definitive list is give in C<TeXLive::TLConfig.pm> in 
+C<%TeXLive::TLConfig::TLPDBOptions>, together with explanations.
+All items B<but> for C<option_location> can be specified.
+The current list is given below:
+
+C<option_autobackup>, C<option_backupdir>, C<option_create_formats>, 
+C<option_desktop_integration>, C<option_file_assocs>, C<option_install_docfiles>, 
+C<option_install_srcfiles>, C<option_post_code>, 
+C<option_sys_bin>, C<option_sys_info>, C<option_sys_man>, 
+C<option_w32_multi_user>, C<option_generate_updmap>
+
+=item B<path options>
+
+C<TEXDIR>, C<TEXMFHOME>, C<TEXMFCONFIG>, C<TEXMFSYSCONFIG>,
+C<TEXMFVAR>, C<TEXMFSYSVAR>, C<TEXMFLOCAL>
+
+=item B<architecture selection options> (those starting with C<binary_>)
+
+For every supported architecture of TeX Live (directories under
+C<bin/>), the key C<binary_ARCH> can be set. 
+
+Example: C<binary_x86_64-linux>
+
+=back
+
+
 =item B<-q>
 
 Omit normal informational messages.



More information about the tex-live-commits mailing list