texlive[43793] Master: user/sys mode for fmtutil and updmap

commits+preining at tug.org commits+preining at tug.org
Sat Apr 15 02:12:46 CEST 2017


Revision: 43793
          http://tug.org/svn/texlive?view=revision&revision=43793
Author:   preining
Date:     2017-04-15 02:12:46 +0200 (Sat, 15 Apr 2017)
Log Message:
-----------
user/sys mode for fmtutil and updmap

add cmd line options -user
require either -user or -sys
move check/setup function to TLUtils.pm, reuse in both
adjust documentation

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl
    trunk/Master/texmf-dist/scripts/texlive/updmap.pl
    trunk/Master/tlpkg/TeXLive/TLConfig.pm
    trunk/Master/tlpkg/TeXLive/TLUtils.pm

Modified: trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl	2017-04-15 00:07:15 UTC (rev 43792)
+++ trunk/Master/texmf-dist/scripts/texlive/fmtutil.pl	2017-04-15 00:12:46 UTC (rev 43793)
@@ -112,6 +112,7 @@
 
 our @cmdline_options = (  # in same order as help message
   "sys",
+  "user",
   "cnffile=s@", 
   "fmtdir=s",
   "no-engine-subdir",
@@ -151,6 +152,12 @@
     # first generated filename after successful generation to stdout then
     # (and nothing else), since kpathsea can only deal with one.
     $mktexfmtMode = 1;
+
+    # TODO TODO
+    # which mode are we running in?
+    # what happens if root runs mktexfmt?
+    $opts{'user'} = 1;
+
     GetOptions ( "help" => \$opts{'help'}, "version" => \$opts{'version'} )
         or die "Unknown option in mktexfmt command line arguments\n";
     if ($ARGV[0]) {
@@ -198,7 +205,10 @@
   }
   
   # these two functions should go to TLUtils (for use in updmap)
-  check_hidden_sysmode();
+  ($texmfconfig, $texmfvar) = 
+    TeXLive::TLUtils::setup_sys_user_mode($prg, \%opts,
+      $TEXMFCONFIG, $TEXMFSYSCONFIG, $TEXMFVAR, $TEXMFSYSVAR);
+
   determine_config_files("fmtutil.cnf");
   my $changes_config_file = $alldata->{'changes_config'};
   # we do changes always in the used config file with the highest priority
@@ -964,32 +974,6 @@
 # and also be reused in updmap.pl!!!
 
 
-sub check_hidden_sysmode {
-  #
-  # check if we are in *hidden* sys mode, in which case we switch
-  # to sys mode
-  # Nowdays we use -sys switch instead of simply overriding TEXMFVAR
-  # and TEXMFCONFIG
-  # This is used to warn users when they run updmap in usermode the first time.
-  # But it might happen that this script is called via another wrapper that
-  # sets TEXMFCONFIG and TEXMFVAR, and does not pass on the -sys option.
-  # for this case we check whether the SYS and non-SYS variants agree,
-  # and if, then switch to sys mode (with a warning)
-  if (($TEXMFSYSCONFIG eq $TEXMFCONFIG) && ($TEXMFSYSVAR eq $TEXMFVAR)) {
-    if (!$opts{'sys'}) {
-      print_warning("hidden sys mode found, switching to sys mode.\n");
-      $opts{'sys'} = 1;
-    }
-  }
-
-  if ($opts{'sys'}) {
-    # we are running as updmap-sys, make sure that the right tree is used
-    $texmfconfig = $TEXMFSYSCONFIG;
-    $texmfvar    = $TEXMFSYSVAR;
-  }
-}
-
-
 # sets global $alldata->{'changes_config'} to the config file to be
 # changed if requested.
 #
@@ -1264,9 +1248,10 @@
 
 sub help {
   my $usage = <<"EOF";
-Usage: $prg     [OPTION] ... [COMMAND]
-   or: $prg-sys [OPTION] ... [COMMAND]
-   or: mktexfmt FORMAT.fmt|BASE.base|FMTNAME.EXT
+Usage: $prg      [-user|-sys] [OPTION] ... [COMMAND]
+   or: $prg-sys  [OPTION] ... [COMMAND]
+   or: $prg-user [OPTION] ... [COMMAND]
+   or: mktexfmt  FORMAT.fmt|BASE.base|FMTNAME.EXT
 
 Rebuild and manage TeX fmts and Metafont bases, collectively called
 "formats" here. (MetaPost no longer uses the past-equivalent "mems".)
@@ -1285,7 +1270,8 @@
 successfully built, else nonzero.
 
 Options:
-  --sys                   use TEXMFSYS{VAR,CONFIG} instead of TEXMF{VAR,CONFIG}
+  --sys                   use TEXMFSYS{VAR,CONFIG}
+  --user                  use TEXMF{VAR,CONFIG}
   --cnffile FILE          read FILE instead of fmtutil.cnf
                            (can be given multiple times, in which case
                            all the files are used)
@@ -1341,7 +1327,7 @@
   TEXMFLOCAL     \$TEXLIVE/texmf-local/web2c/fmtutil.cnf
   TEXMFDIST      \$TEXLIVE/YYYY/texmf-dist/web2c/fmtutil.cnf
 
-  For fmtutil:
+  For fmtutil-user:
   TEXMFCONFIG    \$HOME/.texliveYYYY/texmf-config/web2c/fmtutil.cnf
   TEXMFVAR       \$HOME/.texliveYYYY/texmf-var/web2c/fmtutil.cnf
   TEXMFHOME      \$HOME/texmf/web2c/fmtutil.cnf
@@ -1409,13 +1395,15 @@
   --no-error-if-no-engine option exists, since luajittex cannot be
   compiled on all platforms.)
 
-fmtutil vs. fmtutil-sys (fmtutil --sys):
+fmtutil-user (fmtutil -user) vs. fmtutil-sys (fmtutil -sys):
 
-  When fmtutil-sys is run or the command line option --sys is used, 
+  When fmtutil-sys is run or the command line option -sys is used, 
   TEXMFSYSCONFIG and TEXMFSYSVAR are used instead of TEXMFCONFIG and 
   TEXMFVAR, respectively.  This is the primary difference between 
-  fmtutil-sys and fmtutil.
+  fmtutil-sys and fmtutil-user.
 
+  See $TeXLive::TLConfig::SYSUSERURL for details.
+
   Other locations may be used if you give them on the command line, or
   these trees don't exist, or you are not using the original TeX Live.
 

Modified: trunk/Master/texmf-dist/scripts/texlive/updmap.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/updmap.pl	2017-04-15 00:07:15 UTC (rev 43792)
+++ trunk/Master/texmf-dist/scripts/texlive/updmap.pl	2017-04-15 00:12:46 UTC (rev 43793)
@@ -73,6 +73,7 @@
 
 my @cmdline_options = (
   "sys",
+  "user",
   "listfiles",
   "cnffile=s@", 
   "copy", 
@@ -172,28 +173,10 @@
     exit (0);
   }
 
-  # check if we are in *hidden* sys mode, in which case we switch
-  # to sys mode
-  # Nowdays we use -sys switch instead of simply overriding TEXMFVAR
-  # and TEXMFCONFIG
-  # This is used to warn users when they run updmap in usermode the first time.
-  # But it might happen that this script is called via another wrapper that
-  # sets TEXMFCONFIG and TEXMFVAR, and does not pass on the -sys option.
-  # for this case we check whether the SYS and non-SYS variants agree,
-  # and if, then switch to sys mode (with a warning)
-  if (($TEXMFSYSCONFIG eq $TEXMFCONFIG) && ($TEXMFSYSVAR eq $TEXMFVAR)) {
-    if (!$opts{'sys'}) {
-      print_warning("hidden sys mode found, switching to sys mode.\n");
-      $opts{'sys'} = 1;
-    }
-  }
+  ($texmfconfig, $texmfvar) = 
+    TeXLive::TLUtils::setup_sys_user_mode($prg, \%opts,
+      $TEXMFCONFIG, $TEXMFSYSCONFIG, $TEXMFVAR, $TEXMFSYSVAR);
 
-  if ($opts{'sys'}) {
-    # we are running as updmap-sys, make sure that the right tree is used
-    $texmfconfig = $TEXMFSYSCONFIG;
-    $texmfvar    = $TEXMFSYSVAR;
-  }
-
   if ($opts{'dvipdfmoutputdir'} && !defined($opts{'dvipdfmxoutputdir'})) {
     $opts{'dvipdfmxoutputdir'} = $opts{'dvipdfmoutputdir'};
     print_warning("Using --dvipdfmoutputdir options for dvipdfmx,"
@@ -1342,15 +1325,17 @@
     print_and_log("
 WARNING: you are switching to updmap's per-user mappings.
 
-You have run updmap (as opposed to updmap-sys) for the first time; this
+You have run updmap-user (as opposed to updmap-sys) for the first time; this
 has created configuration files which are local to your personal account.
 
 Any changes in system map files will *not* be automatically reflected in
 your files; furthermore, running updmap-sys will no longer have any
-effect for you.  As a consequence, you have to rerun updmap yourself
+effect for you.  As a consequence, you have to rerun updmap-user yourself
 after any change in the system directories; for example, if a new font
 package is added.
 
+See $TeXLive::TLConfig::SYSUSERURL for details.
+
 If you want to undo this, remove the files mentioned above.
 
 (Run $prg --help for full documentation of updmap.)
@@ -2240,8 +2225,9 @@
 
 sub help {
   my $usage = <<"EOF";
-Usage: $prg     [OPTION] ... [COMMAND]
-   or: $prg-sys [OPTION] ... [COMMAND]
+Usage: $prg [-user|-sys] [OPTION] ... [COMMAND]
+   or: $prg-user [OPTION] ... [COMMAND]
+   or: $prg-sys  [OPTION] ... [COMMAND]
 
 Update the default font map files used by pdftex (pdftex.map), dvips
 (psfonts.map), and dvipdfm(x), and optionally pxdvi, as determined by
@@ -2252,12 +2238,15 @@
 should be used as bitmaps and which as outlines, and to determine which
 font files are included, typically subsetted, in the PDF or PostScript output.
 
-updmap-sys is intended to affect the system-wide configuration, while
-updmap affects personal configuration files only, overriding the system
-files.  As a consequence, once updmap has been run, even a single time,
+updmap-sys (or updmap -sys) is intended to affect the system-wide 
+configuration, while updmap-user (or updmap -user) affects personal
+configuration files only, overriding the system files.  
+As a consequence, once updmap-user has been run, even a single time,
 running updmap-sys no longer has any effect.  (updmap-sys issues a
 warning in this situation.)
 
+See $TeXLive::TLConfig::SYSUSERURL for details.
+
 By default, the TeX filename database (ls-R) is also updated.
 
 The updmap system is regrettably complicated, for both inherent and
@@ -2289,6 +2278,7 @@
   --nomkmap                 do not recreate map files
   --nohash                  do not run texhash
   --sys                     affect system-wide files (equivalent to updmap-sys)
+  --user                    affect personal files (equivalent to updmap-user)
   -n, --dry-run             only show the configuration, no output
   --quiet, --silent         reduce verbosity
 
@@ -2323,7 +2313,7 @@
   only and are not like other map files.  dvipdfmx reads pdftex.map for
   the map entries for non-Kanji fonts.
   
-  If no option is given, so the invocation is just "updmap" or
+  If no option is given, so the invocation is just "updmap-user" or
   "updmap-sys", these output files are always recreated.
 
   Otherwise, if an option such as --enable or --disable is given, the
@@ -2402,7 +2392,7 @@
   TEXMFLOCAL     \$TEXLIVE/texmf-local/web2c/updmap.cfg
   TEXMFDIST      \$TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg
 
-  For updmap:
+  For updmap-user:
   TEXMFCONFIG    \$HOME/.texliveYYYY/texmf-config/web2c/updmap.cfg
   TEXMFVAR       \$HOME/.texliveYYYY/texmf-var/web2c/updmap.cfg
   TEXMFHOME      \$HOME/texmf/web2c/updmap.cfg
@@ -2484,11 +2474,11 @@
   (again separated by tab) containing '(not available)' for those
   map files that cannot be found.
  
-updmap vs. updmap-sys:
+updmap-user vs. updmap-sys:
 
   When updmap-sys is run, TEXMFSYSCONFIG and TEXMFSYSVAR are used
   instead of TEXMFCONFIG and TEXMFVAR, respectively.  This is the
-  primary difference between updmap-sys and updmap.
+  primary difference between updmap-sys and updmap-user.
 
   Other locations may be used if you give them on the command line, or
   these trees don't exist, or you are not using the original TeX Live.

Modified: trunk/Master/tlpkg/TeXLive/TLConfig.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLConfig.pm	2017-04-15 00:07:15 UTC (rev 43792)
+++ trunk/Master/tlpkg/TeXLive/TLConfig.pm	2017-04-15 00:12:46 UTC (rev 43793)
@@ -46,6 +46,7 @@
     $ChecksumLength
     $ChecksumProgram
     $ChecksumExtension
+    $SYSUSERURL
   );
   @EXPORT = @EXPORT_OK;
 }
@@ -218,6 +219,9 @@
 # The extension of the checksum file
 $ChecksumExtension = "sha512";
 
+#
+our $SYSUSERURL = 'http://tug.org/texlive/sys-user-scripts.html';
+
 1;
 
 

@@ -301,6 +305,10 @@
 The string that replaces the C<RelocTree> in the tlpdb if a package is
 relocated, defaults to C<RELOC>".
 
+=item C<$TeXLive::TLConfig::SYSUSERURL>
+
+URL pointing to explanations concerning -sys and -user mode.
+
 =back
 
 =head1 SEE ALSO

Modified: trunk/Master/tlpkg/TeXLive/TLUtils.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLUtils.pm	2017-04-15 00:07:15 UTC (rev 43792)
+++ trunk/Master/tlpkg/TeXLive/TLUtils.pm	2017-04-15 00:12:46 UTC (rev 43793)
@@ -97,6 +97,7 @@
   TeXLive::TLUtils::report_tlpdb_differences(\%ret);
   TeXLive::TLUtils::tlnet_disabled_packages($root);
   TeXLive::TLUtils::mktexupd();
+  TeXLive::TLUtils::setup_sys_user_mode($optsref,$tmfc, $tmfsc, $tmfv, $tmfsv);
 
 =head1 DESCRIPTION
 
@@ -180,6 +181,7 @@
     &report_tlpdb_differences
     &setup_persistent_downloads
     &mktexupd
+    &setup_sys_user_mode
     &nulldev
     &get_full_line
     &sort_archs
@@ -3980,6 +3982,56 @@
   return $hash;
 }
 
+
+=item C<check_sys_user_mode($user,$sys,$tmfc, $tmfsc, $tmfv, $tmfsv)>
+
+=cut
+
+sub setup_sys_user_mode {
+  my ($prg, $optsref, $TEXMFCONFIG, $TEXMFSYSCONFIG, 
+      $TEXMFVAR, $TEXMFSYSVAR) = @_;
+  
+  if ($optsref->{'user'} && $optsref->{'sys'}) {
+    print STDERR "$prg [ERROR]: only one of -user and -sys can be used.\n";
+    exit(1);
+  }
+
+  # check if we are in *hidden* sys mode, in which case we switch
+  # to sys mode
+  # Nowdays we use -sys switch instead of simply overriding TEXMFVAR
+  # and TEXMFCONFIG
+  # This is used to warn users when they run updmap in usermode the first time.
+  # But it might happen that this script is called via another wrapper that
+  # sets TEXMFCONFIG and TEXMFVAR, and does not pass on the -sys option.
+  # for this case we check whether the SYS and non-SYS variants agree,
+  # and if, then switch to sys mode (with a warning)
+  if (($TEXMFSYSCONFIG eq $TEXMFCONFIG) && ($TEXMFSYSVAR eq $TEXMFVAR)) {
+    if ($optsref->{'user'}) {
+      print STDERR "$prg [ERROR]: -user mode but path setup is -sys type, bailing out.\n";
+      exit(1);
+    }
+    if (!$optsref->{'sys'}) {
+      print STDERR "$prg [WARNING]: hidden sys mode found, switching to sys mode.\n" if (!$optsref->{'quiet'});
+      $optsref->{'sys'} = 1;
+    }
+  }
+
+  my ($texmfconfig, $texmfvar);
+  if ($optsref->{'sys'}) {
+    # we are running as updmap-sys, make sure that the right tree is used
+    $texmfconfig = $TEXMFSYSCONFIG;
+    $texmfvar    = $TEXMFSYSVAR;
+  } elsif ($optsref->{'user'}) {
+    $texmfconfig = $TEXMFCONFIG;
+    $texmfvar    = $TEXMFVAR;
+  } else {
+    print STDERR "$prg [ERROR]: Either -user or -sys mode is required.\n" .
+      "See $TeXLive::TLConfig::SYSUSERURL for details!\n";
+    exit(1);
+  }
+  return ($texmfconfig, $texmfvar);
+}
+
 =back
 =cut
 1;



More information about the tex-live-commits mailing list