#!/bin/sh

PATH=/bin:/usr/bin:%%LOCALBASE%%/bin

export PATH
XMLCATMGR=%%XMLCATMGR%%
CATALOG_MASTER_SGML=%%CATALOG_MASTER_SGML%%
CATALOG_MASTER_XML=%%CATALOG_MASTER_XML%%
CATALOG_PORTS_SGML=%%CATALOG_PORTS_SGML%%
CATALOG_PORTS_XML=%%CATALOG_PORTS_XML%%

case $2 in
DEINSTALL)

T=/tmp/catalog.$$

${XMLCATMGR} -sc ${CATALOG_MASTER_SGML} remove CATALOG catalog.ports
${XMLCATMGR} -sc ${T} create
if cmp -s ${T} ${CATALOG_MASTER_SGML}; then
	echo " + Removing ${CATALOG_MASTER_SGML}.  It is empty."
	rm -f ${CATALOG_MASTER_SGML}
fi
if cmp -s ${T} ${CATALOG_PORTS_SGML}; then
	echo " + Removing ${CATALOG_PORTS_SGML}.  It is empty."
	rm -f ${CATALOG_PORTS_SGML}
fi
rm -f ${T}

${XMLCATMGR} -c ${CATALOG_MASTER_XML} remove nextCatalog ${CATALOG_PORTS_XML}
${XMLCATMGR} -c ${T} create
if cmp -s ${T} ${CATALOG_MASTER_XML}; then
	echo " + Removing ${CATALOG_MASTER_XML}.  It is empty."
	rm -f ${CATALOG_MASTER_XML}
fi
if cmp -s ${T} ${CATALOG_PORTS_XML}; then
	echo " + Removing ${CATALOG_PORTS_XML}.  It is empty."
	rm -f ${CATALOG_PORTS_XML}
fi
rm -f ${T}
;;
esac
