2012-06-20 15:03:52 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2012-07-13 09:42:19 +02:00
|
|
|
# $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.
|
|
|
|
#
|
2012-06-20 15:03:52 +02:00
|
|
|
# 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.
|
2012-07-13 09:42:19 +02:00
|
|
|
# Copyright (c) 2011-2012 SuSE LINUX Products GmbH, Nuernberg, Germany.
|
2012-06-20 15:03:52 +02:00
|
|
|
#
|
|
|
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
|
|
|
#
|
|
|
|
# Author: Werner Fink, 1997-2012
|
|
|
|
#
|
|
|
|
|
|
|
|
typeset -r OLDIFS="$IFS"
|
|
|
|
typeset -i rc=0
|
|
|
|
: ${VERBOSE=true}
|
|
|
|
|
2012-06-25 14:09:44 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
mkdir -p $MD5DIR || exit 0
|
|
|
|
|
2012-06-20 15:03:52 +02:00
|
|
|
unset ${!LC_*}
|
|
|
|
LANG=POSIX
|
|
|
|
MKTEXLSR=true
|
|
|
|
export LANG MKTEXLSR
|
|
|
|
|
2012-06-25 14:09:44 +02:00
|
|
|
mkdir -p /var/run/texlive || exit 0
|
|
|
|
|
|
|
|
#
|
|
|
|
# Sanity check
|
|
|
|
#
|
|
|
|
size=$(find /etc/texmf/ls-R -follow -printf '%s')
|
|
|
|
test $size -lt 80 && > /var/run/texlive/run-mktexlsr
|
2012-06-20 15:03:52 +02:00
|
|
|
|
|
|
|
rotator ()
|
|
|
|
{
|
2012-09-12 11:55:34 +02:00
|
|
|
local -i i=0 n=0
|
2012-06-20 15:03:52 +02:00
|
|
|
local -a elements=('|' '/' '-' '\')
|
|
|
|
while read -s -n 1 ; do
|
|
|
|
printf "\r[${elements[((i++%4))]}]"
|
2012-09-12 11:55:34 +02:00
|
|
|
let n=1
|
2012-06-20 15:03:52 +02:00
|
|
|
done
|
2012-09-12 11:55:34 +02:00
|
|
|
((n > 0)) && echo
|
|
|
|
}
|
|
|
|
|
|
|
|
atexit()
|
|
|
|
{
|
|
|
|
exec 4>&-
|
2012-06-20 15:03:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if test $VERBOSE = true ; then
|
|
|
|
exec 4> >(rotator)
|
|
|
|
else
|
|
|
|
exec 4> /dev/null
|
|
|
|
fi
|
2012-09-12 11:55:34 +02:00
|
|
|
trap atexit EXIT
|
2012-06-20 15:03:52 +02:00
|
|
|
|
2012-06-25 14:09:44 +02:00
|
|
|
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."
|
|
|
|
mktexlsr < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
test $VERBOSE = true && echo
|
|
|
|
rm -f /var/run/texlive/run-mktexlsr*
|
2012-09-12 11:55:34 +02:00
|
|
|
> /var/run/texlive/sync-updmap
|
2012-06-25 14:09:44 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
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 ; }
|
2012-06-20 15:03:52 +02:00
|
|
|
|
|
|
|
# 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)}
|
2012-06-22 18:28:48 +02:00
|
|
|
: ${TEXMFCNFFILE:=$(kpsewhich texmf.cnf 2> /dev/null)}
|
2012-06-20 15:03:52 +02:00
|
|
|
: ${TEXMFSYSCONFIG:=$(kpsewhich --expand-path='$TEXMFSYSCONFIG' 2> /dev/null)}
|
|
|
|
: ${TEXMFLSR:=$(kpsewhich --show-path=ls-R 2> /dev/null)}
|
|
|
|
: ${WEB2C:=$TEXMFVAR/web2c}
|
2012-06-22 18:28:48 +02:00
|
|
|
test -L "$TEXMFCNFFILE" && TEXMFCNFFILE="$(readlink -f "$TEXMFCNFFILE" 2> /dev/null)"
|
|
|
|
|
2012-06-25 14:09:44 +02:00
|
|
|
#
|
|
|
|
# Language and hyphenation setup
|
|
|
|
#
|
|
|
|
cnf_ldat=$(TEXMF=$TEXMFSYSCONFIG kpsewhich language.dat 2> /dev/null)
|
|
|
|
cnf_ldef=$(TEXMF=$TEXMFSYSCONFIG kpsewhich language.def 2> /dev/null)
|
|
|
|
|
|
|
|
if test -n "${cnf_ldat}" -a -n "${cnf_ldef}" ; then
|
|
|
|
for cfg in ${cnf_ldat} ${cnf_ldef} ; 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_ldat=${MD5DIR}${cnf_ldat}
|
|
|
|
md5_ldef=${MD5DIR}${cnf_ldef}
|
|
|
|
set -- $(md5sum < ${cnf_ldat}) ; md5ldat="$1"
|
|
|
|
set -- $(md5sum < ${cnf_ldef}) ; md5ldef="$1"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Previous md5 sums
|
|
|
|
#
|
|
|
|
omd5ldat=0
|
|
|
|
omd5ldef=0
|
|
|
|
if test -e ${md5_ldat} -a -r ${md5_ldat} ; then
|
|
|
|
test ${md5_ldat} -nt ${cnf_ldat} && md5_nt_ldat="yes"
|
|
|
|
set -- $(cat ${md5_ldat}) ; omd5ldat="$1"
|
|
|
|
elif test ! -d ${md5_ldat%/*} ; then
|
|
|
|
mkdir -p ${md5_ldat%/*}
|
|
|
|
fi
|
|
|
|
if test -e ${md5_ldef} -a -r ${md5_ldef} ; then
|
|
|
|
test ${md5_ldef} -nt ${cnf_ldef} && md5_nt_ldef="yes"
|
|
|
|
set -- $(cat ${md5_ldef}) ; omd5ldef="$1"
|
|
|
|
elif test ! -d ${md5_ldef%/*} ; then
|
|
|
|
mkdir -p ${md5_ldef%/*}
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Create new formats for new language.dat and/or language.def if needed
|
|
|
|
#
|
|
|
|
if test $omd5ldat = 0 -o \( $md5ldat != $omd5ldat -o "$md5_nt_ldat" != "yes" \)
|
|
|
|
then
|
|
|
|
> /var/run/texlive/run-fmtutil.language
|
|
|
|
fi
|
|
|
|
if test $omd5ldef = 0 -o \( $md5ldef != $omd5ldef -o "$md5_nt_ldef" != "yes" \)
|
|
|
|
then
|
|
|
|
> /var/run/texlive/run-fmtutil.language
|
|
|
|
fi
|
|
|
|
fi
|
2012-06-20 15:03:52 +02:00
|
|
|
|
|
|
|
tcfmgr ()
|
|
|
|
{
|
|
|
|
${TEXMFMAIN}/texconfig/tcfmgr ${1+"$@"} 2> /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
enablemaps ()
|
|
|
|
{
|
2012-09-12 11:55:34 +02:00
|
|
|
local -i rc=0
|
|
|
|
local -i hash=0
|
|
|
|
local maps=($(updmap-sys --quiet --nohash --listmaps < /dev/null 2> /dev/null | \
|
|
|
|
sed -n -r 's@(#![[:blank:]])(Mixed|Kanji)?Map[[:blank:]]*@@gp' | \
|
2012-06-20 15:03:52 +02:00
|
|
|
xargs -r kpsewhich --format=map 2> /dev/null | \
|
2012-09-12 11:55:34 +02:00
|
|
|
sed -r 's@.*/([^/]*)@\1@g'))
|
|
|
|
local line emap
|
|
|
|
((${#maps} == 0)) && return $rc
|
|
|
|
for line in ${maps[@]} ; do
|
|
|
|
let hash++
|
|
|
|
line='^#![[:blank:]]*((Mixed|Kanji)?Map)[[:blank:]]*('$line')'
|
|
|
|
emap=$(sed -n -r "s/$line/\1=\3/p" ${cfg})
|
|
|
|
updmap-sys --nohash --nomkmap --enable $emap
|
|
|
|
let rc+=$?
|
|
|
|
done
|
|
|
|
((hash > 0)) && > /var/run/texlive/run-mktexlsr
|
|
|
|
return $rc
|
2012-06-20 15:03:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
2012-06-25 14:09:44 +02:00
|
|
|
# Go further
|
2012-06-20 15:03:52 +02:00
|
|
|
#
|
2012-06-22 18:49:09 +02:00
|
|
|
for run in /var/run/texlive/run-fmtutil* ; do
|
|
|
|
test -e $run || break
|
2012-06-25 14:09:44 +02:00
|
|
|
type -p fmtutil-sys &> /dev/null || { echo "${0##*/}: No fmtutil-sys in PATH ... skipping" 1>&2; break; }
|
|
|
|
case "${run#*fmtutil.}" in
|
|
|
|
language)
|
|
|
|
test -n "${cnf_ldat}" -a -n "${cnf_ldef}" || continue
|
|
|
|
set -- $(md5sum < ${cnf_ldat})
|
|
|
|
echo $1 > ${md5_ldat}
|
2012-09-11 17:20:49 +02:00
|
|
|
set -- $(md5sum < ${cnf_ldef})
|
2012-06-25 14:09:44 +02:00
|
|
|
echo $1 > ${md5_ldef}
|
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Handle language.dat setups."
|
|
|
|
fmtutil-sys --byhyphen ${cnf_ldat} < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
test $VERBOSE = true && echo
|
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Handle language.def setups."
|
|
|
|
fmtutil-sys --byhyphen ${cnf_ldef} < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
test $VERBOSE = true && echo
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Updating TeX formats."
|
|
|
|
fmtutil-sys --missing < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
test $VERBOSE = true && echo
|
|
|
|
;;
|
|
|
|
esac
|
2012-06-22 18:49:09 +02:00
|
|
|
rm -f /var/run/texlive/run-fmtutil*
|
2012-06-22 19:02:12 +02:00
|
|
|
done
|
2012-09-11 17:20:49 +02:00
|
|
|
|
2012-06-22 18:49:09 +02:00
|
|
|
for run in /var/run/texlive/run-updmap* ; do
|
2012-09-12 11:55:34 +02:00
|
|
|
test -e $run || break
|
|
|
|
type -p updmap-sys &> /dev/null || { echo "${0##*/}: No updmap-sys in PATH ... skipping" 1>&2; break; }
|
|
|
|
cfg=$(tcfmgr --cmd find --file updmap.cfg)
|
|
|
|
test -e $cfg || break
|
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Updating TeX font mappings."
|
|
|
|
updmap-sys --nohash --nomkmap --syncwithtrees < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
enablemaps $cfg < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
if test -e /var/run/texlive/run-mktexlsr ; then
|
|
|
|
updmap-sys < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
else
|
2012-06-22 18:49:09 +02:00
|
|
|
updmap-sys --nohash < /dev/null 1>&4 2>&4
|
2012-06-25 14:09:44 +02:00
|
|
|
let rc+=$?
|
2012-09-12 11:55:34 +02:00
|
|
|
fi
|
|
|
|
# test $VERBOSE = true && echo
|
|
|
|
rm -f /var/run/texlive/run-updmap*
|
|
|
|
rm -f /var/run/texlive/sync-updmap*
|
|
|
|
rm -f /var/run/texlive/run-mktexlsr*
|
|
|
|
done
|
|
|
|
|
|
|
|
for run in /var/run/texlive/sync-updmap* ; do
|
|
|
|
test -e $run || break
|
|
|
|
type -p updmap-sys &> /dev/null || break
|
|
|
|
cfg=$(tcfmgr --cmd find --file updmap.cfg)
|
|
|
|
test -e $cfg || break
|
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Updating TeX font mappings."
|
|
|
|
updmap-sys --nohash --nomkmap --syncwithtrees < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
enablemaps $cfg < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
if test -e /var/run/texlive/run-mktexlsr ; then
|
|
|
|
updmap-sys < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
rm -f /var/run/texlive/run-mktexlsr*
|
2012-06-22 18:49:09 +02:00
|
|
|
else
|
2012-09-12 11:55:34 +02:00
|
|
|
updmap-sys --nohash < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
2012-06-22 18:49:09 +02:00
|
|
|
fi
|
2012-09-12 11:55:34 +02:00
|
|
|
# test $VERBOSE = true && echo
|
|
|
|
rm -f /var/run/texlive/sync-updmap*
|
|
|
|
rm -f /var/run/texlive/run-mktexlsr*
|
2012-06-22 18:49:09 +02:00
|
|
|
done
|
2012-09-12 11:55:34 +02:00
|
|
|
|
2012-06-22 18:28:48 +02:00
|
|
|
if test -x /usr/bin/mtxrun ; then
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Generate file database."
|
2012-06-22 18:28:48 +02:00
|
|
|
TEXMF=${TEXMFDIST} \
|
2012-06-22 18:51:59 +02:00
|
|
|
TEXMFCACHE=${TEXMFVAR} \
|
2012-06-22 18:28:48 +02:00
|
|
|
TEXMFCNF=${TEXMFCNFFILE%/*} \
|
|
|
|
/usr/bin/mtxrun --generate < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo
|
2012-06-22 18:28:48 +02:00
|
|
|
fi
|
2012-06-20 15:03:52 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# If texmf.cnf has changed it may contain changed memory sizes
|
|
|
|
# of various programs.
|
|
|
|
#
|
|
|
|
type -p texconfig-sys &> /dev/null || exit 0
|
|
|
|
|
|
|
|
#
|
|
|
|
# Configuration broken
|
|
|
|
#
|
2012-06-22 18:28:48 +02:00
|
|
|
if test ! -e "$TEXMFCNFFILE" ; then
|
2012-09-12 11:55:34 +02:00
|
|
|
echo "${0##*/}: Configuration of texlive installation not found." 1>&2
|
2012-06-20 15:03:52 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
init=false
|
|
|
|
for f in $(find ${WEB2C}/ -name '*.fmt' -name '*.mem' -o -name '*.base') ; do
|
|
|
|
test -e "$f" || continue
|
|
|
|
test -L "$f" && continue
|
2012-06-22 18:28:48 +02:00
|
|
|
test "$TEXMFCNFFILE" -nt "$f" && init=true
|
2012-06-20 15:03:52 +02:00
|
|
|
test -s "$f" && touch "$f"
|
|
|
|
done
|
|
|
|
if test $init = true ; then
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Initialize TeX configuration and font mappings."
|
2012-06-20 15:03:52 +02:00
|
|
|
updmap-sys --syncwithtrees < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
|
|
|
texconfig-sys init < /dev/null 1>&4 2>&4
|
|
|
|
let rc+=$?
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo
|
2012-06-20 15:03:52 +02:00
|
|
|
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
|
|
|
|
|
2012-06-25 14:09:44 +02:00
|
|
|
for cfg in ${cnf_mfont} ${cnf_xdvi} ${cnf_dvips} cups ; do
|
2012-06-20 15:03:52 +02:00
|
|
|
test -s ${OLDMD5DIR}${cfg} || continue
|
|
|
|
if test -e ${MD5DIR}${cfg} ; then
|
2012-06-25 14:09:44 +02:00
|
|
|
if test ${MD5DIR}${cfg} -nt ${OLDMD5DIR}${cfg} ; then
|
2012-06-20 15:03:52 +02:00
|
|
|
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=300
|
|
|
|
color=mono
|
|
|
|
IFS=$'\n'
|
|
|
|
lpopt=($(lpoptions -l 2> /dev/null))
|
|
|
|
IFS="$OLDIFS"
|
|
|
|
shopt -s extglob
|
|
|
|
for line in "${lpopt[@]}" ; do
|
|
|
|
case "$line" in
|
|
|
|
PageSize*)
|
|
|
|
set -- $line
|
|
|
|
while test -n "$1" ; do
|
|
|
|
case "$1" in
|
|
|
|
\**) size="${1:1}"; break
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
Resolution*)
|
|
|
|
set -- $line
|
|
|
|
reg='?(\*)@(+([0-9])|+([0-9])x+([0-9]))dpi'
|
|
|
|
cur=0
|
|
|
|
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
|
|
|
|
while test -n "$1" ; do
|
|
|
|
case "$1" in
|
|
|
|
\*RGB|\*CMYK) color=color; break
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
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
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Set MetaFont mode."
|
2012-06-20 15:03:52 +02:00
|
|
|
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}
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo
|
2012-06-20 15:03:52 +02:00
|
|
|
fi
|
|
|
|
if test $omd5xdvi = 0 -o \
|
|
|
|
\( $md5xdvi = $omd5xdvi -a "$prtcap_nt_xdvi" = "yes" -a "$md5_nt_xdvi" = "yes" \)
|
|
|
|
then
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Set XDvi paper size."
|
2012-06-20 15:03:52 +02:00
|
|
|
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}
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo
|
2012-06-20 15:03:52 +02:00
|
|
|
fi
|
|
|
|
if test $omd5dvips = 0 -o \
|
|
|
|
\( $md5dvips = $omd5dvips -a "$prtcap_nt_dvips" = "yes" -a "$md5_nt_dvips" = "yes" \)
|
|
|
|
then
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo -en "\r[ ]Set dvips mode and paper size."
|
2012-06-20 15:03:52 +02:00
|
|
|
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}
|
2012-06-25 14:09:44 +02:00
|
|
|
test $VERBOSE = true && echo
|
2012-06-20 15:03:52 +02:00
|
|
|
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
|