post_install() {
	echo "updating the filename database..."
	mktexlsr > /dev/null 2>&1
	echo " done."
        echo "creating missing formats..."
	sed -i "s/^#ptex ptex - ptex.ini/ptex ptex - ptex.ini/" /usr/share/texmf-dist/web2c/fmtutil.cnf
	sed -i "s/^#eptex eptex/eptex eptex/" /usr/share/texmf-dist/web2c/fmtutil.cnf
	sed -i "s/^#platex eptex/platex eptex/" /usr/share/texmf-dist/web2c/fmtutil.cnf
	fmtutil-sys --missing > /dev/null 2>&1
	texlinks -f /usr/share/texmf-dist/web2c/fmtutil.cnf /usr/bin/ > /dev/null 2>&1
	echo " done."
}

pre_remove() {
	sed -i "s/^ptex ptex - ptex.ini/#ptex ptex - ptex.ini/" /usr/share/texmf-dist/web2c/fmtutil.cnf
	sed -i "s/^eptex eptex/#eptex eptex/" /usr/share/texmf-dist/web2c/fmtutil.cnf
	sed -i "s/^platex eptex/#platex eptex/" /usr/share/texmf-dist/web2c/fmtutil.cnf
}

op=$1
shift

$op $*
