From 15b38c41d0da13e4c1b229c405487df790df5601 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 15 Apr 2017 00:12:46 +0000 Subject: 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 git-svn-id: svn://tug.org/texlive/trunk@43793 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLConfig.pm | 8 +++++++ Master/tlpkg/TeXLive/TLUtils.pm | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) (limited to 'Master/tlpkg') diff --git a/Master/tlpkg/TeXLive/TLConfig.pm b/Master/tlpkg/TeXLive/TLConfig.pm index d10e8fa43e4..45835dc1cf7 100644 --- a/Master/tlpkg/TeXLive/TLConfig.pm +++ b/Master/tlpkg/TeXLive/TLConfig.pm @@ -46,6 +46,7 @@ BEGIN { $ChecksumLength $ChecksumProgram $ChecksumExtension + $SYSUSERURL ); @EXPORT = @EXPORT_OK; } @@ -218,6 +219,9 @@ $ChecksumProgram = "sha512sum"; # The extension of the checksum file $ChecksumExtension = "sha512"; +# +our $SYSUSERURL = 'http://tug.org/texlive/sys-user-scripts.html'; + 1; @@ -301,6 +305,10 @@ The texmf-tree name that can be relocated, defaults to C. The string that replaces the C in the tlpdb if a package is relocated, defaults to C". +=item C<$TeXLive::TLConfig::SYSUSERURL> + +URL pointing to explanations concerning -sys and -user mode. + =back =head1 SEE ALSO diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index a5b58a4791d..e645cc07b12 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -97,6 +97,7 @@ C -- utilities used in TeX Live infrastructure 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 @@ BEGIN { &report_tlpdb_differences &setup_persistent_downloads &mktexupd + &setup_sys_user_mode &nulldev &get_full_line &sort_archs @@ -3980,6 +3982,56 @@ sub mktexupd { return $hash; } + +=item C + +=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; -- cgit v1.2.3