#!/sbin/sh
##############
# Product: OS-Core
# Fileset: CORE2-KRN
# postremove (SuperIO IDE)
################
#
# (c) Copyright Hewlett-Packard Company, 1998,1999
#

_PATCHID=PHKL_24282

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

########
#
# The driver references should only be removed when it is clear that they
# cannot be useful.  This includes all of the Boot drivers potentially added 
# by this patch. 
#     
# To work for the future, we need to wait until the postremove time to check
# if the definitions of the drivers are gone.
#
########

driver=side
driver_master=$SW_ROOT_DIRECTORY/usr/conf/master.d/side

########
# FUNCTIONS
########
# DeleteDriverEntry
#
# input: $1 - (string) the driver
#
# Purpose: To delete from the driver delivered by this patch from the 
#          system file.  It is OK if the driver does not get removed,
#          but it is cleaner if it is.
#
DeleteDriverEntry()
{
   mod_systemfile ${SW_SYSTEM_FILE_PATH} -d $1
   if [[ $? -ne $SUCCESS ]]
   then
       print "WARNING: The attempt to remove driver \"$driver\" from the system "
       print "         file has failed for the above reason.  This will cause a "
       print "         WARNING during kernel build."
       exitval=$WARNING
   else
       print "NOTE:    Removed \"$driver\" from ${SW_SYSTEM_FILE_PATH}."
   fi
} #DeleteDriverEntry()

###########################################################################
# MAIN
#

grep PATCH_11 $driver_master > /dev/null 2>&1
master_1100=$?

# If the driver's master file is not on the system or the 10.20 version
# of the master file is the only one on the system, remove the  driver 
# from the system file.
if [ ! -f $driver_master ] || [ $master_1100 -ne 0 ]
then
   DeleteDriverEntry $driver
fi
exit $exitval
