#
# postinst-texfonts
#
# postinst 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!

update_lsr_files ()
{
    tempfile=`mktemp -p /tmp mktexlsr.XXXXXXXX`
    echo -n "Running mktexlsr. This may take some time. ..."
    if mktexlsr > $tempfile 2>&1 ; then
        rm -f $tempfile
	echo " done."
    else
    	echo
	echo "mktexlsr failed. Output has been stored in"
	echo "$tempfile"
	echo "Please include this file if you report a bug."
	echo
	exit 1
    fi
}

create_fontmaps ()
{
    tempfile=`mktemp -p /tmp updmap.XXXXXXXX`
    echo -n "Running updmap-sys. This may take some time. ..."
    if updmap-sys > $tempfile 2>&1 ; then
    	rm -f $tempfile
	echo " done."
    else
    	echo
	echo "updmap failed. Output has been stored in"
	echo "$tempfile"
	echo "Please include this file if you report a bug."
	echo
	exit 1
    fi
}

case "$1" in
    configure|abort-upgrade|abort-remove|abort-deconfigure)
        update-updmap --quiet
	if which mktexlsr >/dev/null; then 
	    update_lsr_files
	fi
	if which updmap-sys >/dev/null; then
	    create_fontmaps
	fi
    ;;

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

