#!/bin/sh

PACKAGE=linuxdoc-tools

set -e

case "$1" in
    remove|upgrade|deconfigure)

	# for FHS transition: remove the link from FSSTND Doc Dir
	if [ -L /usr/doc/${PACKAGE} ]; then
	  rm -f /usr/doc/${PACKAGE}
	fi

        install-info --quiet --remove linuxdoc-sgml

        if ! install-sgmlcatalog --quiet --remove $PACKAGE
          then
            echo "$0: install-sgmlcatlog failed
  There maybe linuxdoc-tools SGML CATALOG ENTRY left over in /etc/sgml.catalog.
  Please manually edit that file, or rm it if you don't need it." 1>&2
        fi

        # older versions installed into /usr/lib/texmf/tex/latex/
        for file in linuxdoc-sgml.sty qwertz.sty null.sty
          do
             rm -f /usr/lib/texmf/tex/latex/$file
             rm -f /usr/lib/texmf/tex/latex/misc/$file
          done

        # Now installed in /usr/share/texmf
        for file in linuxdoc-sgml.sty qwertz.sty null.sty
          do
             rm -f /usr/share/texmf/tex/latex/$file
             rm -f /usr/share/texmf/tex/latex/misc/$file
          done

        if [ -x /usr/bin/texhash ]; then
            /usr/bin/texhash
        fi

        if command -v install-docs >/dev/null 2>&1; then
          install-docs -r linuxdoc-tools
        fi

        ;;
    failed-upgrade)
        ;;
    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

exit 0

