Rev 1530 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#set -x# checkinstall script to control a patch installation.# directory format options.## @(#)checkinstall 1.6 96/09/27 SMI## Copyright (c) 1995 by Sun Microsystems, Inc.# All rights reserved#PATH=/usr/sadm/bin:$PATHINFO_DIR=`dirname $0`INFO_DIR=`dirname $INFO_DIR` # one level upNOVERS_MSG="PaTcH_MsG 8 Version $VERSION of $PKG is not installed on this system."ALRDY_MSG="PaTcH_MsG 2 Patch number $SUNW_PATCHID is already applied."TEMP_MSG="PaTcH_MsG 23 Patch number $SUNW_PATCHID cannot be applied until all \restricted patches are backed out."cat $1# Read the provided environment from what may have been a request script. $1# Old systems can't deal with checkinstall scripts anywayif [ "$PATCH_PROGRESSIVE" = "true" ]; thenexit 0fi## Confirm that the intended version is installed on the system.#if [ "${UPDATE}" != "yes" ]; thenecho "$NOVERS_MSG"exit 3fi## Confirm that this patch hasn't already been applied and# that no other mix-ups have occurred involving patch versions and# the like.#Skip=0active_base=`echo $SUNW_PATCHID | nawk '{ print substr($0, 1, match($0, "Patchvers_pfx")-1) } '`active_inst=`echo $SUNW_PATCHID | nawk '{ print substr($0, match($0, "Patchvers_pfx")+Patchvers_pfx_lnth) } '`# Is this a restricted patch?if echo $active_base | egrep -s "Patchstrict_str"; thenis_restricted="true"# All restricted patches are backoutableecho "PATCH_NO_UNDO=" >> $1elseis_restricted="false"fifor patchappl in ${PATCHLIST}; do# Is this an ordinary patch applying over a restricted patch?if [ $is_restricted = "false" ]; thenif echo $patchappl | egrep -s "Patchstrict_str"; thenecho "$TEMP_MSG"exit 3;fifi# Is there a newer version of this patch?appl_base=`echo $patchappl | nawk '{ print substr($0, 1, match($0, "Patchvers_pfx")-1) } '`if [ $appl_base = $active_base ]; thenappl_inst=`echo $patchappl | nawk '{ print substr($0, match($0, "Patchvers_pfx")\+Patchvers_pfx_lnth) } '`result=`expr $appl_inst \> $active_inst`if [ $result -eq 1 ]; thenecho "PaTcH_MsG 1 Patch number $SUNW_PATCHID is \superceded by the already applied $patchappl."exit 3elif [ $appl_inst = $active_inst ]; then# Not newer, it's the sameif [ "$PATCH_UNCONDITIONAL" = "true" ]; thenif [ -d $PKGSAV/$SUNW_PATCHID ]; thenecho "PATCH_NO_UNDO=true" >> $1fielseecho "$ALRDY_MSG"exit 3;fififidone# Construct a list of applied patches in orderecho "PATCHLIST=${PATCHLIST} $SUNW_PATCHID" >> $1## Construct the complete list of patches this one obsoletes#ACTIVE_OBSOLETES=$Obsoletes_labelif [ -n "$Obsoletes_label" ]; then# Merge the two listsecho $Obsoletes_label | sed 'y/\ /\n/' | \nawk -v PatchObsList="$PATCH_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);}}{Inserted=0;for(PatchIndex in PatchObs) {if (PatchObs[PatchIndex] == $0) {if (Inserted == 0) {PatchObsCnt[PatchIndex]=PatchObsCnt\[PatchIndex]+1;Inserted=1;} else {PatchObsCnt[PatchIndex]=0;}}}if (Inserted == 0) {printf ("%s@1 ", $0);}next;}END {for(PatchIndex in PatchObs) {if ( PatchObsCnt[PatchIndex] != 0) {printf("%s@%d ", PatchObs[PatchIndex], \PatchObsCnt[PatchIndex]);}}printf("\n");} ' >> $1# Clear the parameter since it has already been used.echo "Obsoletes_label=" >> $1# Pass it's value on to the preinstall under another nameecho "ACTIVE_OBSOLETES=$ACTIVE_OBSOLETES" >> $1fi## Construct PATCH_INFO line for this package.## 31-July-2002 VC: added this line to enable the PATCH_INFO line to contain more detail#ACTIVE_OBSOLETES="$PATCH_OBSOLETES"tmpRequire=`nawk -F= ' $1 ~ /REQUIR/ { print $2 } ' $INFO_DIR/pkginfo `tmpIncompat=`nawk -F= ' $1 ~ /INCOMPAT/ { print $2 } ' $INFO_DIR/pkginfo `if [ -n "$tmpRequire" ] && [ -n "$tmpIncompat" ]thenecho "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \Obsoletes: $ACTIVE_OBSOLETES Requires: $tmpRequire \Incompatibles: $tmpIncompat" >> $1elif [ -n "$tmpRequire" ]thenecho "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \Obsoletes: $ACTIVE_OBSOLETES Requires: $tmpRequire \Incompatibles: " >> $1elif [ -n "$tmpIncompat" ]thenecho "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \Obsoletes: $ACTIVE_OBSOLETES Requires: Incompatibles: \$tmpIncompat" >> $1elseecho "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \Obsoletes: $ACTIVE_OBSOLETES Requires: Incompatibles: " >> $1fi## Since this script is called from the delivery medium and we may be using# dot extensions to distinguish the different patch packages, this is the# only place we can, with certainty, trace that source for our backout# scripts. (Usually $INST_DATADIR would get us there).#echo "SCRIPTS_DIR=`dirname $0`" >> $1# If additional operations are required for this package, place# those package-specific commands here.#XXXSpecial_CommandsXXX#exit 0