#!/bin/sh
# update-texmf
# License: GPL

if [ -f /etc/texmf/texmf.d/05TeXMF ] ; then
CNFFILES=`/bin/ls -1 /etc/texmf/texmf.d/* | egrep -v "(.dpkg-[a-z]*|~|.bak)$"`
else
echo "Something seems wrong."
exit 1
fi
CNFDIR=/etc/texmf

if [ "x$1" = "x-v" ]; then
  VERBOSE=true
fi

if [ "$VERBOSE" = "true" ]; then
  if [ -f "$CNFDIR/texmf.cnf" ]; then
    echo -n "Regenerating $CNFDIR/texmf.cnf ... " >&2
  else
    echo -n "Generating $CNFDIR/texmf.cnf ... " >&2
  fi
fi

(echo "%%% This file is automatically generated by update-texmf"; \
echo "%"; \
echo "% Please do not edit this file directly. If you want to change or add"; \
echo "% anything please take a look at the files in /etc/texmf/texmf.d, and"; \
echo "% invoke update-texmf."; \
echo "%"; \
echo "%%%" ) > ${CNFDIR}/texmf.cnf_$$

cat ${CNFFILES} >> ${CNFDIR}/texmf.cnf_$$
mv ${CNFDIR}/texmf.cnf_$$ ${CNFDIR}/texmf.cnf

if [ "$VERBOSE" = "true" ]; then
  echo "done"
fi
