texlive-filesystem/update.texlive

1059 lines
31 KiB
Bash

#!/bin/bash
#
# $TEXMFMAIN/texconfig/update Update the TeXLive system depending on
# the marks found below /var/run/texlive
# and also tries do determine the required printer setup like the page size
# layout, printer resolution and printer blackening.
#
# This script is based on the old SuSEconfig.texlive or SuSEconfig.tetex
# script used before for this job.
#
# Copyright (c) 1997-2001 SuSE Gmbh Nuernberg, Germany. All rights reserved.
# Copyright (c) 2004 SuSE LINUX AG, Germany. All rights reserved.
# Copyright (c) 2007-2009 SuSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2011-2012 SuSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2016 SUSE Linux GmbH, Nuernberg, Germany.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# Author: Werner Fink, 1997-2012,2016
#
if test -n "$1" -a "$1" = force; then
mkdir -p /var/run/texlive
for tag in run-mktexlsr run-hyphen \
run-fmtutil.language run-fmtutil \
run-fmtutil.refresh run-update
do
> /var/run/texlive/$tag
done
fi
# Empty directory means nothing todo
test -d /var/run/texlive || exit 0
typeset -r OLDIFS="$IFS"
typeset -i rc=0
typeset -i nl=0
: ${VERBOSE=true}
umask 022
#
# We need a check for an already modified texlive configuration:
# therefore we use md5 check sums.
#
LIBDIR=/var/lib/texmf
MD5DIR=$LIBDIR/md5
OLDMD5DIR=/var/adm/SuSEconfig/md5
test -d $LIBDIR || { echo The directory $LIBDIR does not exists 1>&2; exit 1; }
mkdir -p $MD5DIR || { echo Can not create directory $MD5DIR 1>&2; exit 1; }
unset ${!LC_*}
LANG=POSIX
MKTEXLSR=true
UPDMAPSYNC=yes
export LANG MKTEXLSR UPDMAPSYNC
#
# Sanity check
#
size=$(find /etc/texmf/ls-R -follow -printf '%s' || echo 0)
test $size -lt 80 && > /var/run/texlive/run-mktexlsr
rotator ()
{
local -i i=0 n=0
local -a elements=('|' '/' '-' '\')
while read -s -n 1 ; do
printf "\r[${elements[((i++%4))]}]"
let n=1
done
((n > 0)) && echo
}
atexit()
{
exec 4>&-
# Empty directory means nothing todo
rm -r /var/run/texlive || :
}
if test $VERBOSE = true ; then
exec 4> >(rotator)
elif test $VERBOSE = debug ; then
log=$(mktemp --tmpdir=/tmp update.XXXXXXXX) || exit 1
set -x
exec 4> >(tee $log) 2>&4
else
exec 4> /dev/null
fi
trap atexit EXIT
type -p mktexlsr &> /dev/null || { echo "${0##*/}: No mktexlsr in PATH ... skipping" 1>&2; exit 0 ; }
#
# Straightforward ... here we go
#
for run in /var/run/texlive/run-mktexlsr* ; do
test -e $run || break
test $VERBOSE = true && { echo -en "\r[ ]Updating TeX hash data base."; let nl++; }
mktexlsr < /dev/null 1>&4 2>&4
let rc+=$?
rm -f /var/run/texlive/run-mktexlsr*
> /var/run/texlive/sync-updmap
done
((nl == 0)) || { echo; let nl=0; }
type -p kpsewhich &> /dev/null || { echo "${0##*/}: No kpsewhich in PATH ... skipping" 1>&2; exit 0 ; }
type -p md5sum &> /dev/null || { echo "${0##*/}: No md5sum in PATH ... skipping" 1>&2; exit 0 ; }
type -p readlink &> /dev/null || { echo "${0##*/}: No readlink in PATH ... skipping" 1>&2; exit 0 ; }
type -p find &> /dev/null || { echo "${0##*/}: No find in PATH ... skipping" 1>&2; exit 0 ; }
type -p sort &> /dev/null || { echo "${0##*/}: No sort in PATH ... skipping" 1>&2; exit 0 ; }
type -p env &> /dev/null || { echo "${0##*/}: No env in PATH ... skipping" 1>&2; exit 0 ; }
type -p sed &> /dev/null || { echo "${0##*/}: No sed in PATH ... skipping" 1>&2; exit 0 ; }
type -p tr &> /dev/null || { echo "${0##*/}: No tr in PATH ... skipping" 1>&2; exit 0 ; }
type -p grep &> /dev/null || { echo "${0##*/}: No grep in PATH ... skipping" 1>&2; exit 0 ; }
type -p ed &> /dev/null || { echo "${0##*/}: No ed in PATH ... skipping" 1>&2; exit 0 ; }
type -p yes &> /dev/null || { echo "${0##*/}: No yes in PATH ... skipping" 1>&2; exit 0 ; }
# Be sure that configuring in /etc/texmf will work even if
# there are files relative to /etc/texmf ...
unset KPSE_DOT || true
: ${TEXMFMAIN:=$(kpsewhich --expand-path='$TEXMFMAIN' 2> /dev/null)}
: ${TEXMFDIST:=$(kpsewhich --expand-path='$TEXMFDIST' 2> /dev/null)}
: ${TEXMFVAR:=$(kpsewhich --var-value=TEXMFVAR 2> /dev/null)}
: ${TEXMFCNFFILE:=$(kpsewhich texmf.cnf 2> /dev/null)}
: ${FMTUTILCNFFILE:=$(kpsewhich fmtutil.cnf 2> /dev/null)}
: ${TEXLUACNFFILE:=$(kpsewhich -format=web2c texmfcnf.lua 2> /dev/null)}
: ${TEXMFSYSCONFIG:=$(kpsewhich --expand-path='$TEXMFSYSCONFIG' 2> /dev/null)}
: ${TEXMFLSR:=$(kpsewhich --show-path=ls-R 2> /dev/null)}
: ${WEB2C:=$TEXMFVAR/web2c}
test -L "$TEXMFCNFFILE" && TEXMFCNFFILE="$(readlink -f "$TEXMFCNFFILE" 2> /dev/null)"
#
# Configuration broken
#
if test ! -e "$TEXMFCNFFILE" ; then
echo "${0##*/}: Configuration of texlive installation not found." 1>&2
exit 0
fi
#
# Check for old configurations and inform system admin to check those
#
typeset -i mail=0
typeset -a list=()
for cnf in ${TEXMFCNFFILE} ${FMTUTILCNFFILE} ${TEXLUACNFFILE}
do
test -e ${cnf}.rpmnew || continue
list[mail++]=${cnf}
done
if ((mail > 0))
then
mailx -s "TeXLive Update: Warning about changed configurations" root@localhost <<-EOF
Hello,
the update script has found one or more changed configuration files:
$(for cnf in ${list[@]}; do echo " ${cnf}"; done)
Please (if required) port the changes to the files with suffix .rpmnew!
Always move those rpmnew files to the original location:
$(for cnf in ${list[@]}; do echo " mv ${cnf}.rpmnew ${cnf}"; done)
afterwards run as root:
/usr/share/texmf/texconfig/update force
to get your configuration work again.
EOF
fi
unset mail list cnf
#
# Check for scriplets
#
for run in /var/run/texlive/scriptlets/* ; do
test -e "$run" || break
bash $run < /dev/null 1>&4 2>&4
done
#
# Language and hyphenation setup
#
cnf_ldat=$(TEXMF=$TEXMFSYSCONFIG kpsewhich language.dat 2> /dev/null)
cnf_ldef=$(TEXMF=$TEXMFSYSCONFIG kpsewhich language.def 2> /dev/null)
cnf_llua=$(TEXMF=$TEXMFSYSCONFIG kpsewhich language.dat.lua 2> /dev/null)
cnf_fmtu=$(TEXMF=$TEXMFSYSCONFIG kpsewhich fmtutil.cnf 2> /dev/null)
cnf_umap=$(TEXMF=$TEXMFSYSCONFIG kpsewhich updmap.cfg 2> /dev/null)
if test -z "$cnf_llua" ; then
#
# RPM has trouble with symbolic links instead of files
#
old=$(TEXMF=$TEXMFDIST kpsewhich language.dat.lua 2> /dev/null)
cnf_llua=${TEXMFSYSCONFIG}${old#*${TEXMFDIST}}
if test -n "$old" -a -e "$old" -a ! -L "$old" ; then
base="${old##*/}"
path="${old%/*}"
if test -d ${TEXMFSYSCONFIG}${path#$TEXMFDIST}; then
if test -e "$cnf_llua" ; then
rm -f "$old"
else
mv "$old" "$cnf_llua"
fi
ln -sf "$cnf_llua" "$old"
fi
fi
mktexlsr $TEXMFSYSCONFIG < /dev/null 1>&4 2>&4
cnf_llua=$(TEXMF=$TEXMFSYSCONFIG kpsewhich language.dat.lua 2> /dev/null)
fi
test -n "$cnf_llua" || { echo There is still no language.dat.lua below $TEXMFSYSCONFIG 1>&2; exit 1; }
#
# Do some sanity checks as well
#
for hyp in ${TEXMFDIST}/tex/generic/config/language.splits/hyphen*
do
test -e "$hyp" || continue
suffix=${hyp##*/}
suffix=${suffix#*.}
case "$suffix" in
dat.lua)
test "$hyp" -nt "$cnf_llua" ;;
dat)
test "$hyp" -nt "$cnf_ldat" ;;
def)
test "$hyp" -nt "$cnf_ldef" ;;
esac && {
> /var/run/texlive/run-hyphen
> /var/run/texlive/run-fmtutil.language
}
done
unset hyp suffix
#
# Be sure that the TeX Links do fit the configuration in fmtutil.cnf
#
if type -p texlinks &> /dev/null
then
test $VERBOSE = true && { echo -en "\r[ ]Updating TeX links"; let nl++; }
texlinks < /dev/null 1>&4 2>&4
((nl == 0)) || { echo; let nl=0; }
fi
init=false
typeset -i yes=0
while read format engine language rest
do
line=($rest)
last=${line[-1]}
inifile=${last#\*}
case "$engine" in
mpost) fmt="$format.mem"; kpse=mpost; engine=metapost ;;
mf|mfw|mf-nowin) fmt="$format.base"; kpse=mf; engine=metafont ;;
*) fmt="$format.fmt"; kpse=tex; engine=$engine ;;
esac
test -d ${WEB2C}/$engine || mkdir -p ${WEB2C}/$engine
fmt="${WEB2C}/$engine/$fmt"
if test ! -e "$fmt"
then
inifile=$(kpsewhich -progname=$format -format=$kpse $inifile 2>/dev/null) || continue
let yes++
continue
fi
if test -x /usr/bin/mtxrun
then
case "${fmt}" in
/*/cont-[a-z][a-z].fmt)
rm -f "$fmt"
continue
;;
esac
fi
test "$fmt" -nt "$TEXMFCNFFILE" || init=true
inifile=$(kpsewhich -progname=$format -format=$kpse $inifile 2>/dev/null) || continue
let yes++
test "$fmt" -nt "$inifile" && continue
case "$engine" in
mpost) fmtutil-sys --byfmt "$egine" < /dev/null 1>&4 2>&4 ;;
mf|mfw|mf-nowin) fmtutil-sys --byfmt "$egine" < /dev/null 1>&4 2>&4 ;;
*) > /var/run/texlive/run-fmtutil.refresh
esac
done < <(sed -r "/^(\#.*|[[:blank:]]*)$/d" "$cnf_fmtu")
unset format engine language rest line last inifile fmt kpse engine
if ((yes == 0)) ; then
echo "${0##*/}: This TeXLive installation is broken!" 1>&2
echo "${0##*/}: Only programs are found but no init file(s) at all. You might install" 1>&2
echo "${0##*/}: e.g. texlive-collection-latex or any other texlive-collection package." 1>&2
exit 1
fi
unset yes
md5_ldat=${MD5DIR}${cnf_ldat}
md5_ldef=${MD5DIR}${cnf_ldef}
md5_llua=${MD5DIR}${cnf_llua}
if test -n "${cnf_ldat}" -a -n "${cnf_ldef}" -a -n "${cnf_llua}" ; then
for cfg in ${cnf_ldat} ${cnf_ldef} ${cnf_llua} ; do
test -s ${OLDMD5DIR}${cfg} || continue
if test -e ${MD5DIR}${cfg} ; then
if test ${MD5DIR}${cfg} -nt ${OLDMD5DIR}${cfg} ; then
rm -f ${OLDMD5DIR}${cfg}
continue
fi
else
mkdir -p ${MD5DIR}${cfg%/*}
fi
mv -f ${OLDMD5DIR}${cfg} ${MD5DIR}${cfg}
done
#
# Handle hyphens
#
typeset -i refresh=0
for run in /var/run/texlive/run-hyphen* ; do
test -e "$run" || break
tmp=${cnf_ldat}.$RANDOM
set -C
echo "% Generated by ${TEXMFDIST}/texconfig/update on $(date)" > $tmp
cat ${TEXMFDIST}/tex/generic/config/language.us >> $tmp
for dat in ${TEXMFDIST}/tex/generic/config/language.splits/*.dat ; do
test -e "$dat" || break
cat "$dat"
done >> $tmp
mv -f $tmp ${cnf_ldat}
let refresh++
#
tmp=${cnf_ldef}.$RANDOM
cat ${TEXMFDIST}/tex/generic/config/language.us.def >> $tmp
for def in ${TEXMFDIST}/tex/generic/config/language.splits/*.def ; do
test -e "$def" || break
cat "$def"
done >> $tmp
echo '%%% No changes may be made beyond this point.' >> $tmp
echo >> $tmp
echo '\uselanguage {USenglish} %%% This MUST be the last line of the file.' >> $tmp
mv -f $tmp ${cnf_ldef}
let refresh++
#
tmp=${cnf_llua}.$RANDOM
echo "-- Generated by ${TEXMFDIST}/texconfig/update on $(date)" > $tmp
cat ${TEXMFDIST}/tex/generic/config/language.us.lua >> $tmp
for lua in ${TEXMFDIST}/tex/generic/config/language.splits/*.dat.lua ; do
test -e "$lua" || break
cat "$lua"
done >> $tmp
# Silent editor {
echo '}' >> $tmp
mv -f $tmp ${cnf_llua}
let refresh++
set +C
rm -f /var/run/texlive/run-hyphen*
done
if ((refresh > 0))
then
#
# New md5 sums
#
md5_ldat=${MD5DIR}${cnf_ldat}
md5_ldef=${MD5DIR}${cnf_ldef}
md5_llua=${MD5DIR}${cnf_llua}
set -- $(md5sum < ${cnf_ldat}) ; md5ldat="$1"
set -- $(md5sum < ${cnf_ldef}) ; md5ldef="$1"
set -- $(md5sum < ${cnf_llua}) ; md5llua="$1"
#
# Previous md5 sums
#
omd5ldat=0
omd5ldef=0
omd5llua=0
if test -e ${md5_ldat} -a -r ${md5_ldat} ; then
set -- $(cat ${md5_ldat}) ; omd5ldat="$1"
elif test ! -d ${md5_ldat%/*} ; then
mkdir -p ${md5_ldat%/*}
fi
echo "$md5ldat" > $md5_ldat
if test -e ${md5_ldef} -a -r ${md5_ldef} ; then
set -- $(cat ${md5_ldef}) ; omd5ldef="$1"
elif test ! -d ${md5_ldef%/*} ; then
mkdir -p ${md5_ldef%/*}
fi
echo "$md5ldef" > $md5_ldef
if test -e ${md5_llua} -a -r ${md5_llua} ; then
set -- $(cat ${md5_llua}) ; omd5llua="$1"
elif test ! -d ${md5_llua%/*} ; then
mkdir -p ${md5_llua%/*}
fi
echo "$md5llua" > $md5_llua
#
# Refresh formats for new language.dat and/or language.def if needed
#
while read format engine language rest
do
line=($rest)
last=${line[-1]}
inifile=${last#\*}
case "$engine" in
mpost) continue ;;
mf|mfw|mf-nowin) continue ;;
*) fmt="$format.fmt"; kpse=tex; engine=$engine ;;
esac
test -d ${WEB2C}/$engine || mkdir -p ${WEB2C}/$engine
fmt="${WEB2C}/$engine/$fmt"
test -e "$fmt" || continue
inifile=$(kpsewhich -progname=$format -format=$kpse $inifile 2>/dev/null) || continue
for lang in ${language//,/ }
do
for cfg in ${cnf_ldat} ${cnf_ldef} ${cnf_llua}
do
test $lang = "${cfg##*/}" || continue
test $fmt -nt $cfg && continue
> /var/run/texlive/run-fmtutil.language
break 3
done
done
done < <(sed -r "/^(\#.*|[[:blank:]]*)$/d" "$cnf_fmtu")
unset format engine language lang rest line last inifile fmt kpse engine
fi
fi
tcfmgr ()
{
${TEXMFMAIN}/texconfig/tcfmgr ${1+"$@"} 2> /dev/null
}
enablemaps ()
{
local -i rc=0
local -i hash=0
local -a maps=($(sed -rn "s@^(\#\![[= =]]+)(Mixed|Kanji)?Map[[:blank:]]*@@gp" < $cnf_umap | \
xargs -r kpsewhich --format=map 2> /dev/null | \
sed -r "s@.*/([^/]*)@\1@g"))
local line emap
((${#maps} == 0)) && return $rc
for line in ${maps[@]} ; do
let hash++
emap=$(sed -rn "s/^\#\![[= =]]+((Mixed|Kanji)?Map)[[:blank:]]*(${line})/\1=\3/p" $cnf_umap)
updmap-sys --cnffile $cnf_umap --nohash --enable $emap
let rc+=$?
done
((hash > 0)) && > /var/run/texlive/run-mktexlsr
return $rc
}
has_formats()
{
local hyphen format=tex
local OIFS="$IFS"
local IFS=$'\n'
test -e "$cnf_fmtu" || return 1
local -a list=($(sed -r "/^(\#.*|[[:blank:]]*)$/d" "$cnf_fmtu"))
local -a line
IFS="$OIFS"
local -i count=${#list[@]}
local -i last
case "$1" in
*.lua) format=lua
esac
while ((count-- > 0)) ; do
line=(${list[count]})
test ${line[2]} = "-" && continue
let last=${#line[@]}
let last--
hyphen=$(kpsewhich -progname=${line[0]} -format=$format ${line[2]} 2>/dev/null) || continue
test -n "$hyphen" -a -e "$hyphen" -a "${hyphen##*/}" = "${1##*/}" || continue
return 0
done
return 1
}
make_context_fmts()
{
local -i status=0
# luametatex/lmtx
for fmt in ${TEXMFDIST}/tex/context/base/mkxl/cont-[a-z][a-z].mkxl
do
test -x /usr/bin/mtxrun || break
fmt=${fmt##*/}
fmt=${fmt%.*}
LUATEXDIR=${TEXMFDIST}/scripts/context/lua \
TEXMFCACHE=${TEXMFVAR} \
TEXMFCNF="home:texmf/web2c;${TEXMFCNFFILE%/*};${TEXMFDIST}/web2c" \
/usr/bin/context $fmt --make < /dev/null 1>&4 2>&4
let status+=$?
done
# luatex/mkiv
for fmt in ${TEXMFDIST}/tex/context/base/mkiv/cont-[a-z][a-z].mkiv
do
test -x /usr/bin/mtxrun || break
fmt=${fmt##*/}
fmt=${fmt%.*}
LUATEXDIR=${TEXMFDIST}/scripts/context/lua \
TEXMFCACHE=${TEXMFVAR} \
TEXMFCNF="home:texmf/web2c;${TEXMFCNFFILE%/*};${TEXMFDIST}/web2c" \
/usr/bin/context $fmt --luatex --make < /dev/null 1>&4 2>&4
let status+=$?
done
# rehash database
LUATEXDIR=${TEXMFDIST}/scripts/context/lua \
TEXMFCACHE=${TEXMFVAR} \
TEXMFCNF="home:texmf/web2c;${TEXMFCNFFILE%/*};${TEXMFDIST}/web2c" \
/usr/bin/mtxrun --script fonts --reload < /dev/null 1>&4 2>&4
let status+=$?
return status
}
#
# ConTeXt data bases
#
if test -x /usr/bin/mtxrun ; then
test $VERBOSE = true && { echo -en "\r[ ]Generate file database."; let nl++; }
# luametatex/lmtx
LUATEXDIR=${TEXMFDIST}/scripts/context/lua \
TEXMFCACHE=${TEXMFVAR} \
TEXMFCNF="home:texmf/web2c;${TEXMFCNFFILE%/*};${TEXMFDIST}/web2c" \
/usr/bin/mtxrun --generate < /dev/null 1>&4 2>&4
let rc+=$?
# luatex/mkiv
LUATEXDIR=${TEXMFDIST}/scripts/context/lua \
TEXMFCACHE=${TEXMFVAR} \
TEXMFCNF="home:texmf/web2c;${TEXMFCNFFILE%/*};${TEXMFDIST}/web2c" \
/usr/bin/context --luatex --generate < /dev/null 1>&4 2>&4
let rc+=$?
LUATEXDIR=${TEXMFDIST}/scripts/context/lua \
TEXMFCACHE=${TEXMFVAR} \
TEXMFCNF="home:texmf/web2c;${TEXMFCNFFILE%/*};${TEXMFDIST}/web2c" \
/usr/bin/mtxrun --script fonts --reload < /dev/null 1>&4 2>&4
let rc+=$?
if test -x /usr/bin/luatools ; then
TEXMF=${TEXMFDIST} \
TEXMFCACHE=${TEXMFVAR} \
TEXMFCNF=${TEXMFCNFFILE%/*} \
LUAINPUTS="$(kpsewhich --var-value=LUAINPUTS)" \
/usr/bin/luatools --generate < /dev/null 1>&4 2>&4
let rc+=$?
fi
if test -x /usr/bin/luaotfload-tool ; then
TEXMF=${TEXMFDIST} \
TEXMFCACHE=${TEXMFVAR} \
TEXMFCNF=${TEXMFCNFFILE%/*} \
LUAINPUTS="$(kpsewhich --var-value=LUAINPUTS)" \
/usr/bin/luaotfload-tool --update --prefer-texmf --formats=+afm --log=stdout < /dev/null 1>&4 2>&4
let rc+=$?
fi
fi
((nl == 0)) || { echo; let nl=0; }
#
# Go further
#
for run in /var/run/texlive/run-fmtutil.* /var/run/texlive/run-fmtutil ; do
test -e "$run" || break
type -p fmtutil-sys &> /dev/null || { echo "${0##*/}: No fmtutil-sys in PATH ... skipping" 1>&2; break; }
option=""
test $VERBOSE = true || option="--quiet"
case "${run#*fmtutil.}" in
context)
test $VERBOSE = true && { echo -en "\r[ ](Re)fresh ConTeXt formats."; let nl++; }
make_context_fmts
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
((rc != 0)) || rm -f "${run}"
;;
language)
if test -n "${cnf_ldat}" ; then
set -- $(md5sum < ${cnf_ldat})
echo $1 > ${md5_ldat}
if has_formats ${cnf_ldat} ; then
test $VERBOSE = true && { echo -en "\r[ ]Handle language.dat setups."; let nl++; }
fmtutil-sys ${option:+$option} --byhyphen ${cnf_ldat} --no-strict < /dev/null 1>&4 2>&4
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
fi
fi
if test -n "${cnf_ldef}" ; then
set -- $(md5sum < ${cnf_ldef})
echo $1 > ${md5_ldef}
if has_formats ${cnf_ldef} ; then
test $VERBOSE = true && { echo -en "\r[ ]Handle language.def setups."; let nl++; }
fmtutil-sys ${option:+$option} --byhyphen ${cnf_ldef} --no-strict < /dev/null 1>&4 2>&4
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
fi
fi
if test -n "${cnf_llua}" ; then
set -- $(md5sum < ${cnf_llua})
echo $1 > ${md5_llua}
if has_formats ${cnf_llua} ; then
test $VERBOSE = true && { echo -en "\r[ ]Handle language.dat.lua setups."; let nl++; }
fmtutil-sys ${option:+$option} --byhyphen ${cnf_llua} --no-strict < /dev/null 1>&4 2>&4
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
elif test -x /usr/bin/mtxrun > /dev/null 2>&2 ; then
test $VERBOSE = true && { echo -en "\r[ ]Handle language.dat.lua setups."; let nl++; }
make_context_fmts
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
fi
fi
((rc != 0)) || rm -f /var/run/texlive/run-fmtutil.language
;;
refresh)
test $VERBOSE = true && { echo -en "\r[ ]Refresh TeX formats."; let nl++; }
fmtutil-sys ${option:+$option} --refresh --no-strict < /dev/null 1>&4 2>&4
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
((rc != 0)) || rm -f /var/run/texlive/run-fmtutil.refresh
;;
"/var/run/texlive/run-fmtutil")
test $VERBOSE = true && { echo -en "\r[ ]Missing TeX formats."; let nl++; }
fmtutil-sys ${option:+$option} --missing --no-strict < /dev/null 1>&4 2>&4
let rc+=$?
make_context_fmts
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
((rc != 0)) || rm -f /var/run/texlive/run-fmtutil
;;
*)
test $VERBOSE = true && { echo -en "\r[ ]Updating TeX format ${run#*fmtutil.}."; let nl++; }
fmtutil-sys ${option:+$option} --byfmt "${run#*fmtutil.}" < /dev/null 1>&4 2>&4
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
((rc != 0)) || rm -f "${run}"
esac
done
for run in /var/run/texlive/run-updmap* ; do
test -e "$run" || break
type -p updmap-sys &> /dev/null || { echo "${0##*/}: No updmap-sys in PATH ... skipping" 1>&2; break; }
test -e "$cnf_umap" || break
test $VERBOSE = true && { echo -en "\r[ ]Updating TeX font mappings."; let nl++; }
while read type map; do
case "$type" in
[Aa]dd*)
type=${type#[Aa]dd}
if grep -qsE "${type}[[:blank:]]+${map}" $cnf_umap ; then
sed -ri "s/^\#\![[= =]]+(${type}[[:blank:]]+${map})/\1/" $cnf_umap
else
echo "${type} ${map}" >> $cnf_umap
fi
;;
[Dd]elete*)
type=${type#[Dd]elete}
sed -ri "s/^(${type}[[:blank:]]+${map})/\#\! \1/" $cnf_umap
;;
*)
;;
esac
done < $run
mktexlsr < /dev/null 1>&4 2>&4
let rc+=$?
updmap-sys --cnffile $cnf_umap --nohash --syncwithtrees < <(yes 2>/dev/null) 1>&4 2>&4
let rc+=$?
enablemaps $cnf_umap < /dev/null 1>&4 2>&4
let rc+=$?
updmap-sys --cnffile $cnf_umap --nohash < /dev/null 1>&4 2>&4
let rc+=$?
((rc == 0)) || continue
rm -f /var/run/texlive/run-updmap*
rm -f /var/run/texlive/sync-updmap*
rm -f /var/run/texlive/run-mktexlsr*
done
((nl == 0)) || { echo; let nl=0; }
for run in /var/run/texlive/sync-updmap* ; do
test -e "$run" || break
type -p updmap-sys &> /dev/null || break
test -e "$cnf_umap" || break
test $VERBOSE = true && { echo -en "\r[ ]Updating TeX font mappings."; let nl++; }
mktexlsr < /dev/null 1>&4 2>&4
let rc+=$?
updmap-sys --cnffile $cnf_umap --nohash --syncwithtrees < <(yes 2>/dev/null) 1>&4 2>&4
let rc+=$?
enablemaps $cnf_umap < /dev/null 1>&4 2>&4
updmap-sys --cnffile $cnf_umap --nohash < /dev/null 1>&4 2>&4
let rc+=$?
((rc == 0)) || continue
rm -f /var/run/texlive/sync-updmap*
rm -f /var/run/texlive/run-mktexlsr*
done
((nl == 0)) || { echo; let nl=0; }
#
# If texmf.cnf has changed it may contain changed memory sizes
# of various programs.
#
type -p texconfig-sys &> /dev/null || exit 0
if test $init = true ; then
test $VERBOSE = true && { echo -en "\r[ ]Initialize TeX configuration and font mappings."; let nl++; }
updmap-sys --cnffile $cnf_umap --syncwithtrees < /dev/null 1>&4 2>&4
let rc+=$?
texconfig-sys init < /dev/null 1>&4 2>&4
let rc+=$?
((nl == 0)) || { echo; let nl=0; }
fi
#
# The main configuration files of TeXLive.
#
cnf_mfont=$(tcfmgr --cmd find --file mktex.cnf)
cnf_xdvi=$(tcfmgr --cmd find --file XDvi)
cnf_dvips=$(tcfmgr --cmd find --file config.ps)
test -n "${cnf_mfont}" || exit 0
test -n "${cnf_xdvi}" || exit 0
test -n "${cnf_dvips}" || exit 0
for cfg in ${cnf_mfont} ${cnf_xdvi} ${cnf_dvips} cups ; do
test -s ${OLDMD5DIR}${cfg} || continue
if test -e ${MD5DIR}${cfg} ; then
if test ${MD5DIR}${cfg} -nt ${OLDMD5DIR}${cfg} ; then
rm -f ${OLDMD5DIR}${cfg}
continue
fi
else
mkdir -p ${MD5DIR}${cfg%/*}
fi
mv -f ${OLDMD5DIR}${cfg} ${MD5DIR}${cfg}
done
md5_mfont=${MD5DIR}${cnf_mfont}
md5_xdvi=${MD5DIR}${cnf_xdvi}
md5_dvips=${MD5DIR}${cnf_dvips}
md5_cups=${MD5DIR}/cups
#
# Is this a full TeXLive system?
#
test -e ${cnf_mfont} || exit 0 # Default MetaFont mode
test -e ${cnf_xdvi} || exit 0 # Default xdvi resolution
test -e ${cnf_dvips} || exit 0 # Default printer mode
#
# Current MD5 sums
#
set -- $(md5sum < ${cnf_mfont}) ; md5modes="$1"
set -- $(md5sum < ${cnf_xdvi} ) ; md5xdvi="$1"
set -- $(md5sum < ${cnf_dvips}) ; md5dvips="$1"
#
# The main system printer.
#
lp=""
if type -p lpoptions &>/dev/null && lpstat -r &>/dev/null ; then
dev=PS
size=a4
dpi=600
color=mono
IFS=$'\n'
IFS="$OLDIFS"
shopt -s extglob
while read line ; do
case "$line" in
PageSize*)
set -- $line
shift
while test -n "$1" ; do
case "$1" in
\**) size="${1:1}"; break
esac
shift
done
;;
CN_DPI*|Resolution*)
set -- $line
shift
cur=0
reg='?(\*)@(+([0-9])|+([0-9])x+([0-9]))dpi'
while test -n "$1" ; do
case "$1" in
${reg})
cur=${1%%+([[:alpha:]])}
esac
cur="${cur#\*}"
case "$1" in
*Color*) color=color
esac
shift
test "${cur%x*}" -gt "${dpi%x*}" && dpi=$cur
done
;;
ColorCorrection*)
set -- $line
shift
while test -n "$1" ; do
case "$1" in
\*RGB|\*CMYK) color=color; break
esac
shift
done
;;
esac
done < <(lpoptions -l < /dev/null 2> /dev/null)
shopt -u extglob
lp="lp|${dev}-$(echo ${size}-auto-${color}-${dpi}|tr '[:upper:]' '[:lower:]')"
elif test -r /etc/printcap -a -d /var/lib/apsfilter/ ; then
lp=$(grep -E '^lp\|' /etc/printcap)
elif test -r /etc/printcap -a -x /usr/lib/lpdfilter/bin/readpc ; then
lp=$(/usr/lib/lpdfilter/bin/readpc lp || true)
fi
test -n "$lp" || exit 0 # No (configured) filter system: nothing to do
if type -p lpoptions &>/dev/null && lpstat -r &>/dev/null ; then
omd5cups=0
if test -r ${md5_cups} ; then
set -- $(cat ${md5_cups}) ; omd5cups=$1
elif test ! -d ${md5_cups%/*} ; then
mkdir -p ${md5_cups%/*}
fi
set -- $(lpoptions -l 2> /dev/null | md5sum) ; md5cups=$1
if test ${omd5cups} != ${md5cups} ; then
prtcap_nt_mfont="yes"
prtcap_nt_xdvi="yes"
prtcap_nt_dvips="yes"
echo ${md5cups} > ${md5_cups}
fi
else
test /etc/printcap -nt ${cnf_mfont} && prtcap_nt_mfont="yes"
test /etc/printcap -nt ${cnf_xdvi} && prtcap_nt_xdvi="yes"
test /etc/printcap -nt ${cnf_dvips} && prtcap_nt_dvips="yes"
fi
#
# Previous md5 sums
#
omd5modes=0
omd5xdvi=0
omd5dvips=0
if test -e ${md5_mfont} -a -r ${md5_mfont} ; then
test ${md5_mfont} -nt ${cnf_mfont} && md5_nt_mfont="yes"
set -- $(cat ${md5_mfont}) ; omd5modes="$1"
elif test ! -d ${md5_mfont%/*} ; then
mkdir -p ${md5_mfont%/*}
fi
if test -e ${md5_xdvi} -a -r ${md5_xdvi} ; then
test ${md5_xdvi} -nt ${cnf_xdvi} && md5_nt_xdvi="yes"
set -- $(cat ${md5_xdvi}) ; omd5xdvi="$1"
elif test ! -d ${md5_xdvi%/*} ; then
mkdir -p ${md5_xdvi%/*}
fi
if test -e ${md5_dvips} -a -r ${md5_dvips} ; then
test ${md5_dvips} -nt ${cnf_dvips} && md5_nt_dvips="yes"
set -- $(cat ${md5_dvips}) ; omd5dvips="$1"
elif test ! -d ${md5_dvips%/*} ; then
mkdir -p ${md5_dvips%/*}
fi
#
# Convert YaST2 configured printer for apsfilter or lpdfilter
#
case "$lp" in
*\|*.upp--*)
lp=""
upp=${lp##*|}
IFS="-$IFS"
for upp in $upp ; do break; done
IFS="$OLDIFS"
if test -s /etc/gs.upp/$upp ; then
while read line ; do
case "$line" in
-sDEVICE=*) dev="${line#*=}" ;;
@*.upp) dev="${line#@}" ;;
-r*) dpi="${line#-r}" ;;
-sPAPERSIZE=*)
psz="${line#*=}" ;;
-sCOLOR=*) col="${line#*=}" ;;
*) ;;
esac
done < /etc/gs.upp/$upp
lp="lp|${dev}-${psz}-auto-${col}-${dpi}"
fi
;;
*:cm=lpdfilter*:)
entry="$lp"
lp=""
IFS=":"
for e in $entry ; do
case "$e" in
cm=lpdfilter*) eval "${e#cm=lpdfilter}" ;;
esac
done
IFS="$OLDIFS"
if test "$drv" = "upp" -a -s /etc/lpdfilter/lp/upp ; then
while read line ; do
case "$line" in
-sDEVICE=*) drv="${line#*=}" ;; # Overwrite driver!
-r*) dpi="${line#-r}" ;;
-dDEVICEXRESOLUTION=*)
xres="${line#*=}" ;;
-dDEVICEYRESOLUTION=*)
yres="${line#*=}" ;;
-sPAPERSIZE=*) size="${line#*=}" ;;
-sCOLOR=*) color="${line#*=}" ;;
-sPOSTFILTER=\"*\")
eval post="${line#*=}" ;;
@*) upp="${line#@}" ;;
esac
done < /etc/lpdfilter/lp/upp
fi
if test -n "$upp" && type -p gs &> /dev/null ; then
drv=${upp##*/}
upp=$(echo "($upp) findlibfile { pop print } { pop } ifelse" | \
gs -sDEVICE=nullpage -q -dNOPAUSE - -c quit)
fi
if test -r "$upp" ; then
while read line ; do
case "$line" in
-r*) dpi="${line#-r}" ;;
esac
done < $upp
fi
if test -z "$dpi" ; then
test -n "$xres" && dpi=$xres
test -n "$yres" && dpi=${dpi+"${dpi}x"}$yres
fi
lp="lp|${drv}-${size}-${method}-${color}-${dpi}"
;;
esac
#
# Parse the configured system main printer
# Ghostscript/PS <-> Metafont mode and paper size
# UNTESTED, Sorry I've *not* enough printers around
#
function get_paper () {
(
. /etc/sysconfig/language &> /dev/null
h=($(LANG=$RC_LANG locale -k LC_PAPER))
case "${h[0]}" in
height=297) echo a4 ;;
*) echo letter ;;
esac
)
}
case "$lp" in
*-letter-*) XDVISIZE=us ; DVIPSSIZE=letter ;;
*-legal-*) XDVISIZE=legal ; DVIPSSIZE=legal ;;
*-ledger-*) XDVISIZE=a3r ; DVIPSSIZE=ledger ;;
*-tabloid-*) XDVISIZE=a3 ; DVIPSSIZE=tabloid ;;
*-a3-*) XDVISIZE=a3 ; DVIPSSIZE=a3 ;;
*-a4-*) XDVISIZE=a4 ; DVIPSSIZE=a4 ;;
*)
case "$(get_paper)" in
a4) XDVISIZE=a4 ; DVIPSSIZE=a4 ;;
*) XDVISIZE=us ; DVIPSSIZE=letter ;;
esac
;;
esac
case "$lp" in
*\|PS*) PRINTER=ljfour ;;
*\|bj10e*) PRINTER=bjtenex ;;
*\|bj200*) PRINTER=bjtzzex ;;
*\|bjc600*) PRINTER=canonbjc ;;
*\|bjc800*) PRINTER=canonbjc ;;
*\|bjc610a*) PRINTER=canonbjc ;;
# *\|bjc610b*) PRINTER=canonbjc ;;
*\|cdeskjet*600) PRINTER=ljfour ;;
*\|deskjet*600) PRINTER=ljfour ;;
*\|cdeskjet*) PRINTER=deskjet ;;
*\|deskjet*) PRINTER=deskjet ;;
*\|cdj6*) PRINTER=ljfour ;;
*\|cdj8*) PRINTER=ljfour ;;
*\|hpdj*) PRINTER=ljfour ;;
*\|cdj*600) PRINTER=ljfour ;;
*\|djet*600) PRINTER=ljfour ;;
*\|cdj*) PRINTER=deskjet ;;
*\|djet*) PRINTER=deskjet ;;
*\|laserjet*) PRINTER=cx ;;
*\|ljetplus*) PRINTER=cx ;;
*\|ljet2*) PRINTER=cx ;;
*\|ljet3*) PRINTER=jetiiisi ;;
*\|ljet4l*) PRINTER=cx ;;
*\|ljet4*) PRINTER=ljfour ;;
*\|lj4*) PRINTER=ljfour ;;
*\|lj5*) PRINTER=ljfive ;;
# *\|lj5*) PRINTER=ljfivemp ;;
*\|stcolor*720) PRINTER=esphi ;;
*\|stcolor*) PRINTER=epstylus ;;
*\|st800*720) PRINTER=esphi ;;
*\|st800*) PRINTER=epstylus ;;
*\|stc800*720) PRINTER=esphi ;;
*\|stc800*) PRINTER=epstylus ;;
*\|stc600*) PRINTER=epscszz ;;
*\|stc_h*) PRINTER=esphi ;;
*\|stc*) PRINTER=epstypro ;;
*) PRINTER=ljfour
prtcap_nt_dvips="manual" ;;
esac
#
# Run texconfig if no one has update the TeXLive system
# or parts of it.
#
if test $omd5modes = 0 -o \
\( $md5modes = $omd5modes -a "$prtcap_nt_mfont" = "yes" -a "$md5_nt_mfont" = "yes" \)
then
test $VERBOSE = true && { echo -en "\r[ ]Set MetaFont mode."; let nl++; }
env -i MKTEXLSR=true PATH=$PATH LANG=$LANG texconfig-sys mode $PRINTER < /dev/null 1>&4 2>&4
let rc+=$?
set -- $(md5sum < ${cnf_mfont})
echo $1 > ${md5_mfont}
((nl == 0)) || { echo; let nl=0; }
fi
if test $omd5xdvi = 0 -o \
\( $md5xdvi = $omd5xdvi -a "$prtcap_nt_xdvi" = "yes" -a "$md5_nt_xdvi" = "yes" \)
then
test $VERBOSE = true && { echo -en "\r[ ]Set XDvi paper size."; let nl++; }
env -i MKTEXLSR=true PATH=$PATH LANG=$LANG texconfig-sys xdvi paper $XDVISIZE < /dev/null 1>&4 2>&4
let rc+=$?
set -- $(md5sum < ${cnf_xdvi})
echo $1 > ${md5_xdvi}
((nl == 0)) || { echo; let nl=0; }
fi
if test $omd5dvips = 0 -o \
\( $md5dvips = $omd5dvips -a "$prtcap_nt_dvips" = "yes" -a "$md5_nt_dvips" = "yes" \)
then
test $VERBOSE = true && { echo -en "\r[ ]Set dvips mode and paper size."; let nl++; }
env -i MKTEXLSR=true PATH=$PATH LANG=$LANG texconfig-sys dvips mode $PRINTER < /dev/null 1>&4 2>&4
let rc+=$?
env -i MKTEXLSR=true PATH=$PATH LANG=$LANG texconfig-sys dvips paper $DVIPSSIZE < /dev/null 1>&4 2>&4
let rc+=$?
set -- $(md5sum < ${cnf_dvips})
echo $1 > ${md5_dvips}
((nl == 0)) || { echo; let nl=0; }
fi
if test "$prtcap_nt_dvips" = "manual" -a \
\( $md5dvips = $omd5dvips -o $omd5dvips = 0 \)
then
echo -e "\n${0##*/}: Unknown default printer, use texconfig to setup dvips manually."
if test -n "$MAIL_REPORTS_TO" ; then
echo "${0##*/}: Unknown default printer, use texconfig to setup dvips manually." | \
mail -s "${0##*/}" $MAIL_REPORTS_TO
fi
fi
##
exit $rc