#!/sbin/sh
#------------------------------------------------------------------#
#
# HPUX_ID: @(#) $Revision: 11.4 $ generated on Fri Oct  1 05:16:35 PDT 1999
#
# (c)Copyright 1983-1999 Hewlett-Packard Co.,  All Rights Reserved.
#
#------------------------------------------------------------------#
# SD checkremove script template for 11.X patches.                 #
#------------------------------------------------------------------#
# This file is optional for all 11.X patches.  The purpose of this #
# script is to ensure that there is no patch specific restriction  #
# to removing the selected software from the target system.        #
#------------------------------------------------------------------#

_PATCHID=PHCO_24148     # <------- Change this to real patch ID

UTILS="/usr/lbin/sw/control_utils"

if [ ! -f $UTILS ]; then
    echo "ERROR:   Cannot find $UTILS"
    exit 1
fi

. $UTILS
exitval=$SUCCESS

#####
##### Insert any code you may require at this point in the script.
##### Pay attention to the exitval variable and set appropriately
##### in your code.  If you are unsure as to what types of operations
##### are legal in this file and what types aren't, consult the 
##### "Guidelines for SD Control Scripts" document.
#####
##### START_CUSTOMIZATION_HERE

########################### JFS3.3 Customization Start #######################
# Since we can't use a patch ID for a prerequisite in the JFS 3.3 packaging,
# the 'checkremove' in this patch prevents the patch from being removed
# if the JFS 3.3 product (JFS) is installed.  If we remove the enabling patches
# for ACLs and we call one of the JFS ACL commands, the system could
# panic.  The goal of this section of the script is to prevent this 
# from happening.

# This section of the script needs to be included in all future patches that 
# supersede PHKL_19991.  No change is needed to this part of the script, it 
# can be included as it is.

BASE_PATCH="PHCO_19491"         # First patch with JFS3.3 functionality
                                # Do NOT change for future, superseding
                                # patches.


type=""                         # Determines what product we're dealing
                                # with.  Both HP and Veritas have
                                # versions of JFS3.3.  If this variable
                                # is NULL we can remove this patch
                                # because no 3.3 product is on the system.

# We only need to check if we're on an 11.00 system.  In 11.1X JFS3.3
# is installed with the OS 

if [ "`uname -r`" = "B.11.00" ]
then
        # Add other products to check for at the end of the 'for' line.
        for i in JFS VRTSvxfs
        do
                if swlist $i > /dev/null 2>&1
                then
                        type=$i
                fi
        done
fi

if [ ! -z "$type" ]
then
        if is_software_selected $type
        then
                : It is OK to let this patch get removed
        else

                # Check to see that swlist executes correctly.  If this
                # file is created, all is well.
                swlist_ok=${TMPDIR:-/var/tmp}/$$.swlist_ok

                rm -f $swlist_ok                # Make sure there isn't one
                                                # already there

                # Check to see if a patch other than this patch is installed
                # that contains or supersedes the original 3.3 functionality
                # patch.
                # The logic is that if the patch that first had the JFS 3.3
                # functionality appears in the output of superseded,
                # or installed patches (excluding the one we're removing), then
                # we're ok to remove.

                if swlist -l patch -a supersedes 2>/dev/null 
                then
                        touch $swlist_ok        # swlist execution worked
                fi |
                        egrep -v "^[    ]+$_PATCHID" |
                        egrep "^[       ].*$BASE_PATCH" > /dev/null

                grep_rv=$?

                if [ \( -f $swlist_ok \) -a \( $grep_rv -eq 0 \) ]
                then
                        : It is OK to remove. A superseded patch will be on the system
                elif [ -f $swlist_ok ]
                then
cat << !
ERROR:   This patch, $_PATCHID, must be installed for the installed
         JFS3.3 product ($type) to function properly.  To remove this 
         patch, $_PATCHID, you must first remove the $type product.
!

                        exitval=$FAILURE
                else

cat << !
WARNING: This patch, $_PATCHID, should not be removed because an
         installed JFS3.3 product ($type) depends upon it.  It could 
         not be determined whether an older patch will still satisfy
         JFS3.3's dependency after $_PATCHID is removed.
!

                fi

                # Remove temporary file, don't complain if it wasn't created
                rm -f $swlist_ok
        fi
fi

########################### JFS3.3 Customization End #######################

exit $exitval

