From f8d02c879df27f43bc84727605cb381cb8f34973 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 23 Nov 2014 18:10:07 +0000 Subject: sync new fmtutil, etc., to Master git-svn-id: svn://tug.org/texlive/trunk@35648 c570f23f-e606-0410-a88d-b1316a301751 --- Master/install-tl | 2 +- Master/texmf-dist/scripts/texlive/fmtutil-sys.sh | 9 +- Master/texmf-dist/scripts/texlive/fmtutil.sh | 359 +++++++++++------------ Master/texmf-dist/scripts/texlive/updmap-sys.sh | 20 +- 4 files changed, 186 insertions(+), 204 deletions(-) (limited to 'Master') diff --git a/Master/install-tl b/Master/install-tl index 732e1199c01..89933f3f6a3 100755 --- a/Master/install-tl +++ b/Master/install-tl @@ -955,7 +955,7 @@ operations might be disturbed.\n\n"; # luatex/context setup. if (exists($install{"context"}) && $install{"context"} == 1 && !exists $ENV{"TEXLIVE_INSTALL_NO_CONTEXT_CACHE"}) { - info("setting up ConTeXt cache:\n"); + info("setting up ConTeXt cache: "); $errcount += run_postinst_cmd("mtxrun --generate"); } diff --git a/Master/texmf-dist/scripts/texlive/fmtutil-sys.sh b/Master/texmf-dist/scripts/texlive/fmtutil-sys.sh index 4091c8cd6ae..a272b66d007 100755 --- a/Master/texmf-dist/scripts/texlive/fmtutil-sys.sh +++ b/Master/texmf-dist/scripts/texlive/fmtutil-sys.sh @@ -1,9 +1,7 @@ #!/bin/sh -# $Id: fmtutil-sys.sh 34641 2014-07-17 16:38:18Z karl $ -# fmtutil-sys: Thomas Esser, public domain. - -# wrapper script for fmtutil with TEXMFVAR and TEXMFCONFIG set to -# TEXMFSYSVAR / TEXMFSYSCONFIG +# $Id: fmtutil-sys.sh 35626 2014-11-20 19:08:47Z karl $ +# fmtutil-sys - arrange for fmtutil to affect system directories. +# Public domain. Originally written by Thomas Esser. test -f /bin/ksh && test -z "$RUNNING_KSH" \ && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ @@ -17,7 +15,6 @@ unset RUNNING_BSH # hack around a bug in zsh: test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' -export PATH # preferentially use subprograms from our own directory. mydir=`echo "$0" | sed 's,/[^/]*$,,'` diff --git a/Master/texmf-dist/scripts/texlive/fmtutil.sh b/Master/texmf-dist/scripts/texlive/fmtutil.sh index 494635cd3c6..408e42b4d59 100755 --- a/Master/texmf-dist/scripts/texlive/fmtutil.sh +++ b/Master/texmf-dist/scripts/texlive/fmtutil.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: fmtutil.sh 34641 2014-07-17 16:38:18Z karl $ +# $Id: fmtutil.sh 35626 2014-11-20 19:08:47Z karl $ # fmtutil - utility to maintain format files. # Public domain. Originally written by Thomas Esser. # Run with --help for usage. @@ -63,15 +63,15 @@ mydir=`echo "$0" | sed 's,/[^/]*$,,'` mydir=`cd "$mydir" && pwd` PATH="$mydir:$PATH"; export PATH -version='$Id: fmtutil.sh 34641 2014-07-17 16:38:18Z karl $' +version='$Id: fmtutil.sh 35626 2014-11-20 19:08:47Z karl $' progname=fmtutil argv0=$0 cnf=fmtutil.cnf # name of the config file ############################################################################### -# cleanup() +# cleanup ERRCODE, where ERRCODE=1 for failure and 0 for success. # clean up the temp area and exit with proper exit status -############################################################################### +# cleanup() { rc=$1 @@ -79,12 +79,11 @@ cleanup() $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ && { cd / && rm -rf "$tmpdir"; } (exit $rc); exit $rc -} +} ############################################################################### -# help() and version() -# display help (or version) message and exit -############################################################################### +# help() and version() - display help resp. version message and exit 0. +# help() { cat <&2 @@ -254,10 +249,9 @@ abort() } ############################################################################### -# maybe_abort(errmsg) -# print `errmsg' to stderr and -# unless noAbortFlag is set exit with error code 1 -############################################################################### +# maybe_abort(ERRMSG) print ERRMSG to stderr; then, if +# noAbortFlag is set, do nothing; if not set, exit with error code 1. +# maybe_abort() { echo "$progname: $1." >&2 @@ -265,71 +259,82 @@ maybe_abort() } ############################################################################### -# verboseMsg(msg) -# print `msg' to stderr is $verbose is true -############################################################################### +# verboseMsg(MSG) - print MSG to stderr if $verbose is true +# verboseMsg() { $verboseFlag && verbose echo ${1+"$@"} } ############################################################################### -# byebye() -# report any failures and exit the program -############################################################################### -byebye() +# flush_msg_buffers() - Called from byebye() to print accumulated +# error messages. +# +# global variable `flush_msg_buffers_called' is set true to detect +# recursive calls during error/trap processing. If the redirection of +# "cat" fails due to full file system, say, we get an error condition. +# +flush_msg_buffers() { - if $has_warnings; then - { - cat <&2 - fi + if $flush_msg_buffers_called; then return; fi + flush_msg_buffers_called=true if $has_errors; then { cat <&2 - cleanup 1 - else - cleanup 0 fi } ############################################################################### -# init_log_warning() -# reset the list of warning messages -############################################################################### -init_log_warning() +# byebye([RETURNCODE]) - report any failures and exit the program +# +# The argument RETURNCODE is optional. When byebye is called indirectly +# through trap processing, it is passed a RETURNCODE of 1, and the +# program then exits with status 1. +# +# If RETURNCODE is not given, the program exits with status 1 if +# log_failure has been called, and 0 otherwise. +# +# byebye invokes flush_msg_buffers to print the messages accumulated by +# the previous calls to log_failure. Thus, unless byebye is called, +# this flushing does not take place, and the messages are not reported. +# +byebye() { - log_warning_msg= - has_warnings=false + flush_msg_buffers # dump any accumulated output + + # If we are passed an explicit non-zero error code, obey it. + force_error=false + test -n "$1" && test "x$1" != x0 && force_error=true + + if $force_error; then + verboseMsg "$progname: Error(s) found, exiting unsuccessfully." + cleanup 1 + else + verboseMsg "$progname: No errors, exiting successfully." + cleanup 0 + fi } ############################################################################### -# init_log_failure() -# reset the list of failure messages -############################################################################### +# init_log_failure() - reset the list of failure messages +# +# Usage scenario: +# init_log_failure +# ... +# log_failure +# ... +# byebye (will flush the message and exit). +# init_log_failure() { log_failure_msg= @@ -337,27 +342,9 @@ init_log_failure() } ############################################################################### -# log_warning(errmsg) -# report and save warning message `errmsg' -############################################################################### -log_warning() -{ - echo "Warning: $@" >&2 - if test -z "$log_warning_msg"; then - log_warning_msg="$@" - else - OLDIFS=$IFS; IFS= - log_warning_msg="$log_warning_msg -$@" - IFS=$OLDIFS - fi - has_warnings=true -} - -############################################################################### -# log_failure(errmsg) -# report and save failure message `errmsg' -############################################################################### +# log_failure(FAILMSG) - report and save failure message FAILMSG +# and set global variable has_errors to true. +# log_failure() { echo "Error: $@" >&2 @@ -373,28 +360,35 @@ $@" } ############################################################################### -# verbose (cmd) -# execute cmd. Redirect output depending on $mktexfmtMode. -############################################################################### +# verbose(CMD) - execute CMD, redirecting output to stderr if $mktexfmtMode +# is true, to stdout otherwise. +# +# This is because when we are called as mktexfmt, we want to output one +# line and one line only to stdout: the name of the generated fmt file, +# which kpathsea can read and handle. +# verbose() { - $mktexfmtMode && ${1+"$@"} >&2 || ${1+"$@"} + if $mktexfmtMode; then + ${1+"$@"} >&2 + else + ${1+"$@"} + fi } ############################################################################### -# mktexdir(args) -# call mktexdir script, disable all features (to prevent sticky directories) -############################################################################### +# mktexdir(ARGS) - call mktexdir script with ARGS, +# disable all features (to prevent sticky directories) +# mktexdir() -{ +{ initTexmfMain MT_FEATURES=none "$MT_TEXMFMAIN/web2c/mktexdir" "$@" >&2 } ############################################################################### -# tcfmgr(args) -# call tcfmgr script -############################################################################### +# tcfmgr(ARGS) - call tcfmgr script with ARGS. +# tcfmgr() { initTexmfMain @@ -402,9 +396,8 @@ tcfmgr() } ############################################################################### -# mktexupd(args) -# call mktexupd script -############################################################################### +# mktexupd(ARGS) - call mktexupd script with ARGS +# mktexupd() { initTexmfMain @@ -412,10 +405,9 @@ mktexupd() } ############################################################################### -# main() -# parse commandline arguments, initialize variables, -# switch into temp. direcrory, execute desired command -############################################################################### +# main() - parse commandline arguments, initialize variables, +# switch into temp direcrory, execute desired command. +# main() { destdir= # global variable: where do we put the format files? @@ -430,6 +422,10 @@ main() # eradicate double slashes to avoid kpathsea expansion. tmpdir=`echo ${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$ | sed s,//,/,g` + flush_msg_buffers_called=false # avoid recursion in error/trap processing + init_log_failure # must be before setupTmpDir since trap inside calls byebye + setupTmpDir # sets up trap for robust cleanup of tmpdir and more + # mktexfmtMode: if called as mktexfmt, set to true. Will echo the # first generated filename after successful generation to stdout then # (and nothing else), since kpathsea can only deal with one. @@ -532,7 +528,6 @@ main() if test -n "$cfgmaint"; then if test -z "$cfgparam"; then - setupTmpDir co=`tcfmgr --tmp $tmpdir --cmd co --file $cnf` test $? = 0 || cleanup 1 set x $co; shift @@ -599,12 +594,11 @@ main() # due to KPSE_DOT, we don't search the current directory, so include # it explicitly for formats that \write and later on \read TEXINPUTS="$tmpdir:$TEXINPUTS"; export TEXINPUTS - # for formats that load other formats (e.g., jadetex loads latex.fmt), + # for formats that load other formats (e.g., jadetex loads latex.fmt), # add the current directory to TEXFORMATS, too. Currently unnecessary # for MFBASES and MPMEMS. TEXFORMATS="$tmpdir:$TEXFORMATS"; export TEXFORMATS - setupTmpDir cd "$tmpdir" || cleanup 1 # make local paths absolute: @@ -618,10 +612,9 @@ main() esac cache_vars - init_log_failure - init_log_warning + # execute the desired command: - case "$cmd" in + case "$cmd" in all) recreate_all;; missing) @@ -643,7 +636,7 @@ main() # parse_line(config_line) sets global variables: # format: name of the format, e.g. pdflatex # engine: name of the TeX engine, e.g. tex, etex, pdftex -# texargs: flags for initex and name of the ini file (e.g. -mltex frlatex.ini) +# texargs: flags for initex and name of ini file (e.g. -mltex frlatex.ini) # fmtfile: name of the format file (without directory, but with extension) # # Support for building internationalized formats sets: @@ -657,7 +650,7 @@ main() # inside the 4th field in fmtutil.cnf. # # exit code: returns error code if the ini file is not installed -############################################################################### +# parse_line() { case $1 in @@ -697,13 +690,14 @@ parse_line() } ############################################################################### -# find_hyphenfile(format, hyphenation) searches for hyphenation along -# searchpath of format -# exit code: returns error is file is not found -############################################################################### +# find_hyphenfile(FORMAT, HYPHENATION) - search for HYPHENATION +# along search path of FORMAT +# exit code: returns error code if file is not found +# find_hyphenfile() { - format="$1"; hyphenation="`echo $2 | sed 's/,/ /g'`" + format="$1" + hyphenation="`echo $2 | sed 's/,/ /g'`" case $hyphenation in -) ;; *) kpsewhich -progname="$format" -format=tex $hyphenation;; @@ -711,10 +705,9 @@ find_hyphenfile() } ############################################################################### -# find_info_for_name(format) -# Look up the config line for format `format' and call parse_line to set -# global variables. -############################################################################### +# find_info_for_name(FORMAT) - look up config line for FORMAT +# and call parse_line to set global variables. +# find_info_for_name() { format="$1" @@ -726,12 +719,11 @@ find_info_for_name() } ############################################################################### -# run_initex() -# Calls initex. Assumes that global variables are set by parse_line. -############################################################################### +# run_initex() - run initex. +# Assumes that global variables are set by parse_line. +# run_initex() { - # install a pool file and set tcx flag if requested in lang= option: rm -f *.pool poolfile= @@ -794,26 +786,29 @@ run_initex() fulldestdir="$destdir" fi mkdir -p "$fulldestdir" + if test -f "$fmtfile"; then - grep '^! ' $format.log >/dev/null 2>&1 && - log_warning "\`$engine -ini $tcxflag $jobswitch $prgswitch $texargs' possibly failed." + grep '^! ' $format.log >/dev/null 2>&1 && log_failure \ + "\`$engine -ini $tcxflag $jobswitch $prgswitch $texargs' had errors." + + # Definitely avoid user interaction for the following mv/cp commands. + mv "$format.log" "$fulldestdir/$format.log" /dev/null || { (exit 0); return 0; } @@ -1021,9 +1011,8 @@ eof } ############################################################################### -# enablefmt(format) -# enables format in configuration file -############################################################################### +# enablefmt(FORMAT) - enable FORMAT in configuration file +# enablefmt() { grep "^#![ ]*$1[ ]" $cnf_file >/dev/null || { (exit 0); return 0; } @@ -1036,4 +1025,6 @@ eof } main ${1+"$@"} + +# we should not get here cleanup 0 diff --git a/Master/texmf-dist/scripts/texlive/updmap-sys.sh b/Master/texmf-dist/scripts/texlive/updmap-sys.sh index edf3c9d6e74..4daaf9b3257 100755 --- a/Master/texmf-dist/scripts/texlive/updmap-sys.sh +++ b/Master/texmf-dist/scripts/texlive/updmap-sys.sh @@ -1,9 +1,7 @@ #!/bin/sh - -# updmap-sys: Thomas Esser, public domain. - -# wrapper script for updmap with TEXMFVAR and TEXMFCONFIG set to -# TEXMFSYSVAR / TEXMFSYSCONFIG +# $Id: updmap-sys.sh 35626 2014-11-20 19:08:47Z karl $ +# updmap-sys - arrange for updmap to affect system directories. +# Public domain. Originally written by Thomas Esser. test -f /bin/ksh && test -z "$RUNNING_KSH" \ && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ @@ -15,16 +13,12 @@ test -f /bin/bsh && test -z "$RUNNING_BSH" \ && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } unset RUNNING_BSH -export PATH +# preferentially use subprograms from our own directory. +mydir=`echo "$0" | sed 's,/[^/]*$,,'` +mydir=`cd "$mydir" && pwd` +PATH="$mydir:$PATH"; export PATH # hack around a bug in zsh: test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' -# v=`kpsewhich -var-value TEXMFSYSVAR` -# c=`kpsewhich -var-value TEXMFSYSCONFIG` - -# TEXMFVAR="$v" -# TEXMFCONFIG="$c" -# export TEXMFVAR TEXMFCONFIG - exec updmap --sys ${1+"$@"} -- cgit v1.2.3