Summary: Common SGML catalog and DTD files Name: sgml-common Packager: rosalia@cygnus.com %define version 0.1 %define release 3 version: %{version} release: %{release} Vendor: Cygnus Solutions Distribution: Cygnus UNSUPPORTED Internal SGML Tools # Source: ftp://ftp.ifi.uio.no/pub/SGML/ENTITIES.tgz Source: sgml-common.tgz Copyright: (C) International Organization for Standardization 1986 Group: Utilities/Text BuildRoot: /tmp/sgmlroot %define sgmlbase /usr %description sgml-common is a collection of entities and dtds that are useful for SGML processing, but shouldn't need to be included in multiple packages. It also includes an up-to-date Open Catalog file. %prep %setup -c %build gawk --posix '/Typical invocation:/,/\-\-\>/ { print }' sgml-common/* | gawk --posix '/PUBLIC/ { sys=$3 } /8879:1986.*\"\>/ { saveline=""; print "PUBLIC " $0 " " sys; next } /8879:1986[^>]*$/ { saveline = $0; next } /\"\>/ { print "PUBLIC " saveline $0 " " sys; saveline="";next } ' | sed 's/\">/\"/' > newcat cat > install-catalog << '__EOF__' #!/bin/sh set -e sgmlbase=%{sgmlbase}/lib/sgml state="" package="" version="" for i in $*; do case $state in "") case $i in --install) state="--install" ; action="install";; --remove) state="--remove" ; action="remove";; --sgmlbase) state="--sgmlbase" ;; --version) state="--version" ;; *) cat <<__USAGE__ Usage: --install pkg: installs pkg.cat in CATALOG --remove pkg: removes pkg.cat from CATALOG --version ver: qualify version of package --sgmlbase path: changes directory for pkg.cat and CATALOG __USAGE__ exit 0 ;; esac ;; --install) state="" ; package=$i ;; --remove) state="" ; package=$i ;; --sgmlbase) state="" ; sgmlbase=$i;; --version) state="" ; version=$i ;; esac done echo "install-catalog: $action of $package DTD" cat=$sgmlbase/CATALOG SBEG=" -- start $package $version" SEND=" -- end $package $version" case $action in install) if grep "$SBEG" $cat > /dev/null 2>/dev/null then echo "$package DTD already in catalog" else echo "adding $package DTD to catalog" (echo "$SBEG -- "; cat $sgmlbase/$package.cat ; echo "$SEND -- ") >> $cat fi ;; remove) if grep -q "$SBEG" $cat then echo "removing $package$version DTD from catalog" sed -e "/$SBEG/,/$SEND/d" < $cat > ${cat}.new mv ${cat}.new ${cat} else echo "No $package$version DTD found in catalog" fi ;; *) echo "install-catalog: Invalid action $action"; exit 1 ;; esac __EOF__ chmod +x install-catalog %install mkdir -p $RPM_BUILD_ROOT%{sgmlbase}/lib/sgml install sgml-common/* $RPM_BUILD_ROOT%{sgmlbase}/lib/sgml install newcat $RPM_BUILD_ROOT%{sgmlbase}/lib/sgml/sgml-common.cat mkdir -p $RPM_BUILD_ROOT/%{sgmlbase}/bin cp install-catalog $RPM_BUILD_ROOT/%{sgmlbase}/bin %post touch %{sgmlbase}/lib/sgml/CATALOG # since old-postun is run *after* new-post, we must always cycle. V=%{version}-%{release} %{sgmlbase}/bin/install-catalog --install sgml-common --version $V %postun # since old-postun is run *after* new-post, we must always cycle. V=%{version}-%{release} %{sgmlbase}/bin/install-catalog --remove sgml-common --version $V %files %{sgmlbase}/lib/sgml/* %{sgmlbase}/bin/install-catalog