Blame | Last modification | View Log | RSS feed
#set -x# This script initializes the backout data for a patch package# directory format options.## @(#)preinstall 1.10 99/04/23 SMI## Copyright (c) 1995 by Sun Microsystems, Inc.# All rights reserved#PATH=/usr/sadm/bin:$PATHrecovery="no"if [ "$PKG_INSTALL_ROOT" = "/" ]; thenPKG_INSTALL_ROOT=""fi# Check to see if this is a patch installation retry.if [ "$INTERRUPTION" = "yes" ]; thenif [ -d "$PKG_INSTALL_ROOT/var/tmp/$SUNW_PATCHID.$PKGINST" ] || [ -d "$PATCH_BUILD_DIR/$SUNW_PATCHID.$PKGINST" ]; thenrecovery="yes"fifiif [ -n "$PATCH_BUILD_DIR" -a -d "$PATCH_BUILD_DIR" ]; thenBUILD_DIR="$PATCH_BUILD_DIR/$SUNW_PATCHID.$PKGINST"elseBUILD_DIR="$PKG_INSTALL_ROOT/var/tmp/$SUNW_PATCHID.$PKGINST"fiFILE_DIR=$BUILD_DIR/filesRELOC_DIR=$BUILD_DIR/files/relocROOT_DIR=$BUILD_DIR/files/rootPROTO_FILE=$BUILD_DIR/prototypeORIGPKGINFO=$PKG_INSTALL_ROOT/var/sadm/pkg/$PKGINST/pkginfoPKGINFO_FILE=$BUILD_DIR/pkginfoTHIS_DIR=`dirname $0`INSTALLINGPKGINFO=`dirname $THIS_DIR`if [ "$PATCH_PROGRESSIVE" = "true" ]; then# If this is being used in an old-style patch, insert# the old-style script commands here.#XXXOld_CommandsXXX#exit 0fi## Unless specifically denied, initialize the backout patch data by# creating the build directory and copying over the original pkginfo# which pkgadd saved in case it had to be restored.#if [ "$PATCH_NO_UNDO" != "true" ] && [ "$recovery" = "no" ]; thenif [ -d $BUILD_DIR ]; thenrm -r $BUILD_DIRfi# If this is a retry of the same patch then recovery is set to# yes. Which means there is a build directory already in# place with the correct backout data.if [ "$recovery" = "no" ]; thenmkdir $BUILD_DIRmkdir -p $RELOC_DIRmkdir $ROOT_DIRfi## Here we initialize the backout pkginfo file by first# copying over the old pkginfo file and then adding the# ACTIVE_PATCH parameter so the backout will know what patch# it's backing out.## NOTE : Within the installation, pkgparam returns the# original data.#pkgparam -v $PKGINST | nawk '$1 ~ /PATCHLIST/ { next; }$1 ~ /CLASSES/ { next; }$1 ~ /PATCH_OBSOLETES/ { next; }$1 ~ /ACTIVE_OBSOLETES/ { next; }$1 ~ /SUNW_OBSOLETES/ { next; }$1 ~ /ACTIVE_PATCH/ { next; }$1 ~ /SUNW_PATCHID/ { next; }$1 ~ /UPDATE/ { next; }$1 ~ /SCRIPTS_DIR/ { next; }$1 ~ /PATCH_NO_UNDO/ { next; }$1 ~ /INSTDATE/ { next; }$1 ~ /PKGINST/ { next; }$1 ~ /OAMBASE/ { next; }$1 ~ /PATH/ { next; }{ print; } ' | sed s,\'\"\'\"\',ApOsTrOpHe,g > $PKGINFO_FILE# The previous is needed to workaround pkgparam# inserting '"'"' for every ' it finds in the# pkginfo file. see bugid 4052001.# If there is an undo script delivered with this patch pkg# there is a possibility that when the patch gets backed out# it may not get executed due to the CLASSES macro in the# original pkginfo file may not contain the class# identifier. Thus we need to merge the old CLASSES macro and# the installing patch pkgs CLASSES macro.nawk ' $1 ~ /CLASSES/ {print $0} ' $INSTALLINGPKGINFO/pkginfo \| sed s/CLASSES=// > /tmp/installingCLASSES.$$classIDs=`nawk ' $1 ~ /CLASSES/ {print $0} ' $ORIGPKGINFO \| sed s/CLASSES=//`for instClass in $classIDs; donotFound=`grep "$instClass" /tmp/installingCLASSES.$$`if [ -z "$notFound" ]; thennewCLASSESlist="$instClass $newCLASSESlist"finotFound=""doneclasses=`nawk ' $1 ~ /CLASSES/ {print $0} ' $ORIGPKGINFO`newCLASSESlist="$classes $newCLASSESlist"echo "$newCLASSESlist" >> $PKGINFO_FILEecho "ACTIVE_PATCH=$SUNW_PATCHID" >> $PKGINFO_FILEecho "ACTIVE_OBSOLETES=$ACTIVE_OBSOLETES" >> $PKGINFO_FILErm /tmp/installingCLASSES.$$# And now initialize the backout prototype file with the# pkginfo file just formulated.echo "i pkginfo" > $PROTO_FILE# Copy over the backout scripts including the undo class# action scriptsfor script in $SCRIPTS_DIR/*; dosrcscript=`basename $script`targscript=`echo $srcscript | nawk '{ script=$0; }/u\./ {sub("u.", "i.", script);print script;next;}/patch_/ {sub("patch_", "", script);print script;next;}{ print "dont_use" } '`if [ "$targscript" = "dont_use" ]; thencontinuefiecho "i $targscript=$FILE_DIR/$targscript" >> $PROTO_FILEcp $SCRIPTS_DIR/$srcscript $FILE_DIR/$targscriptdone## Now add entries to the prototype file that won't be passed to# class action scripts. If the entry is brand new, add it to the# deletes file for the backout package.#Our_Pkgmap=`dirname $SCRIPTS_DIR`/pkgmapBO_Deletes=$FILE_DIR/deletesnawk -v basedir=${BASEDIR:-/} 'BEGIN { count=0; }{token = $2;ftype = $1;}$1 ~ /[#\!:]/ { next; }$1 ~ /[0123456789]/ {if ( NF >= 3) {token = $3;ftype = $2;} else {next;}}{ if (ftype == "i" || ftype == "e" || ftype == "f" || ftype == "v" || ftype == "d") { next; } }{equals=match($4, "=")-1;if ( equals == -1 ) { print $3, $4; }else { print $3, substr($4, 0, equals); }}' < $Our_Pkgmap | while read class path; do## NOTE: If pkgproto is passed a file that is# actually a hard link to another file, it# will return ftype "f" because the first link# in the list (consisting of only one file) is# viewed by pkgproto as the source and always# gets ftype "f".## If this isn't replacing something, then it# just goes to the deletes list.#if valpath -l $path; thenChk_Path="$BASEDIR/$path"Build_Path="$RELOC_DIR/$path"Proto_From="$BASEDIR"else # It's an absolute pathChk_Path="$PKG_INSTALL_ROOT$path"Build_Path="$ROOT_DIR$path"Proto_From="$PKG_INSTALL_ROOT"fi## Hard links have to be restored as regular files.# Unlike the others in this group, an actual# object will be required for the pkgmk.#if [ -f "$Chk_Path" -a ! -h "$Chk_Path" ] ; thenmkdir -p `dirname $Build_Path`cp -p $Chk_Path $Build_Pathcd $Proto_Frompkgproto -c $class "$Build_Path=$path" 1>> $PROTO_FILE 2> /dev/nullcd $THIS_DIRelif [ -h "$Chk_Path" -o \-c "$Chk_Path" -o \-b "$Chk_Path" -o \-p "$Chk_Path" ]; thenpkgproto -c $class "$Chk_Path" 1>> $PROTO_FILE 2> /dev/nullelseecho $path >> $BO_Deletesfidonefi# If additional operations are required for this package, place# those package-specific commands here.#XXXSpecial_CommandsXXX#exit 0