# This class action script is introduced to handle patchrm # operation of a patch installed in safemode. # This CAS is invoked as part of patchrm operation. pkgadd # installs the backout package and invokes u.none after the # backout package is installed. This script creates lofs mounts # for removing safemode patch. # # For special package objects such as edittable files, the patch # producer must supply appropriate class action scripts. # # directory format options. # # @(#)u.script 1.1 07/07/02 SMI # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. PATH=/usr/sadm/bin:$PATH EXPR="/usr/bin/expr" # used by dirname MKDIR="/usr/bin/mkdir" CP="/usr/bin/cp" RM="/usr/bin/rm" MV="/usr/bin/mv" KSH="/usr/bin/ksh" DIRNAME="/usr/bin/dirname" BASENAME="/usr/bin/basename" PATCH_COMMON_LIB="/usr/lib/patch/patch_common_lib" SAFEMODE_FAILED="Exiting! Patch deferred activation failed" PROGNAME=`basename $0` if [ "$PKG_INSTALL_ROOT" = "/" ]; then PKG_INSTALL_ROOT="" fi # Since this is generic, figure out the class. Class=`echo $PROGNAME | nawk ' { print substr($0, 3) }'` if [ "$SAFEMODE_INSTALL" = "true" -a "$Class" = "none" ] ; then if [ ! -s "$PATCH_COMMON_LIB" ]; then puttext "$SAFEMODE_FAILED" exit 1 fi . $PATCH_COMMON_LIB InitSafemode || { puttext $SAFEMODE_FAILED exit 1 } fi CMDS_USED="$KSH $EXPR $MKDIR $CP $RM $MV" LIBS_USED="" # Since this is an update, $BASEDIR is guaranteed to be correct BD=${BASEDIR:-/} cd $BD # # First, figure out the dynamic libraries that can trip us up. # if [ -z "$PKG_INSTALL_ROOT" ]; then if [ -x /usr/bin/ldd ]; then LIB_LIST=`/usr/bin/ldd $CMDS_USED | sort -u | nawk ' $1 ~ /\// { continue; } { printf "%s ", $3 } '` else LIB_LIST="/usr/lib/libc.so.1 /usr/lib/libdl.so.1 /usr/lib/libw.so.1 /usr/lib/libintl.so.1 /usr/lib/libgen.so.1 /usr/lib/libadm.so.1 /usr/lib/libelf.so.1" fi fi # # Now read the list of files in this class to be replaced. # Do the lofs mounts to install the backout pkg in order to # perform patchrm operation of a safemode installed patch. # LD_LIB_DIR=$PKG_INSTALL_ROOT/var/tmp/LDLIB.$$ procIdCtr=0 while read src dst; do if [ -z "$PKG_INSTALL_ROOT" ]; then Chk_Path=$dst for library in $LIB_LIST; do if [ "$Chk_Path" = "$library" ]; then if [ ! -d "$LD_LIB_DIR" ]; then $MKDIR $LD_LIB_DIR fi $CP $dst $LD_LIB_DIR LD_LIBRARY_PATH=$LD_LIB_DIR export LD_LIBRARY_PATH fi done fi # If special processing is required for each src/dst pair, # add that here. # #XXXSpecial_CommandsXXX# # if [ "$SAFEMODE_INSTALL" = "true" -a "$Class" = "none" ] ; then InstallSafemodeObject $src $dst || { puttext $SAFEMODE_FAILED exit 1 } else $CP -p $src $dst.$$$procIdCtr if [ $? -ne 0 ]; then $RM $dst.$$$procIdCtr 1>/dev/null 2>&1 else $MV -f $dst.$$$procIdCtr $dst for library in $LIB_LIST; do if [ "$library" = "$dst" ]; then unset $LD_LIBRARY_PATH fi done fi fi procIdCtr=`expr $procIdCtr + 1` done # If additional operations are required for this package, place # those package-specific commands here. #XXXSpecial_CommandsXXX# # # Release the dynamic libraries # if [ -d "$LD_LIB_DIR" ]; then $RM -fr $LD_LIB_DIR fi exit 0