#!/bin/sh

PACKAGE=linuxdoc-tools
CENTRALCAT=/etc/sgml/${PACKAGE}.cat

# for FHS transition
INFODIR=/usr/share/info
FHSDOC=/usr/share/doc/${PACKAGE}
OLDDOC=/usr/doc/${PACKAGE}

set -e

case $1 in

    configure)

       # for FHS transition: create the link from FSSTND Doc Dir
       if [ -d /usr/doc -a ! -e ${OLDDOC} -a -d ${FHSDOC} ]; then
         ln -sf ../share/doc/${PACKAGE} /usr/doc/${PACKAGE}
       fi

       install-info --quiet --section \
         "Document Preparation" "Document Preparation" \
          --description="Linux Documentation Project SGML tools" \
          ${INFODIR}/linuxdoc-sgml.info.gz

	# remove old sgml catalog
       install-sgmlcatalog --quiet --remove $PACKAGE

	# add new sgml catalog
	update-catalog --quiet --add ${CENTRALCAT} \
	  /usr/share/linuxdoc-tools/linuxdoc-tools.catalog
	# add central catalog to the super catalog
	update-catalog --quiet --add --super ${CENTRALCAT}

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

       if command -v install-docs >/dev/null 2>&1; then
         install-docs -i /usr/share/doc-base/linuxdoc-tools
       fi

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

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

exit 0

