#
# postrm-texfonts
#
# postrm snippets for installing fonts for TeX
#
# Authors: 
#	Florent Rougon <f.rougon@free.fr>
#	Norbert Preining <preining@logic.at>
#
# Please note that comments in this file are stripped before installation
# by calling a grep -v '^[ \t]*#'
# So please be careful if you add stuff here!

# The function name is check_run_without_erros because the following
# scenario might happen:
#    1. this package is deconfigured
#    2. tex-common and tetex-bin are removed
#    3. this package is removed or purged
#
# (cf. Policy  6.5, step 2, about a conflicting package being removed due
# to the installation of the package being discussed).
#
check_run_without_errors ()
{
    tempfile=`mktemp -p /tmp checkrun.XXXXXXXX`
    if which $1  >/dev/null; then
        echo -n "Running $*. This may take some time. ..."
	set +e
	if $* > $tempfile 2>&1 ; then
	    rm -f $tempfile
	    echo " done."
	else
	    echo
	    echo "$* failed. Output has been stored in"
	    echo "$tempfile"
	    echo "If tex-common is not configured you can ignore this error message!"
	    echo "Otherwise please include this file if you report a bug."
	    echo
	fi
	set -e
    else
        rm -f $tempfile
    fi
    return 0
}


case "$1" in
    remove|disappear)
        check_run_without_errors update-updmap --quiet
	check_run_without_errors mktexlsr
	check_run_without_errors updmap-sys
    ;;

    purge|upgrade|failed-upgrade|abort-upgrade|abort-install)
    ;;

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


