From 472f1aa97056361710825e4f3de18b0e89f0e985 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 29 Dec 2019 19:18:55 +0000 Subject: move master version of mktexlsr mktexmf mktexpk mktextfm to Master/texmf-dist/scripts/texlive/, with slave copies in Build/source/texk/texlive/linked_scripts/texlive git-svn-id: svn://tug.org/texlive/trunk@53254 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/texlive/README | 32 ++++ Master/texmf-dist/scripts/texlive/mktexlsr | 236 ++++++++++++++++++++++++ Master/texmf-dist/scripts/texlive/mktexmf | 151 +++++++++++++++ Master/texmf-dist/scripts/texlive/mktexpk | 284 +++++++++++++++++++++++++++++ Master/texmf-dist/scripts/texlive/mktextfm | 162 ++++++++++++++++ 5 files changed, 865 insertions(+) create mode 100644 Master/texmf-dist/scripts/texlive/README create mode 100755 Master/texmf-dist/scripts/texlive/mktexlsr create mode 100755 Master/texmf-dist/scripts/texlive/mktexmf create mode 100755 Master/texmf-dist/scripts/texlive/mktexpk create mode 100755 Master/texmf-dist/scripts/texlive/mktextfm (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/scripts/texlive/README b/Master/texmf-dist/scripts/texlive/README new file mode 100644 index 00000000000..cee1d0fe37f --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/README @@ -0,0 +1,32 @@ +$Id$ +Master/texmf-dist/scripts/texlive +(This file is public domain.) + +This directory contains scripts for TeX Live. Unlike everything else +under Master/texmf-dist/scripts (and most of the rest of Master), most +of these scripts are actually maintained here, and not under Build. + +There are slave copies of these Master-maintained scripts in +Build/source/texk/texlive/linked_scripts, just as for the multitude of +scripts updated from CTAN. + +(Perhaps at some point we will move things around to make this true for +all the scripts here, instead of just most. The remainder now are in +Build/source/texk/texlive/tl_scripts.) + +One reason for doing this is so we can have $Id$ expansion, so +svn:keywords is set for the scripts maintained here. When they were +maintained in Build, the --version option and doc of the copies in bin/ +would become a literal "$Id$", because svn->git mirror process does not +preserve $Id$ strings. (Note from Karl: Although many people and +processes hate keyword expansion, I'm afraid that I find it quite +useful, so I don't want to give it up as long as I am working here. Feel +free to change it when I'm gone. :) + +Another reason is that almost all scripts in the bin/*/ directories are +now symlinks into texmf-dist/scripts/, so it's nice for these to follow +suit for consistency and clarity. + +The principal mailing list is http://lists.tug.org/tex-live. + +All of these scripts are free software, mostly public domain. diff --git a/Master/texmf-dist/scripts/texlive/mktexlsr b/Master/texmf-dist/scripts/texlive/mktexlsr new file mode 100755 index 00000000000..bd3eb50d6e4 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/mktexlsr @@ -0,0 +1,236 @@ +#!/bin/sh +# original mktexlsr -- create or rebuild ls-R. +# +# (If you change or delete the word `original' on the previous line, +# installation won't write this script over yours.) +# +# Suitable for calling from cron, as in: +# 0 * * * * cd /your/texmf/root && /usr/local/texlive/bin/mktexlsr +# +# Originally written as `texhash' by Thomas Esser, Okt., 1994. +# Public domain. + +version='$Id$' +progname=`echo $0 | sed 's%.*/%%'` + +usage="Usage: $progname [OPTION]... [DIR]... + +Rebuild ls-R filename databases used by TeX. If one or more arguments +DIRS are given, these are used as the directories in which to build +ls-R. Else all directories in the search path for ls-R files +(\$TEXMFDBS) are used. + +Options: + --dry-run do not actually update anything + --help display this help and exit + --quiet cancel --verbose + --silent same as --quiet + --verbose explain what is being done + --version output version information and exit + +If standard input is a terminal, --verbose is on by default. + +For more information, see the \`Filename database' section of +Kpathsea manual available at http://tug.org/kpathsea. + +Report bugs to: tex-k@tug.org +TeX Live home page: +" + +# The simple PATH-prepending approach we take in other scripts doesn't +# handle DOS/Windows, but we don't use the shell scripts on Windows +# anyway, and does anyone want current TL on DOS or DJGPP? Maybe they +# can maintain their own changes if so. Leaving this code though, since +# it's always been here ... + +# MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use `;' to separate +# directories in path lists whereas Unix uses `:'. Make an exception for +# Cygwin, which pretends to be UNIX. +# Create a variable that holds the right character to be used by the scripts. +DOSISH=no +case `uname -s` in + CYGWIN*|Cygwin*|cygwin*) ;; + *) if test -n "$COMSPEC" || test -n "$ComSpec"; then DOSISH=yes; fi +esac +if test "$DOSISH" = "no"; then SEP=':'; else SEP=';';fi + +# Add the location of the script to the PATH if necessary. This must +# be done before kpsewhich can be called, and thus cannot be put into +# mktex.opt. +dirname=`echo $0 | sed 's%/*[^/][^/]*$%%'` +case $dirname in + "") # Do nothing + ;; + /* | [A-z]:/*) # Absolute name + PATH="$dirname$SEP$PATH" + export PATH ;; + *) # Relative name + PATH="`pwd`/$dirname$SEP$PATH" + export PATH ;; +esac + +if tty -s; then verbose=true; else verbose=false; fi +dry_run=false +trees= + +# initialize treefile by either mktemp or some random name +# code taken from pdfjam and adjusted +{ + treefile=` + (umask 077 && mktemp "${TMPDIR-/tmp}/mktexlsrtrees.XXXXXXXXXX") 2>/dev/null + ` && test -n "$treefile" && test -f "$treefile" +} || { + ## We'll use awk to make random number, for portability + random=`awk 'END { srand(); printf ("%d\n", rand()*1000000); }' /dev/null` + treefile="${TMPDIR-/tmp}/mktexlsrtrees$$.$random" +} || exit $? + +trap 'cd /; rm -f $treefile; test -z "$db_dir_tmp" || rm -rf "$db_dir_tmp"; + exit' 0 1 2 3 7 13 15 + +# A copy of some stuff from mktex.opt, so we can run in the presence of +# terminally damaged ls-R files. +while test $# -gt 0; do + if test "x$1" = x--help || test "x$1" = x-help; then + echo "$usage" + exit 0 + elif test "x$1" = x--version || test "x$1" = x-version; then + echo "`basename $0` $version" + kpsewhich --version + exit 0 + elif test "x$1" = x--verbose || test "x$1" = x-verbose; then + verbose=true + elif test "x$1" = x--dry-run || test "x$1" = x-n; then + dry_run=true + elif test "x$1" = x--quiet || test "x$1" = x--silent \ + || test "x$1" = x-quiet || test "x$1" = x-silent ; then + verbose=false + elif test "x$1" = x--; then + : + elif echo "x$1" | grep '^x-' >/dev/null; then + echo "$progname: unknown option \`$1', try --help if you need it." >&2 + exit 1 + else + if test ! -d "$1"; then + echo "$progname: $1: not a directory, skipping." >&2 + shift + continue + fi + # By saving the argument in a file, we can later get it back while + # supporting spaces in the name. This still doesn't support + # newlines in the directory names, but nobody ever complains about + # that, and it seems much too much trouble to use \0 terminators. + (umask 077 + if echo "$1" >>"$treefile"; then :; else + echo "$progname: $treefile: could not append to arg file, goodbye." >&2 + exit 1 + fi + ) + fi + shift +done + +# mktexupd and mktexlsr make sure they're coordinated via this. A copy +# is found mktex.opt. +ls_R_magic='% ls-R -- filename database for kpathsea; do not change this line.' +# The old string, which should continue to work. +old_ls_R_magic='% ls-R -- maintained by MakeTeXls-R; do not change this line.' + +{ + # Get list of directories from the explicit arguments (now saved in + # $treefile), or $TEXMFDBS if no explicit args. Eliminate duplicates. + saveIFS=$IFS # break only at newline + IFS=' +' + if test -s "$treefile"; then + set x `sort "$treefile" | uniq` + else + set x `kpsewhich --show-path=ls-R | tr : ' +' | sort | uniq` + fi + IFS=$saveIFS + shift +} + +for TEXMFLS_R in "$@"; do + # Prepend cwd if the directory was relative. + case "$TEXMFLS_R" in + "") continue ;; # Strictly speaking, it is an error if this case is taken. + /* | [A-z]:/*) ;; + *) TEXMFLS_R="`pwd`/$TEXMFLS_R" + esac + # Allow for either ls-R and ls-r to exist. But create ls-R if we're + # working from scratch. + if test -f "$TEXMFLS_R/ls-R"; then + db_file="$TEXMFLS_R/ls-R" + elif test -f "$TEXMFLS_R/ls-r"; then + db_file="$TEXMFLS_R/ls-r" + else + db_file="$TEXMFLS_R/ls-R" + fi + # Follow a possible symlink to get the right filesystem. + # The '|| true' construct prevents an sh -e aborting. + db_readlink=`kpsereadlink "$TEXMFLS_R/ls-R" 2>/dev/null` || true + case "$db_readlink" in + "") ;; + /* | [A-z]:/*) db_file="$db_readlink" ;; + *) db_file="$TEXMFLS_R/$db_readlink" + esac + db_dir=`echo "$db_file" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname + + # want to be silent if the directory doesn't exist, since the ls-R + # path ordinarily contains many nonexistent directories. + test -d "$db_dir" || continue + test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; } + + if test ! -f "$db_file"; then + cp /dev/null "$db_file" + # Use same permissions as parent directory, minus x,s, or t bits. + chmod `kpsestat -xst "$db_dir"` "$db_file" + elif test -s "$db_file" \ + && test "x`sed '1s/ $//;1q' \"$db_file\"`" != "x$ls_R_magic" \ + && test "x`sed '1s/ $//;1q' \"$db_file\"`" != "x$old_ls_R_magic"; then + echo "$progname: $db_file: no magic string, skipping..." >&2 + continue + fi + + # Skip if we cannot write the file: + kpseaccess -w "$db_file" || { echo "$progname: $db_file: no write permission, skipping..." >&2; continue; } + + db_dir_tmp="$db_dir/lsR$$.tmp" + (umask 077 && mkdir "$db_dir_tmp" ) \ + || { echo "$progname: $db_dir_tmp: could not create directory, skipping..." >&2; continue; } + db_file_tmp="$db_dir_tmp/lsR$$.tmp" + rm -f "$db_file_tmp" + + $verbose && echo "$progname: Updating $db_file... " + $dry_run && continue + + echo "$ls_R_magic" >"$db_file_tmp" + + # The main task. We put ./: in the output, so top-level files can be + # found via ls-R. Probably irrelevant in practice. The sed command + # inserts the leading ./ for directory names, and removes ., .., and + # version control entries from the list. Also omit contents of any + # the version directories; sed apparently requires that we do that + # operation in a separate invocation. We do not try to support colons + # in directory names. + # + echo "./:" >>"$db_file_tmp" + vc_dirs='\.\(bzr\|git\|hg\|svn\)\|_darcs' + (cd "$TEXMFLS_R" && \ls -LRa 2>/dev/null) \ + | sed -e '/^$/{n;s%^\./%%;s%^%./%;}; /^\.$/d; /^\.\.$/d; /^'$vc_dirs'$/d;' \ + -e '/^[\.\/]*lsR[0-9]*\.tmp:*$/d' \ + | sed -e /$vc_dirs'.*:$/,/^$/d' \ + >>"$db_file_tmp" + + # To be really safe, a loop. + until PERMS=`kpsestat = "$db_file"`; do sleep 1; done + chmod $PERMS "$db_file_tmp" + rm -f "$db_file" + mv "$db_file_tmp" "$db_file" + rm -rf "$db_dir_tmp" +done + +$verbose && echo "$progname: Done." +exit 0 diff --git a/Master/texmf-dist/scripts/texlive/mktexmf b/Master/texmf-dist/scripts/texlive/mktexmf new file mode 100755 index 00000000000..f6b8991e8d1 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/mktexmf @@ -0,0 +1,151 @@ +#!/bin/sh +# original mktexmf -- make a new MF file, because one wasn't found. +# +# (If you change or delete the word `original' on the previous line, +# installation won't write this script over yours.) +# +# Originally written by Thomas Esser. +# Public domain. + +version='$Id$' + +# preferentially use subprograms from our own directory. +mydir=`echo "$0" | sed 's,/[^/]*$,,'` +mydir=`cd "$mydir" && pwd` +PATH="$mydir:$PATH"; export PATH + +usage="Usage: $0 FONT. + +Makes the Metafont source file for FONT, if possible. For example, +\`ecr12' or \`cmr11'. + +Report bugs to: tex-k@tug.org +TeX Live home page: +" + +# Common code for all scripts. +: ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`} +: ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`} +test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt" +if test ! -f "$MT_MKTEX_OPT"; then + echo "$progname: Cannot find mktex.opt; check your installation." >&2 + exit 1 +fi + +. "$MT_MKTEX_OPT" + +( +# See comments in mktexpk. +name="`echo $1 | sed 's%.*/%%; s%\.mf$%%'`" +rootname=`echo "$name" | sed 's/[0-9]*$//'` +pointsize=`echo "$name" | sed "s/^$rootname//"` + +sauterroot=`kpsewhich b-$rootname.mf 2>/dev/null` +if test -n "$sauterroot"; then + rootfile=$sauterroot + rootname=b-$rootname +else + case $name in + # csso12[0-5][0-9] from CJK package; unsupported by mktexmf + csso12[0-5][0-9]) + rootfile=;; + *) + case $rootname in + cs*|lcsss*|icscsc*|icstt*|ilcsss*) + rootfile=`kpsewhich cscode.mf`;; + wn[bcdfirstuv]*|rx[bcdfiorstuvx][bcfhilmostx]|l[abcdhl][bcdfiorstuvx]*) + lhprefix=`echo "$name" | sed 's/^\(..\).*/\1/'` + rootfile=`kpsewhich ${lhprefix}codes.mf 2>/dev/null`;; + *) + rootfile=`kpsewhich $rootname.mf 2>/dev/null`;; + esac;; + esac +fi +{ test -z "$rootfile" || test ! -f "$rootfile"; } && exit 1 + +#if test -z "$MT_MFNAME"; then +OIFS=$IFS; IFS=$SEP +set x `"$MT_MKTEXNAM" $name`; shift +IFS=$OIFS +MT_MFNAME="$3" +#fi + +destdir=`echo "$MT_MFNAME" | sed 's%/[^/][^/]*$%%'` +test -d "$destdir" || "$MT_MKTEXDIR" "$destdir" || exit 1 +cd "$destdir" || exit 1 + +case "$pointsize" in + "") echo "$progname: no pointsize."; exit 1;; + 11) realsize=10.95;; # \magstephalf + 14) realsize=14.4;; # \magstep2 + 17) realsize=17.28;; # \magstep3 + 20) realsize=20.74;; # \magstep4 + 25) realsize=24.88;; # \magstep5 + 30) realsize=29.86;; # \magstep6 + 36) realsize=35.83;; # \magstep7 + # The new convention is to have three or four letters for the + # font name and four digits for the pointsize. The number is + # pointsize * 100. We effectively divide by 100 by ignoring the + # last two digits. + ????|?????) realsize=`echo "$pointsize" | sed 's/\(..\)$/.\1/'`;; + *) realsize="$pointsize";; +esac + +mfname="$name.mf" +if test -r "$mfname"; then + echo "$progname: $destdir/$mfname already exists." + echo "$destdir/$mfname" >$STDOUT + "$MT_MKTEXUPD" "$destdir" "$mfname" + exit 0 +fi + +case "$name" in + ec*|tc*) + cat > "mf$$.tmp" < "mf$$.tmp" < "mf$$.tmp" < "mf$$.tmp" < "mf$$.tmp" < "mf$$.tmp" <$STDOUT +echo "$progname: $destdir/$mfname: successfully generated." >&2 +"$MT_MKTEXUPD" "$destdir" "$mfname" +exit 0 +) 1>&2 &//' | grep '^[0-9]*$'`" + if test -z "$tail"; then + echo "$progname: argument '$2' ignored - bad file number" >&2 + elif test "$tail" != 1; then + eval 'exec 1>&$tail' + fi +fi + +mt_max_args=2 + +# Common code for all scripts. +: ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`} +: ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`} +test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt" +if test ! -f "$MT_MKTEX_OPT"; then + echo "$progname: Cannot find mktex.opt; check your installation." >&2 + exit 1 +fi + +. "$MT_MKTEX_OPT" + +# Where do potential driver files belong? +case "$MT_FEATURES" in + *nomfdrivers*) + : ${MT_MFDESTDIR=`pwd`} + export MT_MFDESTDIR;; +esac + +# Since we want to pass the generated filename and only that filename +# back to the caller on standard output, we do some redirections so +# regular echo's will end up on stderr, and do an echo >$STDOUT at the end. +# Then the contents of $STDOUT will be echoed to stdout by a trap. + +# start of redirection stdout -> stderr, stdin <- /dev/null +( + +NAME=$1 + +if kpsewhich $NAME.mf >/dev/null 2>&1 || mktexmf $NAME >/dev/null 2>&1; then + # determine the progname of metafont to use; prefer mf-nowin. + if (mf-nowin --version) >/dev/null 2>&1; then + MF="mf-nowin -progname=mf" + else + MF=mf + fi + + # Check that $BDPI and $MODE are consistent; if not, ignore the mode and + # hope we can correctly guess it from bdpi. (People like to specify the + # resolution on the command line, not the mode so much.) + if test -n "$MODE"; then + mf_bdpi=`$MF \ +'\mode:='$MODE';mode_setup;message"BDPI= "&decimal round pixels_per_inch;end.'\ + &2 + MODE= + fi + fi + + # If an explicit mode is not supplied, try to guess. You can get a + # list of extant modes from ftp://ftp.tug.org/tex/modes.mf. + if test -z "$MODE" || test "x$MODE" = xdefault; then + case "$BDPI" in + 85) MODE=sun;; + 100) MODE=nextscrn;; + 180) MODE=toshiba;; + 300) MODE=cx;; + 360) MODE=epstylus;; + 400) MODE=nexthi;; + 600) MODE=ljfour;; + 720) MODE=epscszz;; + 1200) MODE=ultre;; + 1270) MODE=linoone;; + 8000) MODE=dpdfezzz;; + *) echo "$progname: Can't guess mode for $BDPI dpi devices." >&2 + echo "$progname: Use a config file or option to specify the mode; see:" >&2 + echo "$progname: http://tug.org/texinfohtml/kpathsea.html#Unable-to-generate-fonts" >&2 + exit 1 + esac + fi + + # Run Metafont. Always use plain Metafont, since reading cmbase.mf + # does not noticeably slow things down. + cmd="$MF \mode:=$MODE; mag:=$MAG; nonstopmode; input $NAME" +else + MODE=modeless + # ps_to_pk is set in mktex.opt + case $ps_to_pk in + gsftopk) + if $ps_to_pk -t "$NAME"; then + cmd="$ps_to_pk $NAME $DPI" + fi;; + ps2pk) + # grep for the font in $PSMAPFILE. These are base font names, such as + # rpplr (the original) or pplr0 (an interim step) or pplr8r (current). + : ${PSMAPFILE=`kpsewhich --format=map psfonts.map ps2pk.map`} + pattern="^$NAME"'([ ]|$)' + psline=`egrep "$pattern" $PSMAPFILE | tail -1` + if test -n "$psline"; then + set x `echo "$psline" | sed 's%[<["]%%g'` + shift; shift; shift; + encoding=; psname=; slant=; extend= + while test ! -z "$1"; do + case "$1" in + *.enc) encoding="-e $1";; + *.pf[ab]) psname="$1";; + *SlantFont) slant="-S $lastopt";; + *ExtendFont) extend="-E $lastopt";; + esac + lastopt="$1" + shift + done + # Guessing the name of the type1 font file as fallback: + ANAME=`echo $NAME | sed 's/8r$/8a/'` + for i in $NAME.pfa $NAME.pfb $ANAME.pfa $ANAME.pfb; do + if kpsewhich $i >/dev/null 2>&1; then + psname=$i + break + fi + done + + if [ -n "$psname" ]; then + cmd="ps2pk -v -X$DPI -R$BDPI $slant $extend $encoding $psname $NAME.${DPI}pk" + else + if gsftopk -t "$NAME"; then + echo "$progname: cannot find $NAME.pfa or $NAME.pfb. Trying gsftopk." >&2 + cmd="gsftopk $NAME $DPI" + fi + fi + fi;; + esac + + # unsupported by $ps_to_pk, try other conversions: + if test -z "$cmd"; then + if (ttf2pk -t -q $NAME) >/dev/null 2>&1; then + cmd="ttf2pk -q $NAME $DPI" + elif (hbf2gf -t -q $NAME) >/dev/null 2>&1; then + cmd="hbf2gf -q -p $NAME $DPI" + else + echo "$progname: don't know how to create bitmap font for $NAME." >&2 + echo "$progname: perhaps $NAME is missing from the map file." >&2 + exit 1 + fi + fi +fi + +OIFS=$IFS; IFS=$SEP +set x `"$MT_MKTEXNAM" $NAME $DPI $MODE $DEST`; shift +IFS=$OIFS + +PKDEST="$1" +PKDESTDIR=`echo "$PKDEST" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname +PKNAME=`basename "$PKDEST"` +GFNAME=$NAME.${DPI}gf + +if test -r "$PKDESTDIR/$PKNAME"; then + echo "$progname: $PKDESTDIR/$PKNAME already exists." >&2 + echo "$PKDESTDIR/$PKNAME" >$STDOUT + "$MT_MKTEXUPD" "$PKDESTDIR" $PKNAME + exit 0 +fi + +"$MT_MKTEXDIR" "$PKDESTDIR" +if test ! -d "$PKDESTDIR"; then + echo "$progname: $MT_MKTEXDIR $PKDESTDIR failed." >&2 + exit 1 +fi + +echo "$progname: Running $cmd" +$cmd $$.errs 2>/dev/null + grep '^! Strange path' $$.errs >$$.strange 2>/dev/null + grep '^! bad pos.' $$.errs >$$.badpos 2>/dev/null + grep '^! angle(0,0) is taken as zero.' $$.errs >$$.angle 2>/dev/null + cat $$.badpos $$.strange $$.angle | sort > $$.errs_accept + if cmp $$.errs $$.errs_accept >/dev/null 2>&1; then + test -s $$.strange >/dev/null 2>&1 \ + && echo "$progname: warning: \`$cmd' caused strange path errors." >&2 + test -s $$.badpos >/dev/null 2>&1 \ + && echo "$progname: warning: \`$cmd' caused bad pos errors." >&2 + test -s $$.angle >/dev/null 2>&1 \ + && echo "$progname: warning: \`$cmd' caused angle(0,0) errors." >&2 + else + echo "$progname: \`$cmd' failed." >&2 + test -s $NAME.log && mv -f $NAME.log "$KPSE_DOT" + exit 1; + fi +} + +test -r $GFNAME && { gftopk ./$GFNAME $PKNAME || exit 1; } +test ! -f $PKNAME && test -f $NAME.${DPI}pk && mv $NAME.${DPI}pk $PKNAME +if test ! -s $PKNAME; then + echo "$progname: \`$cmd' failed to make $PKNAME." >&2 + exit 1 +fi + +# Install the PK file carefully, since others may be working simultaneously. +# Use cp when mv fails, since DOS will fail mv for deeply-nested directories. +mv $PKNAME "$PKDESTDIR/pk$$.tmp" 2>/dev/null \ + || cp $PKNAME "$PKDESTDIR/pk$$.tmp" || exit 1 +cd "$PKDESTDIR" || exit 1 +chmod `kpsestat -xst,go-w .` pk$$.tmp +test -r $PKNAME || mv pk$$.tmp $PKNAME || exit 1 + +# Update ls-R if necessary. +"$MT_MKTEXUPD" "$PKDESTDIR" $PKNAME + +# If this line (or an equivalent) is not present, dvipsk/xdvik/dviljk +# will think mktexpk failed. Any other output to stdout will also lose. +echo "$PKDESTDIR/$PKNAME" >$STDOUT +echo "$progname: $PKDESTDIR/$PKNAME: successfully generated." >&2 +) 1>&2 &2 + exit 1 +fi + +. "$MT_MKTEX_OPT" + +# Where do potential mf driver files go? +case "$MT_FEATURES" in + *nomfdrivers*) + : ${MT_MFDESTDIR=`pwd`} + export MT_MFDESTDIR;; +esac + +# start of redirection stdout -> stderr, stdin <- /dev/null +( + +NAME=`basename "$1" .tfm` +MAG=1 # mag=0 fails with larm1000.mf +#DEST="$2" +DPI=$BDPI + +OIFS=$IFS; IFS=$SEP +set x `"$MT_MKTEXNAM" $NAME $DPI $MODE $DEST`; shift +IFS=$OIFS + +PKDEST="$1" +TFMDEST="$2" +PKDESTDIR=`echo "$PKDEST" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname +TFMDESTDIR=`echo "$TFMDEST" | sed 's%/[^/][^/]*$%%'` +PKNAME=`basename "$PKDEST"` +TFMNAME=$NAME.tfm +GFNAME=$NAME.$DPI'gf' + +if test -r "$TFMDESTDIR/$TFMNAME"; then + echo "$progname: $TFMDESTDIR/$TFMNAME already exists." >&2 + echo "$TFMDESTDIR/$TFMNAME" >$STDOUT + "$MT_MKTEXUPD" "$TFMDESTDIR" $TFMNAME + exit +fi + +# Try to create the destdir first. Do not create fonts, if this fails. +"$MT_MKTEXDIR" "$TFMDESTDIR" +if test ! -d "$TFMDESTDIR"; then + echo "$progname: mktexdir $TFMDESTDIR failed." + exit 1 +fi + +# Check if this font is supported by hbf2gf else use metafont. +if (hbf2gf -q -t $NAME) >/dev/null 2>&1; then + cmd="hbf2gf -g $NAME $DPI" +else + # determine the progname of metafont to use; prefer mf-nowin. + if (mf-nowin --version) >/dev/null 2>&1; then + MF="mf-nowin -progname=mf" + else + MF=mf + fi + + cmd="$MF \mode:=$MODE; mag:=$MAG; nonstopmode; input $NAME" +fi + +echo "$progname: Running $cmd" +$cmd $$.errs 2>/dev/null + grep '^! Strange path' $$.errs >$$.strange 2>/dev/null + grep '^! bad pos.' $$.errs >$$.badpos 2>/dev/null + grep '^! angle(0,0) is taken as zero.' $$.errs >$$.angle 2>/dev/null + cat $$.badpos $$.strange $$.angle | sort > $$.errs_accept + if cmp $$.errs $$.errs_accept >/dev/null 2>&1; then + test -s $$.strange >/dev/null 2>&1 \ + && echo "$progname: warning: \`$cmd' caused strange path errors." >&2 + test -s $$.badpos >/dev/null 2>&1 \ + && echo "$progname: warning: \`$cmd' caused bad pos errors." >&2 + test -s $$.angle >/dev/null 2>&1 \ + && echo "$progname: warning: \`$cmd' caused angle(0,0) errors." >&2 + else + echo "$progname: \`$cmd' failed." >&2 + test -s $NAME.log && mv -f $NAME.log "$KPSE_DOT" + exit 1; + fi +} + +# hbf2gf just produces a .pl file: +test -r ./$NAME.pl && pltotf ./$NAME.pl $TFMNAME +test -r $TFMNAME || { echo "$progname: \`$cmd' failed to make $TFMNAME."; exit 1; } + +# Install the TFM file carefully, since others may be working simultaneously. +# Use cp when mv fails, since DOS will fail mv for deeply-nested directories. +mv $TFMNAME "$TFMDESTDIR/tfm$$.tmp" 2>/dev/null \ + || cp $TFMNAME "$TFMDESTDIR/tfm$$.tmp" || exit 1 +cd "$TFMDESTDIR" || exit 1 +chmod `kpsestat -xst,go-w .` tfm$$.tmp +test -r $TFMNAME || mv tfm$$.tmp $TFMNAME || exit 1 + +# OK, success with the TFM. +"$MT_MKTEXUPD" "$TFMDESTDIR" $TFMNAME +echo "$TFMDESTDIR/$TFMNAME" >$STDOUT +echo "$progname: $TFMDESTDIR/$TFMNAME: successfully generated." >&2 + +# Since we probably made a GF(->PK) file, too, may as well install it if +# it's needed. +cd $TEMPDIR +if test -r $GFNAME && test ! -f "$PKDESTDIR/$PKNAME"; then + gftopk ./$GFNAME $PKNAME || exit 1 + "$MT_MKTEXDIR" "$PKDESTDIR" + mv $PKNAME "$PKDESTDIR/pk$$.tmp" 2>/dev/null \ + || cp $PKNAME "$PKDESTDIR/pk$$.tmp" || exit 1 + cd "$PKDESTDIR" || exit 1 + if test -f $PKNAME; then + rm -f pk$$.tmp + else + chmod `kpsestat -xst,go-w .` pk$$.tmp + mv pk$$.tmp $PKNAME + "$MT_MKTEXUPD" "$PKDESTDIR" $PKNAME + fi +fi +) 1>&2