# checkinstall script to control a patch installation. # directory format options. # # @(#)checkinstall 1.9 02/03/04 SMI # # Copyright (c) 2002 by Sun Microsystems, Inc. # All rights reserved # PATH=/usr/sadm/bin:$PATH NOVERS_MSG="PaTcH_MsG 8 Version $VERSION of $PKG is not installed on this system." ALRDY_MSG="PaTcH_MsG 2 Patch number $SUNW_PATCHID is already applied." TEMP_MSG="PaTcH_MsG 23 Patch number $SUNW_PATCHID cannot be applied until all \ restricted patches are backed out." # Read the provided environment from what may have been a request script . $1 # Old systems can't deal with checkinstall scripts anyway if [ "$PATCH_PROGRESSIVE" = "true" ]; then exit 0 fi # # Confirm that the intended version is installed on the system. # if [ "${UPDATE}" != "yes" ]; then echo "$NOVERS_MSG" exit 3 fi # # Confirm that this patch hasn't already been applied and # that no other mix-ups have occurred involving patch versions and # the like. # Skip=0 active_base=`echo $SUNW_PATCHID | nawk ' { print substr($0, 1, match($0, "-")-1) } '` active_inst=`echo $SUNW_PATCHID | nawk ' { print substr($0, match($0, "-")+1) } '` # Is this a restricted patch? if echo $active_base | egrep -s "R"; then is_restricted="true" # All restricted patches are backoutable echo "PATCH_NO_UNDO=" >> $1 else is_restricted="false" fi for patchappl in ${PATCHLIST}; do # Is this an ordinary patch applying over a restricted patch? if [ $is_restricted = "false" ]; then if echo $patchappl | egrep -s "R"; then echo "$TEMP_MSG" exit 3; fi fi # Is there a newer version of this patch? appl_base=`echo $patchappl | nawk ' { print substr($0, 1, match($0, "-")-1) } '` if [ $appl_base = $active_base ]; then appl_inst=`echo $patchappl | nawk ' { print substr($0, match($0, "-")+1) } '` result=`expr $appl_inst \> $active_inst` if [ $result -eq 1 ]; then echo "PaTcH_MsG 1 Patch number $SUNW_PATCHID is superceded by the already applied $patchappl." exit 3 elif [ $appl_inst = $active_inst ]; then # Not newer, it's the same if [ "$PATCH_UNCONDITIONAL" = "true" ]; then if [ -d $PKGSAV/$SUNW_PATCHID ]; then echo "PATCH_NO_UNDO=true" >> $1 fi else echo "$ALRDY_MSG" exit 3; fi fi fi done # Construct a list of applied patches in order echo "PATCHLIST=${PATCHLIST} $SUNW_PATCHID" >> $1 # # Construct the complete list of patches this one obsoletes # ACTIVE_OBSOLETES=$SUNW_OBSOLETES if [ -n "$SUNW_OBSOLETES" ]; then # Clear the parameter since it has already been used. echo "SUNW_OBSOLETES=" >> $1 # Pass it's value on to the preinstall under another name echo "ACTIVE_OBSOLETES=$ACTIVE_OBSOLETES" >> $1 fi # # Use the first found pkginfo file since all pkginfo files MUST contain # the same patch meta data. This is done since we can never be guaranteed of # where the checkinstall script is located. This will work for all Solaris # releases. # for pkginfo in $INST_DATADIR/*/pkginfo; do tmpRequire=`nawk -F= ' $1 ~ /REQUIR/ { print $2 } ' $pkginfo` tmpIncompat=`nawk -F= ' $1 ~ /INCOMPAT/ { print $2 } ' $pkginfo` break done # # Construct PATCH_INFO line for this package. # if [ -n "$tmpRequire" ] && [ -n "$tmpIncompat" ] then echo "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \ Obsoletes: $ACTIVE_OBSOLETES Requires: $tmpRequire \ Incompatibles: $tmpIncompat" >> $1 elif [ -n "$tmpRequire" ] then echo "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \ Obsoletes: $ACTIVE_OBSOLETES Requires: $tmpRequire Incompatibles: " >> $1 elif [ -n "$tmpIncompat" ] then echo "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \ Obsoletes: $ACTIVE_OBSOLETES Requires: Incompatibles: $tmpIncompat" >> $1 else echo "PATCH_INFO_$SUNW_PATCHID=Installed: `date` From: `uname -n` \ Obsoletes: $ACTIVE_OBSOLETES Requires: Incompatibles: " >> $1 fi # There can be three conditions that exist for this or an older checkinstall # script, listed in order of precedence: # # 1. The checkinstall script is located in $INST_DATADIR/.[] # 2. The checkinstall has been moved to /tmp # 3. An old checkinstall script must handle both 1 and 2. # Check to see if the script has been moved to /tmp by pkginstall. EXECDIR=`dirname $0 | grep "^/tmp/install"` if [ -n "$SUNW_PKG_DIR" ]; then SCRIPTS_DIR="$SUNW_PKG_DIR/install" elif [ -z "$EXECDIR" ]; then SCRIPTS_DIR=`dirname $0` else # The script has been moved to /tmp. This should never happen since S9 # pkginstall only moves the checkinstall script if it detects that it is # not a patch installation. EXT=`echo $ARCH | sed \ -e 's/all//' \ -e 's/sparc\.sun4/\./' \ -e 's/sparc//' \ -e 's/sparcv9//' \ -e 's/i386\.i86pc/\.i/' \ -e 's/i386//'` SCRIPTS_DIR="$INST_DATADIR/$PKGINST$EXT/install" fi echo "SCRIPTS_DIR=$SCRIPTS_DIR" >> $1 # If additional operations are required for this package, place # those package-specific commands here. #XXXSpecial_CommandsXXX# ## # Once off change for u4 FKU SUNWcsr. Needed to work around a deficiency in pkg ## # level script templates causing them not to populate prototype file for undo pkg ## # correctly across object type/class changes. ## # ## # Object 'etc/inet/ipnodes' is delivered as a symlink over the top of an editable ## # file of class 'preserve'. Fix adds object to the undo pkg as 'e preserve'. ## # ## # Object 'etc/inet/hosts' is now delivered as class 'hosts' where it was formerly ## # of class 'preserve'. Fix adds object to the undo pkg as 'e preserve'. ## # ## # ## # This fix is made uprev safe by queuing the specific manipulations required on ## # 'etc/inet/ipnodes' existing as an actual 'file' on the filesystem. After the ## # patch is applied, 'etc/inet/ipnodes' becomes a symlink, causing logic in any ## # higher rev or obsoleting patch to bypass manipulations. ## # ## # This fix involves the following pkg level scripts : ## # checkinstall ## # preinstall ## # i.hosts ## # u.preserve ## # ipnodes=$BASEDIR/etc/inet/ipnodes { [ -f "$ipnodes" -a ! -h "$ipnodes" ] && echo "IPNODES_IS_FILE=true" || echo "IPNODES_IS_FILE=" ; } >> $1 ## # Fix section end. #!/bin/sh # # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "@(#)checkinstall.initd 1.2 05/06/30 SMI" # # checkinstall.initd # # Before we begin installing new files, we need to save the existing files # if the administrator has modified them since their original installation. # To do this, we find 'e' and 'l' entries in the pkgmap, convert their # relative "etc/" prefix to /etc, and them pipe them into pkgchk. For # each file which already exists and whose contents do not match the size or # checksum saved in the package database, we get (^ = start of line): # # ^ERROR: /etc/init.d/somefile # ^ file size <104780> expected <181> actual # ^ file cksum <56515> expected <14331> actual # # We grep for ERROR: followed by a single non-whitespace token, then strip # the leading '^ERROR: ', leaving us a name of a modified file that we # capture in the MODIFIED_AFTER_INSTALLED variable. This variable is written # to the file provided as an argument to the script, in the form of an # environment variable setting. Said file later gets sourced by # the pkgadd command for use in our class action script. case "$ARCH" in sparc.sun4m) EXT=.m;; sparc.sun4u) EXT=.u;; sparc.sun4v) EXT=.v;; i386.i86pc) EXT=.i;; *) EXT="";; esac PKGMAP=$INST_DATADIR/$PKG$EXT/pkgmap MODIFIED_AFTER_INSTALLED="" if [ "$UPDATE" = yes ]; then MODIFIED_AFTER_INSTALLED=` \ awk '($2 == "e" || $2 == "l") && $3 == "initd" {print $4}' $PKGMAP | \ sed -e 's:^etc/:/etc/:' -e 's/=.*$//' | \ pkgchk -R ${PKG_INSTALL_ROOT:-/} -q -i /dev/stdin $PKG 2>&1 | \ grep '^ERROR: [^ ]*$' | sed 's/^ERROR: //' ` fi echo MODIFIED_AFTER_INSTALLED=\"${MODIFIED_AFTER_INSTALLED}\" >> $1 exit 0