void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

xml-catalog (1789B)


      1#!/bin/sh
      2#
      3# Registers or unregisters SGML/XML catalog entries, through
      4# the xmlcatmgr application.
      5#
      6# Arguments:	$ACTION = [run/targets]
      7#		$TARGET = [post-install/pre-remove]
      8#		$PKGNAME
      9#		$VERSION
     10#		$UPDATE = [yes/no]
     11#
     12ACTION="$1"
     13TARGET="$2"
     14PKGNAME="$3"
     15VERSION="$4"
     16UPDATE="$5"
     17
     18sgml_catalog=usr/share/sgml/catalog
     19xml_catalog=usr/share/xml/catalog
     20
     21xmlcatmgr=usr/bin/xmlcatmgr
     22
     23register_entries()
     24{
     25	if [ -n "${sgml_entries}" ]; then
     26		echo -n "Registering SGML catalog entries... "
     27		set -- ${sgml_entries}
     28		while [ $# -gt 0 ]; do
     29			$xmlcatmgr -sc ${sgml_catalog} add "$1" "$2" "$3"
     30			shift; shift; shift;
     31		done
     32		echo "done."
     33	fi
     34
     35	if [ -n "${xml_entries}" ]; then
     36		echo -n "Registering XML catalog entries... "
     37		set -- ${xml_entries}
     38		while [ $# -gt 0 ]; do
     39			$xmlcatmgr -c ${xml_catalog} add "$1" "$2" "$3"
     40			shift; shift; shift;
     41		done
     42		echo "done."
     43	fi
     44}
     45
     46unregister_entries()
     47{
     48	if [ -n "${sgml_entries}" ]; then
     49		echo -n "Unregistering SGML catalog entries... "
     50		set -- ${sgml_entries}
     51		while [ $# -gt 0 ]; do
     52			$xmlcatmgr -sc ${sgml_catalog} remove "$1" "$2" \
     53				2>/dev/null
     54			shift; shift; shift
     55		done
     56		echo "done."
     57	fi
     58	if [ -n "${xml_entries}" ]; then
     59		echo -n "Unregistering XML catalog entries... "
     60		set -- ${xml_entries}
     61		while [ $# -gt 0 ]; do
     62			$xmlcatmgr -c ${xml_catalog} remove "$1" "$2" \
     63				2>/dev/null
     64			shift; shift; shift
     65		done
     66		echo "done."
     67	fi
     68}
     69
     70case "$ACTION" in
     71targets)
     72	echo "post-install pre-remove"
     73	;;
     74run)
     75	[ ! -x $xmlcatmgr ] && exit 0
     76	[ -n "${sgml_entries}" -a ! -f "${sgml_catalog}" ] && exit 0
     77	[ -n "${xml_entries}" -a ! -f "${xml_catalog}" ] && exit 0
     78
     79	case "$TARGET" in
     80	post-install)
     81		register_entries
     82		;;
     83	pre-remove)
     84		unregister_entries
     85		;;
     86	*)
     87		exit 1
     88		;;
     89	esac
     90	;;
     91*)
     92	exit 1
     93	;;
     94esac
     95
     96exit 0