Blame | Last modification | View Log | RSS feed
#set -x# checkinstall script to validate backing out a patch.# directory format option.## @(#)patch_checkinstall 1.2 95/10/10 SMI## Copyright (c) 1995 by Sun Microsystems, Inc.# All rights reserved#PATH=/usr/sadm/bin:$PATHLATER_MSG="PaTcH_MsG 6 ERROR: A later version of this patch is applied."NOPATCH_MSG="PaTcH_MsG 2 ERROR: Patch number $ACTIVE_PATCH is not installed"NEW_LIST=""# Get OLDLIST. $1## Confirm that the patch that got us here is the latest one installed on# the system and remove it from PATCHLIST.#Is_Inst=0Skip=0active_base=`echo $ACTIVE_PATCH | nawk '{ print substr($0, 1, match($0, "-")-1) } '`active_inst=`echo $ACTIVE_PATCH | nawk '{ print substr($0, match($0, "-")+1) } '`for patchappl in ${OLDLIST}; doappl_base=`echo $patchappl | nawk '{ print substr($0, 1, match($0, "-")-1) } '`if [ $appl_base = $active_base ]; thenappl_inst=`echo $patchappl | nawk '{ print substr($0, match($0, "-")+1) } '`result=`expr $appl_inst \> $active_inst`if [ $result -eq 1 ]; thenputtext "$LATER_MSG"exit 3elif [ $appl_inst = $active_inst ]; thenIs_Inst=1Skip=1fifiif [ $Skip = 1 ]; thenSkip=0elseNEW_LIST="${NEW_LIST} $patchappl"fidoneif [ $Is_Inst = 0 ]; thenputtext "$NOPATCH_MSG"exit 3fi## OK, all's well. Now condition the key variables.#echo "PATCHLIST=${NEW_LIST}" >> $1echo "SUNW_PATCHID=" >> $1echo "PATCH_INFO_$ACTIVE_PATCH=backed out" >> $1# Get the current PATCH_OBSOLETES and condition itOld_Obsoletes=$PATCH_OBSOLETESecho $ACTIVE_OBSOLETES | sed 'y/\ /\n/' | \nawk -v PatchObsList="$Old_Obsoletes" 'BEGIN {printf("PATCH_OBSOLETES=");PatchCount=split(PatchObsList, PatchObsComp, " ");for(PatchIndex in PatchObsComp) {Atisat=match(PatchObsComp[PatchIndex], "@");PatchObs[PatchIndex]=substr(PatchObsComp[PatchIndex], 0, Atisat-1);PatchObsCnt[PatchIndex]=substr(PatchObsComp[PatchIndex], Atisat+1);}}{for(PatchIndex in PatchObs) {if (PatchObs[PatchIndex] == $0) {PatchObsCnt[PatchIndex]=PatchObsCnt[PatchIndex]-1;}}next;}END {for(PatchIndex in PatchObs) {if ( PatchObsCnt[PatchIndex] > 0 ) {printf("%s@%d ", PatchObs[PatchIndex], PatchObsCnt[PatchIndex]);}}printf("\n");} ' >> $1# remove the used parametersecho "ACTIVE_OBSOLETES=" >> $1echo "SUNW_OBSOLETES=" >> $1exit 0