--- teTeX-src-2.0-rc1/texk/tetex/updmap.updmap-cnfdir-alt 2003-01-03 00:14:59 +0200 +++ teTeX-src-2.0-rc1/texk/tetex/updmap 2003-01-14 01:06:03 +0200 @@ -76,7 +76,7 @@ Usage: updmap [option] ... [command] Valid options: - --cnffile file specify configuration file + --cnfdir directory specify configuration files directory --outputdir directory specify output directory --nohash do not run texhash --nomkmap do not recreate map files @@ -129,7 +129,7 @@ ############################################################################### cfgval() { - cat $cnfFile | sed -n 's/^'"$1"'[ =][ =]*//p' | tail -1 + cat $cnfFiles | sed -n 's/^'"$1"'[ =][ =]*//p' | tail -1 } ############################################################################### @@ -187,12 +187,15 @@ ############################################################################### catMaps() { - egrep "$1" $cnfFile \ - | sed 's@#.*@@' \ + + for i in $cnfFiles ; do + egrep "$1" $i \ + | sed 's@#.*@@' \ | awk '{print $2}' \ | sort \ | uniq \ - | grep . > $tmp4 + | grep . + done > $tmp4 while read map; do file=`locateMap "$map"` @@ -259,7 +262,9 @@ ;; esac - configReplace "$cnfFile" "^$opt[ ]" "$opt $val" + for i in $cnfFiles ; do + configReplace "$i" "^$opt[ ]" "$opt $val" + done } ############################################################################### @@ -281,7 +286,9 @@ disableMap "$2" # now enable with the right type: - configReplace "$cnfFile" "^#![ ]*$1[ ]*$2" "$1 $2" + for i in $cnfFiles ; do + configReplace "$i" "^#![ ]*$1[ ]*$2" "$1 $2" + done } ############################################################################### @@ -290,10 +297,13 @@ ############################################################################### disableMap() { - mapType=`awk '($1 == "MixedMap" || $1 == "Map") && $2 == map { print $1 }' \ - map=$1 <"$cnfFile" | sort | uniq` - for type in $mapType; do - configReplace "$cnfFile" "^$type[ ]*$1" "#! $type $1" + + for i in $cnfFiles ; do + mapType=`awk '($1 == "MixedMap" || $1 == "Map") && $2 == map { print $1 }' \ + map=$1 <"$i" | sort | uniq` + for type in $mapType; do + configReplace "$i" "^$type[ ]*$1" "#! $type $1" + done done } @@ -539,20 +549,20 @@ verbose=true needsCleanup=false - cnfFileShort=updmap.cfg - cnfFile= - outputdir= + cnfFileShort=00updmap.cfg + cnfFileOriginal=updmap.cfg + cnfFiles= + outputdir=/etc/tex-fonts/ TEXMFMAIN=`kpsewhich --expand-var='$TEXMFMAIN'` - tmpdir=${TMP-/tmp}/$progname.$$ - tmp1=$tmpdir/a - tmp2=$tmpdir/b - tmp3=$tmpdir/c - tmp4=$tmpdir/d - tmp5=$tmpdir/e - tmp6=$tmpdir/f - tmp7=$tmpdir/g - tmp8=$tmpdir/h + tmp1=`mktemp /tmp/updmap.XXXXXXXXXXXXX` + tmp2=`mktemp /tmp/updmap.XXXXXXXXXXXXX` + tmp3=`mktemp /tmp/updmap.XXXXXXXXXXXXX` + tmp4=`mktemp /tmp/updmap.XXXXXXXXXXXXX` + tmp5=`mktemp -d /tmp/updmap.XXXXXXXXXXXXX` + tmp6=`mktemp /tmp/updmap.XXXXXXXXXXXXX` + tmp7=`mktemp /tmp/updmap.XXXXXXXXXXXXX` + tmp8=`mktemp /tmp/updmap.XXXXXXXXXXXXX` } ############################################################################### @@ -562,8 +572,16 @@ cleanup() { rc=$? - $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ - && { rm -f "$tmpdir"/*; cd /; rmdir "$tmpdir"; } + if test -n "$needsCleanup" ; then + test -n "$tmp1" && rm -f "$tmp1" + test -n "$tmp2" && rm -f "$tmp2" + test -n "$tmp3" && rm -f "$tmp3" + test -n "$tmp4" && rm -f "$tmp4" + test -n "$tmp5" && rm -rf "$tmp5" + test -n "$tmp6" && rm -f "$tmp6" + test -n "$tmp7" && rm -f "$tmp7" + test -n "$tmp8" && rm -f "$tmp8" + fi exit $rc } @@ -577,7 +595,6 @@ trap 'cleanup' 1 2 3 7 13 15 needsCleanup=true - mkdir "$tmpdir" || abort "could not create directory \`$tmpdir'" } ############################################################################### @@ -614,6 +631,17 @@ { if test -z "$outputdir"; then + # Try TEXFONTSCNF tree. Use it if variable is set and dvips/config can + # be written. Copy config file if it does not exist there. + tf=`kpsewhich -expand-var='$TEXFONTSCNF'` + if test -n "$tf"; then + $TEXMFMAIN/web2c/mktexdir "$tf" >/dev/null + if test ! -d "$tf" || test ! -w "$tf"; then + # forget about TEXF tree... + tf= + fi + fi + # Try VARTEXMF tree. Use it if variable is set and dvips/config can # be written. Copy config file if it does not exist there. tf=`kpsewhich -expand-var='$VARTEXMF'` @@ -625,10 +653,9 @@ fi fi - # Try something relative to config file, fall back to $TEXMFMAIN. + # fall back to $TEXMFMAIN. if test -z "$tf"; then - tf=`echo $cnfFile | sed -n 's@/web2c/[^/]*$@@p'` - test -z "$tf" && tf=$TEXMFMAIN + tf=$TEXMFMAIN fi outputdir=$tf/dvips/config @@ -647,21 +674,26 @@ setupCfgFile() { - if test -z "$cnfFile"; then + if test -z "$cnfFiles"; then - tf=`kpsewhich -expand-var='$VARTEXMF'` - if test -n "$tf" && test ! -f "$tf/web2c/$cnfFileShort"; then - test -d "$tf/web2c" || $TEXMFMAIN/web2c/mktexdir "$tf/web2c" 2>/dev/null - if test -d "$tf/web2c" && test -w "$tf/web2c"; then - rm -f "$tf/web2c/$cnfFileShort" - cp $TEXMFMAIN/web2c/$cnfFileShort "$tf/web2c/$cnfFileShort" - $TEXMFMAIN/web2c/mktexupd "$tf/web2c" "$cnfFileShort" + if test -z "$cnfDir" ; then + + tf=`kpsewhich -expand-var='$TEXFONTSCNF'` + if test -n "${tf}.d" && test ! -f "${tf}.d/$cnfFileShort"; then + test -d "${tf}.d" || $TEXMFMAIN/web2c/mktexdir "${tf}.d" 2>/dev/null + if test -d "${tf}.d" && test -w "${tf}.d"; then + rm -f "${tf}.d/$cnfFileShort" + cp $TEXMFMAIN/web2c/$cnfFileOriginal "${tf}.d/$cnfFileShort" + $TEXMFMAIN/web2c/mktexupd "${tf}.d" "$cnfFileShort" fi fi - - cnfFile=`locateWeb2c $cnfFileShort` + else + tf="$cnfDir" + fi + cnfFile="/etc/tex-fonts.d/$cnfFileShort" if test -n "$cnfFile"; then verboseMsg "using config file $cnfFile" + cnfFiles=`ls -1 ${tf}.d/*.cfg` else abort "config file $cnfFileShort not found" fi @@ -678,10 +710,10 @@ case $1 in --quiet|-q) verbose=false;; - --cnffile) - cfgparam=1; cnfFile=$2; shift;; - --cnffile=*) - cfgparam=1; cnfFile=`echo "$1" | sed 's/--cnffile=//'`;; + --cnfdir) + cfgparam=1; cnfDir=$2; shift;; + --cnfdir=*) + cfgparam=1; cnfDir=`echo "$1" | sed 's/--cnfdir=//'`;; --outputdir) outputdirparam=1; outputdir=$2; shift;; --outputdir=*) @@ -717,7 +749,7 @@ do test $# -gt 0 && shift; done if test -n "$cfgparam"; then - if test -z "$cnfFile" || test ! -f "$cnfFile"; then + if test -z "$cnfDir" || test ! -d "$cnfDir"; then abort "config file \`$cnfFileShort' not found" fi fi @@ -737,7 +769,9 @@ ############################################################################### listMaps() { - egrep '^(#! *)?(Mixed)?Map' $cnfFile + for i in $cnfFiles ; do + egrep '^(#! *)?(Mixed)?Map' $i + done } ############################################################################### @@ -892,16 +926,16 @@ setupCfgFile case "$cmd" in - listmaps) listMaps; exit;; + listmaps) listMaps; cleanup; exit;; esac # keep a copy of config file, so that we can see if the file was modified setupTmpDir - cp $cnfFile $tmp5 + cp $cnfFiles $tmp5 case "$cmd" in edit) - ${VISUAL-${EDITOR-vi}} $cnfFile;; + ${VISUAL-${EDITOR-vi}} $cnfFiles;; setoption) setOption "$setoptionOpt" "$setoptionVal";; enable) @@ -910,10 +944,21 @@ disableMap "$disableMapFile";; esac - if test -n "$cmd" && cmp $cnfFile $tmp5 >/dev/null 2>&1; then - verboseMsg "$cnfFile unchanged. Map files not recreated." - return - fi + if test -n "$cmd" ; then + changed= + for i in $cnfFiles ; do + if test -n "$cmd" && cmp $i $tmp5/`basename $i` >/dev/null 2>&1; then + verboseMsg "$i unchanged." + else + changed=1 + fi + done + + if test -n "$changed" ; then + verboseMsg "Configuration files unchanged, maps wouldn't be recreated" + return + fi + fi $mkmapEnabled || return setupDestDir