Blame | Last modification | View Log | RSS feed
#set -x# This class action script copies the files being replaced# into a package being constructed in $BUILD_DIR. This class# action script is only appropriate for regular files that# are installed by simply copying them into place.## For special package objects such as edittable files, the patch# producer must supply appropriate class action scripts.## directory format options.## @(#)i.script 1.13 99/11/17 SMI## Copyright (c) 1995 by Sun Microsystems, Inc.# All rights reserved## -------------------------------------------------------------------------------------_processLibFile ()## A project speccific function to process a library item detected in# the delivere prototype file.## Input: src, dst## -------------------------------------------------------------------------------------{SRC=$1m_base=`basename $SRC`m_libNameNoVersion=`perl -e '$item=$ARGV[0]; $item =~ s/\.so.*$/\.so/; printf("$item")' -- $m_base`m_libNameNoVersionOrBuildType=`perl -e '$item=$ARGV[0]; $item =~ s/D\.so.*$|P\.so.*$/\.so/; printf("$item")' -- $m_base`# now we need to detemrine what we were previously linked to# in the app dir.#if [ -f "$m_libNameNoVersionOrBuildType" ]thenm_tmp=`ls -l $m_libNameNoVersionOrBuildType | tr -s " "`m_previousLibNameSrc=`echo $m_tmp | cut -f11 -d" "`elsem_previousLibNameSrc=nonefi# lets now record what we have done so we can back out#if [ ! -f "$M_BACKOUT_SCRIPT" ]thenecho "#!/bin/sh" > $M_BACKOUT_SCRIPTecho "set -x" >> $M_BACKOUT_SCRIPTfiif [ ! -f "$M_POSTPATCH_SCRIPT" ]thenecho "#!/bin/sh" > $M_POSTPATCH_SCRIPTecho "set -x" >> $M_POSTPATCH_SCRIPTfiecho "# -------------------------------------------------------------------------------------------------" >> $M_BACKOUT_SCRIPTecho "# lets backout lib file, from=[$m_base] to=[$m_previousLibNameSrc]" >> $M_BACKOUT_SCRIPTecho "# -------------------------------------------------------------------------------------------------" >> $M_POSTPATCH_SCRIPTecho "# lets postpatch lib file, to=[$m_base] from=[$m_previousLibNameSrc]" >> $M_POSTPATCH_SCRIPTif [ "x$m_previousLibNameSrc" = "xnone" ]thenecho "no history for item [$m_base]."# deal with items in the app dir#echo "installf -c none $PKGINST $M_APPLIB_DIR/$m_libNameNoVersion=$m_base s" >> $M_POSTPATCH_SCRIPTecho "installf -c none $PKGINST $M_APPLIB_DIR/$m_libNameNoVersionOrBuildType=$m_base s" >> $M_POSTPATCH_SCRIPTecho "removef $PKGINST $M_APPLIB_DIR/$m_libNameNoVersion" >> $M_BACKOUT_SCRIPTecho "rm -f $M_APPLIB_DIR/$m_libNameNoVersion" >> $M_BACKOUT_SCRIPTecho "removef $PKGINST $M_APPLIB_DIR/$m_libNameNoVersionOrBuildType" >> $M_BACKOUT_SCRIPTecho "rm -f $M_APPLIB_DIR/$m_libNameNoVersionOrBuildType" >> $M_BACKOUT_SCRIPT# create common items by default ...#echo "installf -c none $PKGINST $M_BASELIB_DIR/$m_base=$M_APPLIB_DIR/$m_base s" \>> $M_POSTPATCH_SCRIPTecho "installf -c none $PKGINST $M_BASELIB_DIR/$m_libNameNoVersion=$M_APPLIB_DIR/$m_base s" \>> $M_POSTPATCH_SCRIPT# Not required. To be removed.# echo "installf -c none $PKGINST $M_BASELIB_DIR/$m_libNameNoVersionOrBuildType=$M_APPLIB_DIR/$m_base s" \# >> $M_POSTPATCH_SCRIPTecho "removef $PKGINST $M_BASELIB_DIR/$m_libNameNoVersion" >> $M_BACKOUT_SCRIPTecho "rm -f $M_BASELIB_DIR/$m_libNameNoVersion" >> $M_BACKOUT_SCRIPTecho "removef $PKGINST $M_BASELIB_DIR/$m_libNameNoVersionOrBuildType" >> $M_BACKOUT_SCRIPTecho "rm -f $M_BASELIB_DIR/$m_libNameNoVersionOrBuildType" >> $M_BACKOUT_SCRIPT# Not required. To be removed.# echo "removef $PKGINST $M_BASELIB_DIR/$m_base" >> $M_BACKOUT_SCRIPT# echo "rm -f $M_BASELIB_DIR/$m_base" >> $M_BACKOUT_SCRIPTelse# we have history.# deal with items in the app dir#_removeItem $M_APPLIB_DIR/$m_libNameNoVersion_linkItem $m_base \$m_libNameNoVersion \$m_previousLibNameSrc \$M_APPLIB_DIR_removeItem $M_APPLIB_DIR/$m_libNameNoVersionOrBuildType_linkItem $m_base \$m_libNameNoVersionOrBuildType \$m_previousLibNameSrc \$M_APPLIB_DIR# deal with common items if they exist ...#if [ -f "$M_BASELIB_DIR/$m_libNameNoVersion" ]then_removeItem $M_BASELIB_DIR/$m_libNameNoVersion_linkItem $M_APPLIB_DIR/$m_base \$m_libNameNoVersion \$M_APPLIB_DIR/$m_previousLibNameSrc \$M_BASELIB_DIRfiif [ -f "$M_BASELIB_DIR/$m_libNameNoVersionOrBuildType" ]then_removeItem $M_BASELIB_DIR/$m_libNameNoVersionOrBuildType_linkItem $M_APPLIB_DIR/$m_base \$m_libNameNoVersionOrBuildType \$M_APPLIB_DIR/$m_previousLibNameSrc \$M_BASELIB_DIRfi# Not required, as we do not have any of these links in the baseDir/lib# To be removed.## if [ -f "$M_BASELIB_DIR/$m_previousLibNameSrc" ]# then## echo "removef $PKGINST $M_BASELIB_DIR/$m_previousLibNameSrc" >> $M_POSTPATCH_SCRIPT# echo "rm -f $M_BASELIB_DIR/$m_previousLibNameSrc" >> $M_POSTPATCH_SCRIPT## echo "installf -c none $PKGINST $M_BASELIB_DIR/$m_base=$M_APPLIB_DIR/$m_base s" \# >> $M_POSTPATCH_SCRIPT## echo "removef $PKGINST $M_BASELIB_DIR/$m_base" >> $M_BACKOUT_SCRIPT# echo "rm -f $M_BASELIB_DIR/$m_base" >> $M_BACKOUT_SCRIPT## echo "installf -c none $PKGINST $M_BASELIB_DIR/$m_previousLibNameSrc=$M_APPLIB_DIR/$m_previousLibNameSrc s" \# >> $M_BACKOUT_SCRIPT## fifi}_removeItem (){echo "rm -f $1"rm -f $1echo "rm -f $1" >> $M_BACKOUT_SCRIPT}_linkItem (){m_pwd=`pwd`cd $4echo "ln -s $1 $2"ln -s $1 $2if [ "x$3" != "xnone" ]thenecho "cd $4" >> $M_BACKOUT_SCRIPTecho "ln -s $3 $2" >> $M_BACKOUT_SCRIPTficd $m_pwd}PATH=/usr/sadm/bin:$PATHECHO="/usr/bin/echo"SED="/usr/bin/sed"PKGPROTO="/usr/bin/pkgproto"EXPR="/usr/bin/expr" # used by dirnameMKDIR="/usr/bin/mkdir"CP="/usr/bin/cp"RM="/usr/bin/rm"MV="/usr/bin/mv"recovery="no"Pn=$$procIdCtr=0CMDS_USED="$ECHO $SED $PKGPROTO $EXPR $MKDIR $CP $RM $MV"LIBS_USED=""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=$FILE_DIR/relocROOT_DIR=$FILE_DIR/rootBO_Deletes=$FILE_DIR/deletesPROGNAME=`basename $0`# 31-July-2002 VC: added these variable, required to generate the postbackout script.#M_PATCHDB=/var/sadm/patchM_PKGINST_LC=`echo $PKGINST | tr -s '[A-Z]' '[a-z]'`M_APPLIB_DIR="$BASEDIR/$M_PKGINST_LC/lib"M_BASELIB_DIR="$BASEDIR/lib"M_BACKOUT_SCRIPT="$M_PATCHDB/$SUNW_PATCHID/postbackout"M_POSTPATCH_SCRIPT="$M_PATCHDB/$SUNW_PATCHID/postpatch"if [ "$PATCH_PROGRESSIVE" = "true" ]; thenPATCH_NO_UNDO="true"fi# Since this is generic, figure out the class.Class=`echo $PROGNAME | nawk ' { print substr($0, 3) }'`# Since this is an update, $BASEDIR is guaranteed to be correctBD=${BASEDIR:-/}cd $BD## First, figure out the dynamic libraries that can trip us up.#if [ -z "$PKG_INSTALL_ROOT" ]; thenif [ -x /usr/bin/ldd ]; thenLIB_LIST=`/usr/bin/ldd $CMDS_USED | sort -u | nawk '$1 ~ /\// { continue; }{ printf "%s ", $3 } '`elseLIB_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"fifi## Now read the list of files in this class to be replaced. If the file# is already in place, then this is a change and we need to copy it# over to the build directory if undo is allowed. If it's a new entry# (No $dst), then it goes in the deletes file for the backout package.#LD_LIB_DIR=$PKG_INSTALL_ROOT/var/tmp/LDLIB.$$procIdCtr=0while read src dst; doif [ -z "$PKG_INSTALL_ROOT" ]; thenChk_Path=$dstfor library in $LIB_LIST; doif [ "$Chk_Path" = "$library" ]; thenif [ ! -d "$LD_LIB_DIR" ]; then$MKDIR $LD_LIB_DIRfi$CP $dst $LD_LIB_DIRLD_LIBRARY_PATH=$LD_LIB_DIRexport LD_LIBRARY_PATHfidonefiif [ "$PATCH_PROGRESSIVE" = "true" ]; then# If this is being used in an old-style patch, insert# the old-style script commands here.#XXXOld_CommandsXXX#echo >/dev/null # dummyfiif [ "${PATCH_NO_UNDO}" != "true" ]; then## Here we construct the path to the appropriate source# tree for the build. First we try to strip BASEDIR. If# there's no BASEDIR in the path, we presume that it is# absolute and construct the target as an absolute path# by stripping PKG_INSTALL_ROOT. FS_Path is the path to# the file on the file system (for deletion purposes).# Build_Path is the path to the object in the build# environment.## The following rootPath variable accounts for a BASEDIR# that is used as a regular variable within the path and# not as a variable that a path needs to be relocated to.rootPath=`$ECHO $src | $SED s@"$INST_DATADIR/$PKGINST"@@ | \nawk -F/ '{print $2}'`if [ "$rootPath" = "root" ]; thenFS_Path=$dstelif [ "$BD" = "/" ]; thenFS_Path=`$ECHO $dst | $SED s@"$BD"@@`elseFS_Path=`$ECHO $dst | $SED "s|$BD/||"`fi# If it's an absolute path the attempt to strip the# BASEDIR will have failed.if [ "$dst" = "$FS_Path" ]; thenif [ -z "$PKG_INSTALL_ROOT" ]; thenFS_Path=$dstBuild_Path="$ROOT_DIR$dst"elseBuild_Path="$ROOT_DIR"`echo $dst | \$SED "s|$PKG_INSTALL_ROOT||"`FS_Path=`echo $dst | \$SED "s|$PKG_INSTALL_ROOT||"`fielseBuild_Path="$RELOC_DIR/$FS_Path"fiif [ -f "$dst" ]; then # If this is replacing somethingcd $FILE_DIR## Construct the prototype file entry. We replace# the pointer to the filesystem object with the# build directory object.#$PKGPROTO -c $Class $dst=$FS_Path | \$SED -e "s|=$dst|=$Build_Path|" >> \$BUILD_DIR/prototype# Now copy over the fileif [ "$recovery" = "no" ]; thenDirName=`dirname $Build_Path`$MKDIR -p $DirName$CP -p $dst $Build_Pathelse# If this file is already in the build area skip itif [ -f "$Build_Path" ]; thencd $BDcontinueelseDirName=`dirname $Build_Path`if [ ! -d "$DirName" ]; then$MKDIR -p $DirNamefi$CP -p $dst $Build_Pathfificd $BDelse # It's brand new$ECHO $FS_Path >> $BO_Deletesfifi# If special processing is required for each src/dst pair,# add that here.##XXXSpecial_CommandsXXX### we need to determine if the item is a lib file`perl -e '$ARGV[0] =~ m/\.so/ or exit(1);' -- $src`isLib=$?if [ "$isLib" -eq "0" ]thenOLD_DIR=`pwd`cd $M_APPLIB_DIR_processLibFile $srccd $OLD_DIRfi$CP -p $src $dst.$$$procIdCtrif [ $? -ne 0 ]; then$RM $dst.$$$procIdCtr 1>/dev/null 2>&1else$MV -f $dst.$$$procIdCtr $dstfor library in $LIB_LIST; doif [ "$library" = "$dst" ]; thenunset $LD_LIBRARY_PATHfidonefiprocIdCtr=`expr $procIdCtr + 1`done# If additional operations are required for this package, place# those package-specific commands here.#XXXSpecial_CommandsXXX#echo "removef -f $PKGINST" >> $M_POSTPATCH_SCRIPTecho "installf -f $PKGINST" >> $M_POSTPATCH_SCRIPTecho "exit 0;" >> $M_POSTPATCH_SCRIPTchmod 755 $M_POSTPATCH_SCRIPTecho "removef -f $PKGINST" >> $M_BACKOUT_SCRIPTecho "installf -f $PKGINST" >> $M_BACKOUT_SCRIPTecho "exit 0;" >> $M_BACKOUT_SCRIPTchmod 755 $M_BACKOUT_SCRIPT## Release the dynamic libraries#if [ -d "$LD_LIB_DIR" ]; then$RM -fr $LD_LIB_DIRfiexit 0