blob: 50a6726ef5527ea29edd43538fc70a5b8e034fa5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
#!/bin/bash
# Copyright (C) 2002 by SuSE Linux AG.
# Author: Karl Eichwalder <ke@suse.de>, 2002.
# This program is under GPL license. See COPYING file for details.
# In part based on a script by Eric Bischoff <eric@caldera.de>
# Set help message
SGML_HELP_MESSAGE="Usage: `basename $0` [<option>] <action>\n\
where <option> is:\n\
-d, --delegate Use DELEGATE instead of CATALOG\n\
and where <action> is:\n\
-a, --add <CATALOG> Declare ordinary catalog in the centralized catalog\n\
-r, --remove <CATALOG> Remove ordinary catalog from the centralized catalog\n\
-h, --help Print this help message and exit\n\
-v, --version Print the version number and exit\n"
# Set version message
SGML_VERSION_MESSAGE="${0##*/} (sgml-skel version 0.6)"
# Set type of pointer
SGML_POINTER="CATALOG"
# Set action to be performed
SGML_ACTION=""
# Set catalogs
# SGML_CENTRALIZED=""
SGML_ORDINARY=""
# Process options
case $1 in
-d|--delegate) SGML_POINTER="DELEGATE"; shift 1 ;;
esac
# Process actions
case $1 in
-a|--add) SGML_ACTION="addition"
# SGML_CENTRALIZED=$2
SGML_ORDINARY=$2 ;;
-r|--remove) SGML_ACTION="removal"
# SGML_CENTRALIZED=$2
SGML_ORDINARY=$2 ;;
-h|--help) echo -e $SGML_HELP_MESSAGE ; exit 0 ;;
-v|--version) echo -e $SGML_VERSION_MESSAGE ; exit 0 ;;
*) echo -e $SGML_HELP_MESSAGE >&2 ; exit 1 ;;
esac
# Check that the super catalog can be created and changed and deleted
if [ ! -w /etc/sgml ]; then
echo "`basename $0`: unable to write in /etc/sgml." >&2
exit 2
fi
case $SGML_ACTION in
addition)
if [ -e /etc/sgml/catalog -a ! -w /etc/sgml/catalog ]; then
echo "`basename $0`: can not modify \"/etc/sgml/catalog\"." >&2
exit 2
fi
;;
removal)
if [ ! -w /etc/sgml/catalog ]; then
echo "`basename $0`: can not modify \"/etc/sgml/catalog\"." >&2
exit 2
fi
;;
esac
# # Check that the centralized catalog can be created, changed and deleted
# if [ -z "$SGML_CENTRALIZED" ]
# then
# echo -e $SGML_HELP_MESSAGE >&2
# exit 1
# fi
# case $SGML_ACTION in
# addition)
# if [ -e $SGML_CENTRALIZED -a ! -w $SGML_CENTRALIZED ]
# then
# echo "`basename $0`: can not modify \"$SGML_CENTRALIZED\"." >&2
# exit 2
# fi
# ;;
# removal)
# if [ ! -w $SGML_CENTRALIZED ]
# then
# echo "`basename $0`: can not modify \"$SGML_CENTRALIZED\"." >&2
# exit 2
# fi
# ;;
# esac
# Check that we have at least one ordinary package to process
if [ -z "$SGML_ORDINARY" ]; then
echo -e $SGML_HELP_MESSAGE >&2 ; exit 1
fi
case $SGML_ACTION in
addition)
if [ ! -s $SGML_ORDINARY ]; then
echo "`basename $0`: \"$SGML_ORDINARY\" does not exist or is empty." >&2
exit 2
fi
;;
esac
# Installation or removal of pointers
case $SGML_ACTION in
addition)
# echo "`basename $0`: addition of $SGML_ORDINARY in $SGML_CENTRALIZED"
# if grep -q $SGML_ORDINARY $SGML_CENTRALIZED 2>/dev/null
# then
# echo "Warning: $SGML_ORDINARY is already installed in the centralized catalog $SGML_CENTRALIZED" >&2
# else
# echo "$SGML_POINTER $SGML_ORDINARY" >> $SGML_CENTRALIZED
# fi
grep -q -e "\<$SGML_ORDINARY\>" /etc/sgml/catalog 2>/dev/null
if [ $? -ne 0 ]; then
echo "`basename $0`: addition of $SGML_ORDINARY in /etc/sgml/catalog"
echo "$SGML_POINTER \"$SGML_ORDINARY\"" >> /etc/sgml/catalog
fi
;;
removal)
# echo "`basename $0`: removal of $SGML_ORDINARY from $SGML_CENTRALIZED"
# if grep -q $SGML_ORDINARY $SGML_CENTRALIZED 2>/dev/null
# then
# sed -e "\:$SGML_POINTER $SGML_ORDINARY:d" < $SGML_CENTRALIZED > ${SGML_CENTRALIZED}.new
# mv ${SGML_CENTRALIZED}.new $SGML_CENTRALIZED
# else
# echo "Warning: $SGML_ORDINARY was not found in the centralized catalog $SGML_CENTRALIZED" >&2
# fi
if [ ! -s $SGML_ORDINARY ]; then
# rm $SGML_ORDINARY
echo "`basename $0`: removal of $SGML_ORDINARY from /etc/sgml/catalog"
sed -e "\:$SGML_POINTER \"\?$SGML_ORDINARY\"\?\>:d" /etc/sgml/catalog \
> /etc/sgml/catalog.new
mv /etc/sgml/catalog.new /etc/sgml/catalog
fi
;;
esac
exit 0
|