#!/sbin/sh 
#
# iVillage modified patch_finish
# ATonns Thu Aug 30 12:49:37 EDT 2001
#
# Modifications are as follows:
#
# 1) SOL_PATCHDIR has been changed to reflect the location of the
#    NFS mounted patch directory
# 2) The order which patches are installed is no longer determined by:
#	patches=`\ls -rt .` 
#    instead it is done by:
#	patches=`cat $SOL_PATCHDIR/patch_order`
#
# You can diff the patch_finish.orig with the copy from the Solaris CD
# (/cdrom/sol_7_1199_sparc_sun_srvr/s0/Solaris_2.7/Tools/Boot/usr/sbin/install.d/install_config/patch_finish)
# to check to see if there has been any additional updates

#!/sbin/sh
#
#       @(#)patch_finish.sh	1.21	11/18/98	SMI
#
#	Copyright 1997 Sun Microsystems, Inc.  All Rights Reserved.

# Sun considers its source code as an unpublished, proprietary trade secret,
# and it is available only under strict license provisions.  This copyright
# notice is placed here only to protect Sun in the event the source is
# deemed a published work.  Dissassembly, decompilation, or other means of
# reducing the object code to human readable form is prohibited by the
# license agreement under which this code is provided to the user or company
# in possession of this copy.
#
# RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the Government
# is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the
# Rights in Technical Data and Computer Software clause at DFARS 52.227-7013
# and in similar clauses in the FAR and NASA FAR Supplement.
#

#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#	This script installs patches from the Solaris distribution image
#	It is run via the JumpStart mechanisms found in 'sbin/suninstall'
#	DO NOT LOG OUTPUT FROM THIS SCRIPT INTO A LOG FILE IN THIS SCRIPT
#	Such output is already being logged into a installation log.
#
#	THIS SCRIPT ONLY HANDLES A STANDALONE INSTALLATION VIA INITIAL
#	INSTALL OR AN UPGRADE.  It does not do the processing (at this
#	time) to install the patches on all the clients of a server.
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# INSTALLROOT is the mountpoint of the filesystems being installed.
INSTALLROOT=/a

# Make sure files aren't world writtable, fixes bugid 4166257
umask 022

# The Solaris distribution image is mounted in the Solaris installation
# environment on "/cdrom" in Solaris install's 'etc/rcS' file.

# Additional Solaris patches that are not part of the MU patch set
# need to go into the <product_name_dir>/Patches' directory
#		Solaris_2.5.1/Patches  or  Solaris_2.6/Patches
# See PSARC/1996/354 and PSARC/1996/133.
#
# SI_OSNAME is a JumpStart environment variable.  See the JumpStart
# documentation in AnswerBook or see "Automating Solaris Installations -
# A Custom JumpStart Guide", Kasper, Paul Anthony, and Alan McClellan,
# SunSoft Press, 1995.
# SI_OSNAME is not set in the environment.  Have to hardcode path until
# a different environment variable can be used.

SI_OSNAME=Solaris_2.7
#SOL_PATCHDIR=/cdrom/${SI_OSNAME}/Patches
SOL_PATCHDIR=/tmp/jump/patch/recommended/7_Recommended

# This may be used in the future for interface version checking between
# the elements of this mechanism.
INTERFACE_VERSION=1.0

PROGNAME=`basename $0`

# Kludge for AdminSuite patchid 104468-06 && bugid 4092420
SADM_PATCH_DIR=${INSTALLROOT}/var/sadm/patch
MU_FLAG=${SADM_PATCH_DIR}/.mu_applied
if [ ! -f ${MU_FLAG} ] ; then
	# Bugid 4105682
	if [ ! -d "${SADM_PATCH_DIR}" ] ; then
		mkdir "${SADM_PATCH_DIR}"	|| exit $?
	fi
	touch ${MU_FLAG}			|| exit $?
fi

# Install any mandatory patches that are on the Solaris distribution
# that are not already part of the Maintenance Update patch set or
# that have to be installed no matter what.
# Try to install all the patches even if any of them fail.
# Original implemention would exit the 'for' loop if any patch failed
# to install without errors.

if [ -d ${SOL_PATCHDIR} ]; then

	cd ${SOL_PATCHDIR}

	# !!!RFE!!! The set of patches to install should be driven by a
	# configuration file listing the set of patches to install, not
	# blindly installing all patches in the directory.
	#
	# Due to bug # 4127000, we are using the same order of how the
	# patches are copied into the Patches directory to install 
	# them via SolStart.  Thus, the "-rt" option is here.
	#
	# For helping early release, Solstart doesnot use -d flag until
	# FCS time to allow patch be backout-able
	# put -d back at FCS time.
	# because of space issue, now all patches donot allow backout
	#/usr/sbin/patchadd -d -R ${INSTALLROOT} \


#	patches=`\ls -rt .` 
	patches=`cat $SOL_PATCHDIR/patch_order`

	status=0
	for patch in $patches ; do
		/usr/sbin/patchadd -d -R ${INSTALLROOT} \
			${SOL_PATCHDIR}/$patch
			ret=$?
			case $ret in
				0)	;;
				8)	;;
				15)	;;
				25)	;;
				*)	status=1
					;;
			esac
	done
fi

exit $status

