#!/bin/sh
# 
# Script to remove unused conffiles from /etc/texmf/dvips
# 
# In previous versions, font map files were treated as configuration
# files by the teTeX packages and therefore installed in /etc/texmf
# (some were handled using ucf). In fact, however, these files hardly
# ever need to be edited. (Indeed it is much more likely that there is
# an error in the *.sty or *fd files). Therefore, these files are now
# installed in the usual TEXMF tree.
# 
# Since they formally were conffiles previously, dpkg treats them
# specially: They will not be altered or removed when the package is
# updated. The purpose of this is to keep any local configuration
# changes - even if the files are no longer used, the changes therein
# can be taken as a model for new changes elsewhere. In our case,
# however, it also results in lots of unused files that probably were
# never changed.
# 
# If you want, you can remove these files - it will not affect tetex's
# behavior at all. You can do this manually, or let this script do the
# work for you. When working manually, note that there are still some
# files left in /etc/texmf/dvips: Files with other extensions than "map"
# as well as map files from other packages, and generated map files.
# 

DVIPS=/etc/texmf/dvips

ANTP="config.antp antp.map antp.enc"
ANTT="config.antt antt.map antt.enc"
BLUESKY="psfonts.ams psfonts.cm psfonts.amz psfonts.cmz"
CCPL="ccpl.map"
LUCIDA="lucidabr-k.map lucidabr.map lumath-k.map lumath.map"
PSNFSS="charter.map pazo.map psnfss.map"
MISC="cmcyr.map mathpi.map cs.map config.mirr marvosym.map pcrr8rn.map wolfram.map"
EXTRAMISC="eurosym.map"
TETEX="hoekwater.map mt-yy.map txfonts.map lucidabr-o.map pdftex35.map mathpple.map \
  ps2pk35.map mt-belleek.map pxfonts.map dvips35.map mt-plus.map ttcmex.map \
  dvipdfm35.map lumath-o.map"
PL="config.pl pl.map"
QFNT="config.qbk config.qpl config.qzc config.qcr config.qhv config.qtm qbk.map qcr.map qhv.map qpl.map qtm.map qzc.map"
XYPIC="xypic.map"

OMEGA_UCF="omega.map"
BSRTETEX_UCF="bsr-interpolated.map bsr.map"

# from tetex-1.x
oldfiles='antp.cfg
antt.cfg
ar-ext-adobe-bi.map
ar-ext-adobe-kb.map
ar-ext-urw-kb.map
ar-ext-urw-urw.map
ar-std-adobe-bi.map
ar-std-adobe-kb.map
ar-std-urw-kb.map
ar-std-urw-urw.map
bakoma-extra.map
config.qf
lw35extra-adobe-bi.map
lw35extra-adobe-kb.map
lw35extra-urw-kb.map
lw35extra-urw-urw.map
mathpple-ext.map
mtsupp-ext-adobe-bi.map
mtsupp-ext-adobe-kb.map
mtsupp-ext-urw-kb.map
mtsupp-ext-urw-urw.map
mtsupp-std-adobe-bi.map
mtsupp-std-adobe-kb.map
mtsupp-std-urw-kb.map
mtsupp-std-urw-urw.map
pl.cfg
raw-ar-ext-adobe-bi.map
raw-ar-ext-adobe-kb.map
raw-ar-ext-urw-kb.map
raw-ar-ext-urw-urw.map
raw-ar-std-adobe-bi.map
raw-ar-std-adobe-kb.map
raw-ar-std-urw-kb.map
raw-ar-std-urw-urw.map
raw-lw35extra-adobe-bi.map
raw-lw35extra-adobe-kb.map
raw-lw35extra-urw-kb.map
raw-lw35extra-urw-urw.map
utopia.map'

# generated files and links are still needed, but will probably 
# be moved to VARTEXMF
generated="download35.map builtin35.map psfonts_t1.map psfonts_pk.map pdftex_dl14.map pdftex_ndl14.map dvipdfm_dl14.map dvipdfm_ndl14.map ps2pk.map"

generated_links="dvipdfm.map pdftex.map psfonts.map"

for oldmap in $ANTP $ANTT $BLUESKY $CCPL $LUCIDA $PSNFSS \
  $MISC $EXTRAMISC $TETEX $PL $QFNT $XYPIC $OMEGA_UCF $BSRTETEX_UCF $oldfiles; do
#   $generated $oldfiles; do
  file=$DVIPS/$oldmap
  if [ -e $file -a ! -L $file ]; then rm $file; fi
done

# for oldlink in $generated_links; do
#   file=$DVIPS/$oldlink
#   if [ -L $file -a ! -f "`readlink $file`" ]; then rm $file; fi
# done

