1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
#!/bin/bash
# jadetex postinst
# jobs: texhash, remove old cruft we used to make, and run fmtutil
set -e
# clear environment
TETEXDIR=
TEXMF=
TEXINPUTS=
FMTDIR=/etc/texmf/fmt.d
TEMPLDIR=/usr/share/texmf/tex/jadetex/config-templates
umask 022
# emit a warning, generic routine
warn ( ) {
echo $* 1>&2
}
checkfmt ( ) {
format=$1
baseformat=`basename $1 .fmt`
if ! kpsewhich $format > /dev/null ; then
warn "WARNING: memory dump $format not found, attempting to reconstruct ..."
echo "running 'fmtutil --byfmt $baseformat'" >> $MYTMPFILE
fmtutil --byfmt $baseformat >> $MYTMPFILE
if kpsewhich $format > /dev/null ; then
warn " ok, reconstructed"
else
warn "ERROR: cannot create TeX memory dump $format"
warn " Your TeX environment seems to be broken; the memory dump file $format"
warn " was not found and cannot be created. Probably, TeX is miconfigured."
warn " You should submit the log file $MYTMPFILE as a bug against"
warn " the package tetex-bin."
warn
warn "JadeTeX cannot be installed."
exit 1
fi
fi
}
makejadetexfmt ( ) {
local goterror
goterror=false
if ! fmtutil --byfmt jadetex >> $MYTMPFILE
then
warn "ERROR: jadetex fmtutil failed" 1>&2
goterror=true
fi
if ! fmtutil --byfmt pdfjadetex >> $MYTMPFILE
then
warn "ERROR: pdfjadetex fmtutil failed" 1>&2
goterror=true
fi
if $goterror; then
return 1
else
return 0
fi
}
jadetexfmtcheck ( ) {
# check whether it actually worked, since the texconfig program
# doesn't exit non-zero
# file exists test
local goterror
goterror=false
if ! kpsewhich jadetex.fmt > /dev/null ; then
warn "ERROR: JadeTeX memory dump (jadetex.fmt) cannot be found"
goterror=true
fi
if ! kpsewhich pdfjadetex.fmt > /dev/null ; then
warn "ERROR: PDFJadeTeX memory dump (pdfjadetex.fmt) cannot be found"
goterror=true
fi
if $goterror; then
return -1
else
return 0
fi
}
if [ "$1" = "configure" ]; then
# old crufty stuff we used to build in postinst - I wonder whether we
# should actually do this in preinst?
if [ -L /usr/lib/texmf/tex/jadetex/config ]; then
warn "removing old JadeTeX config symlink"
rm /usr/lib/texmf/tex/jadetex/config
fi
if [ -d /usr/lib/texmf/tex/jadetex ]; then
rmdir /usr/lib/texmf/tex/jadetex || \
warn "unused, obsolete dir /usr/lib/texmf/tex/jadetex, remove it yourself if you care"
fi
texhash
# new fmt.d handling; we have to handle this in postinst rather
# than conffiles so that we can disable it when pkg is removed
#
# first we check if the file or any jadetex.cnf file is already there,
# if not, is there is a disabled version of the script available?
# if not, is there a globbed version of the disabled file available?
# if not, copy in the file from the template area
if [ -f ${FMTDIR}/40jadetex.cnf ] ||
ls ${FMTDIR}/*jadetex.cnf 2>/dev/null; then
:
elif [ -f ${FMTDIR}/40jadetex.cnf.disable ]; then
mv ${FMTDIR}/40jadetex.cnf.disable ${FMTDIR}/40jadetex.cnf
else
OLD=`ls -1 ${FMTDIR}/*jadetex.cnf* 2>/dev/null | tail -1`
if [ ${OLD} -a -f ${OLD} ]; then
NEW=`echo $OLD | sed -e 's/.cnf.*/.cnf/'`
mv ${OLD} ${NEW}
else
cp ${TEMPLDIR}/fmtutil.cnf ${FMTDIR}/40jadetex.cnf
fi
fi
update-fmtutil
MYTMPFILE=`mktemp /tmp/jadetex-postinst.XXXXXX`
: > $MYTMPFILE
echo "Checking for TeX memory dumps (.fmt) ..."
checkfmt latex.fmt
checkfmt pdftex.fmt
checkfmt pdflatex.fmt
echo " done."
echo "Creating JadeTeX memory dumps ..."
if makejadetexfmt && jadetexfmtcheck; then
echo " done."
else
warn " failed."
echo "Desperate measures: running 'fmtutil --all' to rebuild existing TeX"
echo " memory dumps ..."
fmtutil --all >> $MYTMPFILE
echo " done."
echo "Re-checking for JadeTeX memory dumps ..."
if jadetexfmtcheck; then
echo " done."
else
warn "ERROR: JadeTeX/PDFJadeTeX memory dump not found"
warn " This package could not be installed."
warn " Please report this bug; include tetex* package version"
warn " numbers and the file $MYTMPFILE in the bug report."
exit 1
fi
fi
# remove temp file
rm -f $MYTMPFILE
fi
#DEBHELPER#
exit 0
|