2 # Script to install a catalog in the centralized SGML catalog
3 # Send any comments to Eric Bischoff <eric@caldera.de>
4 # This program is under GPL license. See LICENSE file for details.
7 SGML_HELP_MESSAGE="Usage: `basename $0` [<option>] <action>\n\
9 \040 -d|--delegate: \t\t\t Use DELEGATE instead of CATALOG\n\
10 and where <action> is:\n\
11 \040 -a|--add <centralized> <ordinary>: \t Declare ordinary catalog in the centralized catalog\n\
12 \040 -r|--remove <centralized> <ordinary>:\t Remove ordinary catalog from the centralized catalog\n\
13 \040 -h, --help: \t\t\t\t Print this help message and exit\n\
14 \040 -v, --version: \t\t\t Print the version number and exit\n"
17 SGML_VERSION_MESSAGE="sgml-common version @VERSION@ (install-catalog version 1.0)"
20 SGML_POINTER="CATALOG"
22 # Set action to be performed
31 -d|--delegate) SGML_POINTER="DELEGATE"
38 -a|--add) SGML_ACTION="addition"
42 -r|--remove) if [ -z "$3" -o "$3" = "--version" ]
44 echo "install-catalog: Old syntax; doing nothing"
51 -h|--help) echo -e $SGML_HELP_MESSAGE
54 -v|--version) echo -e $SGML_VERSION_MESSAGE
57 --install) echo "install-catalog: Old syntax; doing nothing"
60 *) echo -e $SGML_HELP_MESSAGE >&2
65 # Check that the super catalog can be created and changed and deleted
68 echo "`basename $0`: unable to write in /etc/sgml." >&2
73 if [ -e /etc/sgml/catalog -a ! -w /etc/sgml/catalog ]
75 echo "`basename $0`: can not modify \"/etc/sgml/catalog\"." >&2
80 if [ ! -w /etc/sgml/catalog ]
82 echo "`basename $0`: can not modify \"/etc/sgml/catalog\"." >&2
88 # Check that the centralized catalog can be created, changed and deleted
89 if [ -z "$SGML_CENTRALIZED" ]
91 echo -e $SGML_HELP_MESSAGE >&2
96 if [ -e $SGML_CENTRALIZED -a ! -w $SGML_CENTRALIZED ]
98 echo "`basename $0`: can not modify \"$SGML_CENTRALIZED\"." >&2
103 if [ ! -w $SGML_CENTRALIZED ]
105 echo "`basename $0`: can not modify \"$SGML_CENTRALIZED\"." >&2
111 # Check that we have at least one ordinary package to process
112 if [ -z "$SGML_ORDINARY" ]
114 echo -e $SGML_HELP_MESSAGE >&2
119 if [ ! -s $SGML_ORDINARY ]
121 echo "`basename $0`: \"$SGML_ORDINARY\" does not exist or is empty." >&2
127 # Installation or removal of pointers
130 echo "`basename $0`: addition of $SGML_ORDINARY in $SGML_CENTRALIZED"
131 if grep -q $SGML_ORDINARY $SGML_CENTRALIZED 2>/dev/null
133 echo "Warning: $SGML_ORDINARY is already installed in the centralized catalog $SGML_CENTRALIZED" >&2
135 echo "$SGML_POINTER $SGML_ORDINARY" >> $SGML_CENTRALIZED
137 grep -q $SGML_CENTRALIZED /etc/sgml/catalog 2>/dev/null
140 echo "`basename $0`: addition of $SGML_CENTRALIZED in /etc/sgml/catalog"
141 echo "$SGML_POINTER $SGML_CENTRALIZED" >> /etc/sgml/catalog
145 echo "`basename $0`: removal of $SGML_ORDINARY from $SGML_CENTRALIZED"
146 if grep -q $SGML_ORDINARY $SGML_CENTRALIZED 2>/dev/null
148 sed -e "\:$SGML_POINTER $SGML_ORDINARY:d" < $SGML_CENTRALIZED > ${SGML_CENTRALIZED}.new
149 mv ${SGML_CENTRALIZED}.new $SGML_CENTRALIZED
151 echo "Warning: $SGML_ORDINARY was not found in the centralized catalog $SGML_CENTRALIZED" >&2
153 if [ ! -s $SGML_CENTRALIZED ]
156 echo "`basename $0`: removal of $SGML_CENTRALIZED from /etc/sgml/catalog"
157 sed -e "\:$SGML_POINTER $SGML_CENTRALIZED:d" < /etc/sgml/catalog > /etc/sgml/catalog.new
158 mv /etc/sgml/catalog.new /etc/sgml/catalog