| 1530 |
dpurdie |
1 |
#set -x
|
|
|
2 |
# checkinstall script to control a patch installation.
|
|
|
3 |
# directory format options.
|
|
|
4 |
#
|
|
|
5 |
# @(#)checkinstall 1.6 96/09/27 SMI
|
|
|
6 |
#
|
|
|
7 |
# Copyright (c) 1995 by Sun Microsystems, Inc.
|
|
|
8 |
# All rights reserved
|
|
|
9 |
#
|
|
|
10 |
|
|
|
11 |
PATH=/usr/sadm/bin:$PATH
|
|
|
12 |
|
|
|
13 |
INFO_DIR=`dirname $0`
|
|
|
14 |
INFO_DIR=`dirname $INFO_DIR` # one level up
|
|
|
15 |
|
|
|
16 |
NOVERS_MSG="PaTcH_MsG 8 Version $VERSION of $PKG is not installed on this system."
|
|
|
17 |
ALRDY_MSG="PaTcH_MsG 2 Patch number $SUNW_PATCHID is already applied."
|
|
|
18 |
TEMP_MSG="PaTcH_MsG 23 Patch number $SUNW_PATCHID cannot be applied until all \
|
|
|
19 |
restricted patches are backed out."
|
|
|
20 |
|
|
|
21 |
cat $1
|
|
|
22 |
# Read the provided environment from what may have been a request script
|
|
|
23 |
. $1
|
|
|
24 |
|
|
|
25 |
# Old systems can't deal with checkinstall scripts anyway
|
|
|
26 |
if [ "$PATCH_PROGRESSIVE" = "true" ]; then
|
|
|
27 |
exit 0
|
|
|
28 |
fi
|
|
|
29 |
|
|
|
30 |
#
|
|
|
31 |
# Confirm that the intended version is installed on the system.
|
|
|
32 |
#
|
|
|
33 |
if [ "${UPDATE}" != "yes" ]; then
|
|
|
34 |
echo "$NOVERS_MSG"
|
|
|
35 |
exit 3
|
|
|
36 |
fi
|
|
|
37 |
|
|
|
38 |
#
|
|
|
39 |
# Confirm that this patch hasn't already been applied and
|
|
|
40 |
# that no other mix-ups have occurred involving patch versions and
|
|
|
41 |
# the like.
|
|
|
42 |
#
|
|
|
43 |
Skip=0
|
|
|
44 |
active_base=`echo $SUNW_PATCHID | nawk '
|
|
|
45 |
{ print substr($0, 1, match($0, "Patchvers_pfx")-1) } '`
|
|
|
46 |
active_inst=`echo $SUNW_PATCHID | nawk '
|
|
|
47 |
{ print substr($0, match($0, "Patchvers_pfx")+Patchvers_pfx_lnth) } '`
|
|
|
48 |
|
|
|
49 |
# Is this a restricted patch?
|
|
|
50 |
if echo $active_base | egrep -s "Patchstrict_str"; then
|
|
|
51 |
is_restricted="true"
|
|
|
52 |
# All restricted patches are backoutable
|
|
|
53 |
echo "PATCH_NO_UNDO=" >> $1
|
|
|
54 |
else
|
|
|
55 |
is_restricted="false"
|
|
|
56 |
fi
|
|
|
57 |
|
|
|
58 |
for patchappl in ${PATCHLIST}; do
|
|
|
59 |
# Is this an ordinary patch applying over a restricted patch?
|
|
|
60 |
if [ $is_restricted = "false" ]; then
|
|
|
61 |
if echo $patchappl | egrep -s "Patchstrict_str"; then
|
|
|
62 |
echo "$TEMP_MSG"
|
|
|
63 |
exit 3;
|
|
|
64 |
fi
|
|
|
65 |
fi
|
|
|
66 |
|
|
|
67 |
# Is there a newer version of this patch?
|
|
|
68 |
appl_base=`echo $patchappl | nawk '
|
|
|
69 |
{ print substr($0, 1, match($0, "Patchvers_pfx")-1) } '`
|
|
|
70 |
if [ $appl_base = $active_base ]; then
|
|
|
71 |
appl_inst=`echo $patchappl | nawk '
|
|
|
72 |
{ print substr($0, match($0, "Patchvers_pfx")\
|
|
|
73 |
+Patchvers_pfx_lnth) } '`
|
|
|
74 |
result=`expr $appl_inst \> $active_inst`
|
|
|
75 |
if [ $result -eq 1 ]; then
|
|
|
76 |
echo "PaTcH_MsG 1 Patch number $SUNW_PATCHID is \
|
|
|
77 |
superceded by the already applied $patchappl."
|
|
|
78 |
exit 3
|
|
|
79 |
elif [ $appl_inst = $active_inst ]; then
|
|
|
80 |
# Not newer, it's the same
|
|
|
81 |
if [ "$PATCH_UNCONDITIONAL" = "true" ]; then
|
|
|
82 |
if [ -d $PKGSAV/$SUNW_PATCHID ]; then
|
|
|
83 |
echo "PATCH_NO_UNDO=true" >> $1
|
|
|
84 |
fi
|
|
|
85 |
else
|
|
|
86 |
echo "$ALRDY_MSG"
|
|
|
87 |
exit 3;
|
|
|
88 |
fi
|
|
|
89 |
fi
|
|
|
90 |
fi
|
|
|
91 |
done
|
|
|
92 |
|
|
|
93 |
# Construct a list of applied patches in order
|
|
|
94 |
echo "PATCHLIST=${PATCHLIST} $SUNW_PATCHID" >> $1
|
|
|
95 |
|
|
|
96 |
#
|
|
|
97 |
# Construct the complete list of patches this one obsoletes
|
|
|
98 |
#
|
|
|
99 |
ACTIVE_OBSOLETES=$Obsoletes_label
|
|
|
100 |
|
|
|
101 |
if [ -n "$Obsoletes_label" ]; then
|
|
|
102 |
# Merge the two lists
|
|
|
103 |
echo $Obsoletes_label | sed 'y/\ /\n/' | \
|
|
|
104 |
nawk -v PatchObsList="$PATCH_OBSOLETES" '
|
|
|
105 |
BEGIN {
|
|
|
106 |
printf("PATCH_OBSOLETES=");
|
|
|
107 |
PatchCount=split(PatchObsList, PatchObsComp, " ");
|
|
|
108 |
|
|
|
109 |
for(PatchIndex in PatchObsComp) {
|
|
|
110 |
Atisat=match(PatchObsComp[PatchIndex], "@");
|
|
|
111 |
PatchObs[PatchIndex]=substr(PatchObsComp[PatchIndex], \
|
|
|
112 |
0, Atisat-1);
|
|
|
113 |
PatchObsCnt[PatchIndex]=substr(PatchObsComp\
|
|
|
114 |
[PatchIndex], Atisat+1);
|
|
|
115 |
}
|
|
|
116 |
}
|
|
|
117 |
{
|
|
|
118 |
Inserted=0;
|
|
|
119 |
for(PatchIndex in PatchObs) {
|
|
|
120 |
if (PatchObs[PatchIndex] == $0) {
|
|
|
121 |
if (Inserted == 0) {
|
|
|
122 |
PatchObsCnt[PatchIndex]=PatchObsCnt\
|
|
|
123 |
[PatchIndex]+1;
|
|
|
124 |
Inserted=1;
|
|
|
125 |
} else {
|
|
|
126 |
PatchObsCnt[PatchIndex]=0;
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
if (Inserted == 0) {
|
|
|
131 |
printf ("%s@1 ", $0);
|
|
|
132 |
}
|
|
|
133 |
next;
|
|
|
134 |
}
|
|
|
135 |
END {
|
|
|
136 |
for(PatchIndex in PatchObs) {
|
|
|
137 |
if ( PatchObsCnt[PatchIndex] != 0) {
|
|
|
138 |
printf("%s@%d ", PatchObs[PatchIndex], \
|
|
|
139 |
PatchObsCnt[PatchIndex]);
|
|
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
printf("\n");
|
|
|
143 |
} ' >> $1
|
|
|
144 |
# Clear the parameter since it has already been used.
|
|
|
145 |
echo "Obsoletes_label=" >> $1
|
|
|
146 |
|
|
|
147 |
# Pass it's value on to the preinstall under another name
|
|
|
148 |
echo "ACTIVE_OBSOLETES=$ACTIVE_OBSOLETES" >> $1
|
|
|
149 |
fi
|
|
|
150 |
|
|
|
151 |
#
|
|
|
152 |
# Construct PATCH_INFO line for this package.
|
|
|
153 |
#
|
|
|
154 |
|
|
|
155 |
# 31-July-2002 VC: added this line to enable the PATCH_INFO line to contain more detail
|
|
|
156 |
#
|
|
|
157 |
ACTIVE_OBSOLETES="$PATCH_OBSOLETES"
|
|
|
158 |
|
|
|
159 |
tmpRequire=`nawk -F= ' $1 ~ /REQUIR/ { print $2 } ' $INFO_DIR/pkginfo `
|
|
|
160 |
tmpIncompat=`nawk -F= ' $1 ~ /INCOMPAT/ { print $2 } ' $INFO_DIR/pkginfo `
|
|
|
161 |
|
|
|
162 |
if [ -n "$tmpRequire" ] && [ -n "$tmpIncompat" ]
|
|
|
163 |
then
|
|
|
164 |
echo "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \
|
|
|
165 |
Obsoletes: $ACTIVE_OBSOLETES Requires: $tmpRequire \
|
|
|
166 |
Incompatibles: $tmpIncompat" >> $1
|
|
|
167 |
elif [ -n "$tmpRequire" ]
|
|
|
168 |
then
|
|
|
169 |
echo "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \
|
|
|
170 |
Obsoletes: $ACTIVE_OBSOLETES Requires: $tmpRequire \
|
|
|
171 |
Incompatibles: " >> $1
|
|
|
172 |
elif [ -n "$tmpIncompat" ]
|
|
|
173 |
then
|
|
|
174 |
echo "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \
|
|
|
175 |
Obsoletes: $ACTIVE_OBSOLETES Requires: Incompatibles: \
|
|
|
176 |
$tmpIncompat" >> $1
|
|
|
177 |
else
|
|
|
178 |
echo "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \
|
|
|
179 |
Obsoletes: $ACTIVE_OBSOLETES Requires: Incompatibles: " >> $1
|
|
|
180 |
fi
|
|
|
181 |
|
|
|
182 |
#
|
|
|
183 |
# Since this script is called from the delivery medium and we may be using
|
|
|
184 |
# dot extensions to distinguish the different patch packages, this is the
|
|
|
185 |
# only place we can, with certainty, trace that source for our backout
|
|
|
186 |
# scripts. (Usually $INST_DATADIR would get us there).
|
|
|
187 |
#
|
|
|
188 |
echo "SCRIPTS_DIR=`dirname $0`" >> $1
|
|
|
189 |
|
|
|
190 |
# If additional operations are required for this package, place
|
|
|
191 |
# those package-specific commands here.
|
|
|
192 |
|
|
|
193 |
#XXXSpecial_CommandsXXX#
|
|
|
194 |
|
|
|
195 |
exit 0
|