#!/bin/sh -e

workdir=debian/tetex-bin/usr/share/tetex-bin/
exitcode=0
needed_files="05TeXMF 15Plain 45TeXinputs 55Fonts \
   65BibTeX 75DviPS 85Misc 90TeXDoc 95NonPath"



oldpwd=`pwd`
cd $workdir

for file in $needed_files; do
  # get new md5sum
  newsum=`md5sum $file.cnf | cut -d ' ' -f1`
  found=false

  # get list of old md5sums (together with versions)
  list=`cat $file.cnf.md5sum`
  set $list

  while [ $# -gt 1 ]; do
    oldsum="$1"
    if [ "$newsum" = "$oldsum" ]; then found=true; fi
    shift 2
  done
done

if [ "$found" = false ]; then
  exitcode=1
  echo "md5sum of $file.cnf has changed, new md5sum is:"
  echo $newsum
  echo
fi

cd $oldpwd
exit $exitcode

