#!/bin/sh # update-texmf # License: GPL set -e TXMF=/etc/texmf TXMF_CNF=$TXMF/web2c/texmf.cnf CNFDIR=${TXMF}/texmf.d TMPDIR=`mktemp -d` TMPTXMF=`mktemp -p ${TMPDIR} texmfXXXXXXX` VERBOSE=false DEBUG=false while [ $# -ne 0 ]; do case $1 in -v|--verbose) VERBOSE=true shift;; -d|--debug) DEBUG=true VERBOSE=true shift;; -o|--output) shift TXMF_CNF="$1" shift;; *) echo "unknown option: $1" exit 1 ;; esac done # test wether destinatio is read-only DESTDIR=$(dirname "$TXMF_CNF") mkdir -p "$DESTDIR" if touch "$DESTDIR/is_rw" 2>/dev/null; then rm -f "$DESTDIR/is_rw" else echo "Directory \"$DESTDIR\" not writeable. Exiting." exit 1 fi CNFFILES=`find ${CNFDIR} -name \*.cnf -print | sort` if [ $DEBUG = true ]; then echo "Using the following files:" for file in $CNFFILES; do echo $file done fi if [ -z "$CNFFILES" ] ; then # no config files are found, remove texmf.cnf if it is there if [ -f "$TXMF_CNF" ] ; then rm "$TXMF_CNF" fi exit 0 fi if [ "${VERBOSE}" = "true" ]; then if [ -f "${TXMF_CNF}" ]; then echo -n "Merging information from /etc/texmf/texmf.d/ into ${TXMF_CNF} ... " >&2 else echo -n "Generating ${TXMF_CNF} ... " >&2 fi fi cat > ${TMPTXMF} <&2 echo "%%% IGNORED: $i" >> ${TMPTXMF} continue fi echo "%%% From file: $i" >> ${TMPTXMF} cat $i >> ${TMPTXMF} echo "%%% End of file: $i" >> ${TMPTXMF} done cp ${TMPTXMF} ${TXMF_CNF} rm -r ${TMPDIR} chmod 644 ${TXMF_CNF} if [ "${VERBOSE}" = "true" ]; then echo "done" fi # # Let vim know that we don't want tabs # vim:set expandtab: #