Subversion Repositories DevTools

Rev

Rev 1530 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1530 dpurdie 1
#set -x
2
# checkinstall script to validate backing out a patch.
3
# directory format option.
4
#
5
#       @(#)patch_checkinstall 1.2 95/10/10 SMI
6
#
7
# Copyright (c) 1995 by Sun Microsystems, Inc.
8
# All rights reserved
9
#
10
 
11
PATH=/usr/sadm/bin:$PATH
12
 
13
LATER_MSG="PaTcH_MsG 6 ERROR: A later version of this patch is applied."
14
NOPATCH_MSG="PaTcH_MsG 2 ERROR: Patch number $ACTIVE_PATCH is not installed"
15
NEW_LIST=""
16
 
17
# Get OLDLIST
18
. $1
19
 
20
#
21
# Confirm that the patch that got us here is the latest one installed on
22
# the system and remove it from PATCHLIST.
23
#
24
Is_Inst=0
25
Skip=0
26
active_base=`echo $ACTIVE_PATCH | nawk '
27
	{ print substr($0, 1, match($0, "-")-1) } '`
28
active_inst=`echo $ACTIVE_PATCH | nawk '
29
	{ print substr($0, match($0, "-")+1) } '`
30
for patchappl in ${OLDLIST}; do
31
	appl_base=`echo $patchappl | nawk '
32
		{ print substr($0, 1, match($0, "-")-1) } '`
33
	if [ $appl_base = $active_base ]; then
34
		appl_inst=`echo $patchappl | nawk '
35
			{ print substr($0, match($0, "-")+1) } '`
36
		result=`expr $appl_inst \> $active_inst`
37
		if [ $result -eq 1 ]; then
38
			puttext "$LATER_MSG"
39
			exit 3
40
		elif [ $appl_inst = $active_inst ]; then
41
			Is_Inst=1
42
			Skip=1
43
		fi
44
	fi
45
	if [ $Skip = 1 ]; then
46
		Skip=0
47
	else
48
		NEW_LIST="${NEW_LIST} $patchappl"
49
	fi
50
done
51
 
52
if [ $Is_Inst = 0 ]; then
53
	puttext "$NOPATCH_MSG"
54
	exit 3
55
fi
56
 
57
#
58
# OK, all's well. Now condition the key variables.
59
#
60
echo "PATCHLIST=${NEW_LIST}" >> $1
61
echo "SUNW_PATCHID=" >> $1
62
echo "PATCH_INFO_$ACTIVE_PATCH=backed out" >> $1
63
 
64
# Get the current PATCH_OBSOLETES and condition it
65
Old_Obsoletes=$PATCH_OBSOLETES
66
 
67
echo $ACTIVE_OBSOLETES | sed 'y/\ /\n/' | \
68
nawk -v PatchObsList="$Old_Obsoletes" '
69
	BEGIN {
70
		printf("PATCH_OBSOLETES=");
71
		PatchCount=split(PatchObsList, PatchObsComp, " ");
72
 
73
		for(PatchIndex in PatchObsComp) {
74
			Atisat=match(PatchObsComp[PatchIndex], "@");
75
			PatchObs[PatchIndex]=substr(PatchObsComp[PatchIndex], 0, Atisat-1);
76
			PatchObsCnt[PatchIndex]=substr(PatchObsComp[PatchIndex], Atisat+1);
77
		}
78
	}
79
	{
80
		for(PatchIndex in PatchObs) {
81
			if (PatchObs[PatchIndex] == $0) {
82
				PatchObsCnt[PatchIndex]=PatchObsCnt[PatchIndex]-1;
83
			}
84
		}
85
		next;
86
	}
87
	END {
88
		for(PatchIndex in PatchObs) {
89
			if ( PatchObsCnt[PatchIndex] > 0 ) {
90
				printf("%s@%d ", PatchObs[PatchIndex], PatchObsCnt[PatchIndex]);
91
			}
92
		}
93
		printf("\n");
94
	} ' >> $1
95
 
96
	# remove the used parameters
97
	echo "ACTIVE_OBSOLETES=" >> $1
98
	echo "SUNW_OBSOLETES=" >> $1
99
 
100
exit 0
101