#
# remove old diversion
#

# needed in case there is no diversion from luatex, and grep will return 1
# we could test for exit value of >=2 which is an error (1 is being
# no match present), too.
set +e

# remove all diversions from texdoc
# code from amule.preinst
DIVERSIONS=`env LC_ALL=C /usr/sbin/dpkg-divert --list | grep -E 'by luatex$'`
set -e

if [ -n "$DIVERSIONS" ] ; then
  echo "$DIVERSIONS" | while read diversion of FILE to DIVERTED by PACKAGE; do
    dpkg-divert --package "$PACKAGE" --remove --rename "$FILE"
  done
fi

#dpkg-divert --remove --package luatex --rename \
#      --divert /usr/bin/texdoc.notluatex /usr/bin/texdoc
#dpkg-divert --remove --package luatex --rename \
#      --divert /usr/share/man/man1/texdoc.notluatex.1.gz \
#      /usr/share/man/man1/texdoc.1.gz


