118 kx #!/bin/sh
118 kx
118 kx # Preserve new files
118 kx install_file() {
118 kx NEW="$1"
118 kx OLD="`dirname $NEW`/`basename $NEW .new`"
118 kx # If there's no file by that name, mv it over:
118 kx if [ ! -r $OLD ]; then
118 kx mv $NEW $OLD
118 kx elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
118 kx rm $NEW
118 kx fi
118 kx # Otherwise, we leave the .new copy for the admin to consider...
118 kx }
118 kx
118 kx install_catalog() {
118 kx centralized=$1
118 kx ordinary=$2
118 kx if ! grep -q "$ordinary" "$centralized" 2>/dev/null ; then
118 kx echo "CATALOG \"/$ordinary\"" >> "$centralized"
118 kx fi
118 kx grep -q "$centralized" etc/sgml/catalog 2>/dev/null
118 kx if [ $? -ne 0 ] ; then
118 kx echo "CATALOG \"/$centralized\"" >> etc/sgml/catalog
118 kx fi
118 kx }
118 kx
118 kx remove_catalog() {
118 kx centralized=$1
118 kx ordinary=$2
118 kx if grep -q "$ordinary" "$centralized" 2>/dev/null ; then
118 kx sed -e "\:CATALOG \"\\?/$ordinary\"\\?:d" < "$centralized" > "${centralized}.new"
118 kx mv "${centralized}.new" "$centralized"
118 kx fi
118 kx if [ ! -s "$centralized" ] ; then
118 kx rm "$centralized"
118 kx sed -e "\:CATALOG \"\\?/$centralized\"\\?:d" < etc/sgml/catalog > etc/sgml/catalog.new
118 kx mv etc/sgml/catalog.new etc/sgml/catalog
118 kx fi
118 kx }
118 kx
118 kx
118 kx # arg 1: the new package version
118 kx pre_install() {
118 kx /bin/true
118 kx }
118 kx
118 kx # arg 1: the new package version
118 kx post_install() {
118 kx install_catalog etc/sgml/sgml-ent.cat usr/share/sgml/sgml-iso-entities-8879.1986/catalog
118 kx install_catalog etc/sgml/sgml-docbook.cat etc/sgml/sgml-ent.cat
118 kx }
118 kx
118 kx # arg 1: the new package version
118 kx # arg 2: the old package version
118 kx pre_update() {
118 kx remove_catalog etc/sgml/sgml-docbook.cat etc/sgml/sgml-ent.cat
118 kx remove_catalog etc/sgml/sgml-ent.cat usr/share/sgml/sgml-iso-entities-8879.1986/catalog
118 kx }
118 kx
118 kx # arg 1: the new package version
118 kx # arg 2: the old package version
118 kx post_update() {
118 kx post_install
118 kx }
118 kx
118 kx # arg 1: the old package version
118 kx pre_remove() {
118 kx remove_catalog etc/sgml/sgml-docbook.cat etc/sgml/sgml-ent.cat
118 kx remove_catalog etc/sgml/sgml-ent.cat usr/share/sgml/sgml-iso-entities-8879.1986/catalog
118 kx }
118 kx
118 kx # arg 1: the old package version
118 kx post_remove() {
118 kx /bin/true
118 kx }
118 kx
118 kx
118 kx operation=$1
118 kx shift
118 kx
118 kx $operation $*