#!/bin/sh
# This script will create the docbook-xsl catalog and will add entries to xml catalog.
# WARNING: If you change this script, be sure to check pkg-deinstall.in!
#
# Based on http://xmlsoft.org/buildDocBookCatalog file.
#
# Run the following command to generate a new VERSIONS string:
# perl -n -e '/Version ([\d.]+) rel/ && print "$1\n"' work/*/ChangeLog |
#     sort -n | tr '\n' ' '
#
# -- Rui Lopes <rui@ruilopes.com>

XSL_DIR=${PKG_PREFIX}/share/xsl/docbook
CATALOG_XSL=${XSL_DIR}/catalog.xml

if [ "$2" != "POST-INSTALL" ]; then
	exit 0
fi

test -r "${CATALOG_XSL}" || {
    echo >&2 "Cannot register non-existent catalog ${CATALOG_XSL}"
    exit 1
}
/usr/local/bin/xmlcatmgr -c /usr/local/share/xml/catalog.ports add delegateSystem \
	http://docbook.sourceforge.net/release/xsl/ \
	"file://${CATALOG_XSL}"
/usr/local/bin/xmlcatmgr -c /usr/local/share/xml/catalog.ports add delegateURI \
	http://docbook.sourceforge.net/release/xsl/ \
	"file://${CATALOG_XSL}"
exit 0
