# 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.16 07/07/02 SMI # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. PATH=/usr/sadm/bin:$PATH ECHO="/usr/bin/echo" SED="/usr/bin/sed" PKGPROTO="/usr/bin/pkgproto" 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" recovery="no" Pn=$$ procIdCtr=0 CMDS_USED="$KSH $ECHO $SED $PKGPROTO $EXPR $MKDIR $CP $RM $MV" LIBS_USED="" if [ "$PKG_INSTALL_ROOT" = "/" ]; then PKG_INSTALL_ROOT="" fi # Check to see if this is a patch installation retry. if [ "$INTERRUPTION" = "yes" ]; then if [ -d "$PKG_INSTALL_ROOT/var/tmp/$SUNW_PATCHID.$PKGINST" ] || [ -d "$PATCH_BUILD_DIR/$SUNW_PATCHID.$PKGINST" ]; then recovery="yes" fi fi if [ -n "$PATCH_BUILD_DIR" -a -d "$PATCH_BUILD_DIR" ]; then BUILD_DIR="$PATCH_BUILD_DIR/$SUNW_PATCHID.$PKGINST" else BUILD_DIR="$PKG_INSTALL_ROOT/var/tmp/$SUNW_PATCHID.$PKGINST" fi FILE_DIR=$BUILD_DIR/files RELOC_DIR=$FILE_DIR/reloc ROOT_DIR=$FILE_DIR/root BO_Deletes=$FILE_DIR/deletes PROGNAME=`basename $0` if [ "$PATCH_PROGRESSIVE" = "true" ]; then PATCH_NO_UNDO="true" 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 # 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. 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.$$ #XXXSpecial_CommandsXXX# # Use locale C to evaluate extended acsii characters in existing conf file LC_ALL=C; export LC_ALL tmpfile=/tmp/emlxs_tmp_$$ sedfile=/tmp/emlxs-sed_$$ remove_oldheader () # Remove address and confidential notice no longer used { sed -e '/^# 3333 Susan Street, Costa Mesa, CA 92626/d' \ -e '/^# All rights reserved. This computer program and related /',\ '/^# copyright laws and may subject you to criminal prosecution./d'\ $dst > $tmpfile if [ $? -eq 0 ] ; then mv $tmpfile $dst fi } update_header () # Update Copyright in destination { emlxs_copyright=`grep '# COPYRIGHT.*Emulex.*' $src` sed -e "s:# *EMLXS.CONF:# EMLXS.CONF:" \ -e "s:# COPYRIGHT.*Emulex.*:$emlxs_copyright:" $dst > $tmpfile if [ $? -eq 0 ] ; then mv $tmpfile $dst fi } add_pci_max_read () # Add pci-max-read comment block { cat >> $dst < $sedfile < $sedfile < $sedfile < /dev/null if [ $? -eq 0 ]; then create_default_num_nodes_sedfile default=`sed -n -f $sedfile $dst` if [ -n "$default" ] && [ $default -eq 512 ] ; then create_update_num_nodes_sedfile sed -f $sedfile $dst > $tmpfile if [ $? -eq 0 ] ; then mv $tmpfile $dst fi fi fi } create_max_link_speed_sedfile () # Create sed script to determine Max in comments for link_speed # Used by check_link_speed routine { cat > $sedfile < $sedfile < $tmpfile if [ $? -eq 0 ] ; then mv $tmpfile $dst fi fi } add_log_ct () # add LOG_CT comment to destination { sed -e '/# LOG_FIRMWARE /a\ \# LOG_CT 0x00010000 /* CT events */' $dst > $tmpfile if [ $? -eq 0 ] ; then mv $tmpfile $dst fi } add_log_fcsp () # add LOG_CT comment to destination { sed -e '/# LOG_CT /a\ \# LOG_FCSP 0x00020000 /* FCSP events */' $dst > $tmpfile if [ $? -eq 0 ] ; then mv $tmpfile $dst fi } add_parameter () # Add new parameters and comment block from src confile { newparam=$1 # Special cases - parameters not used or which have been updated if [ $newparam = pci-max-read ] ; then # pci-max-read parameter may be new or need to be updated check_pci_max_read elif [ $newparam = vport ] ; then # vport parameter is not included in the delivered conf file. # Check is done against the first line of the vport comment instead. # to see if comment was already added. grep "^# vport: Virtual port registration table." $dst > /dev/null if [ $? -ne 0 ] ;then add_vport_comment fi else # Regular parameters commentblk="" # Lookup comment and parameter from src conffile while read confline do if [ -z "$confline" ] ; then # Blank line; reset block and resume commentblk="" continue fi echo "$confline" | grep '^#' > /dev/null 2>&1 if [ $? -eq 0 ] ; then # Comment # Start new comment block or append to existing block. if [ -z "${commentblk}" ] ; then commentblk="${confline}" else commentblk="${commentblk}\n${confline}" fi continue fi # Must be a parameter param=`echo "$confline" | sed 's/\(.*\)=.*/\1/'` if [ "${newparam}" = "${param}" ] ; then echo "$commentblk" >> $dst echo "$confline" >> $dst echo "\n" >> $dst else # Wrong parameter; reset block commentblk="" continue fi done < $src fi } new_content () # look up new parameters and add if needed # Add the parameter variable to the new_params list. { new_params="\ pci-max-read \ linkup-delay \ enable-npiv \ vport-restrict-login \ vport \ enable-auth \ max-xfer-size \ " for param in $new_params ; do grep "^${param}=" $dst > /dev/null if [ $? -ne 0 ] ; then add_parameter $param fi done } update_content () # Update existing information in destination conffile { # Correct spelling issue sed -e 's/manamgnet/management/' \ -e 's/# LOG_RESERVED 0xfff.0000/# LOG_RESERVED 0xfffc0000/' \ $dst > $tmpfile if [ $? -eq 0 ] ; then mv $tmpfile $dst fi if grep '^# LOG_CT ' $dst > /dev/null ; then : else add_log_ct fi if grep '^# LOG_FCSP ' $dst > /dev/null ; then : else add_log_fcsp fi check_num_nodes check_link_speed } #XXXEnd of Special_CommandsXXX# 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 [ "$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 # dummy fi if [ "${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" ]; then FS_Path=$dst elif [ "$BD" = "/" ]; then FS_Path=`$ECHO $dst | $SED s@"$BD"@@` else FS_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" ]; then if [ -z "$PKG_INSTALL_ROOT" ]; then FS_Path=$dst Build_Path="$ROOT_DIR$dst" else Build_Path="$ROOT_DIR"`echo $dst | \ $SED "s|$PKG_INSTALL_ROOT||"` FS_Path=`echo $dst | \ $SED "s|$PKG_INSTALL_ROOT||"` fi else Build_Path="$RELOC_DIR/$FS_Path" fi if [ -f "$dst" ]; then # If this is replacing something cd $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 file if [ "$recovery" = "no" ]; then DirName=`dirname $Build_Path` $MKDIR -p $DirName $CP -p $dst $Build_Path else # If this file is already in the build area skip it if [ -f "$Build_Path" ]; then cd $BD continue else DirName=`dirname $Build_Path` if [ ! -d "$DirName" ]; then $MKDIR -p $DirName fi $CP -p $dst $Build_Path fi fi cd $BD else # It's brand new $ECHO $FS_Path >> $BO_Deletes fi 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 if [ ! -f $dst ] ; then $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 else # Upgrade destination file remove_oldheader update_header new_content update_content 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