#!/sbin/sh
###############
# Product: PHKL_25010
# Fileset: PHKL_25010
# postremove
# @(#) postremove  $Revision: AUTO-GENERATED PATCH_11.00 (PHKL_25010)
#------------------------------------------------------------------#
# (c)Copyright 1983-2001 Hewlett-Packard Co., All Rights Reserved. #
#------------------------------------------------------------------#
# SD postremove script template for 11.X patches.                  #
#------------------------------------------------------------------#
# This file is optional for all 11.X patches.  The purpose of this #
# script is to perform any necessary cleanup actions after the     #
# patch's files have been removed.                                 #
#------------------------------------------------------------------#

_PATCHID=PHKL_25010

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
#%# <static: PHKL_20478>
#%#
########
#
# 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_master=$SW_ROOT_DIRECTORY/usr/conf/master.d/usb

########
# 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()
{
   driver=$1
   mod_systemfile ${SW_SYSTEM_FILE_PATH} -d $driver
   if [[ $? -ne $SUCCESS ]]
   then
       print "WARNING: The attempt to remove driver \"$driver\" from the "
       print "         system file has failed for the above reason.  This "
       print "         will cause a 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 hcd
   DeleteDriverEntry usbd
   DeleteDriverEntry hub
   DeleteDriverEntry hid
fi
#%#
#%# </static: PHKL_20478>


#%# DO NOT REMOVE ANYTHING AFTER THIS LINE
#%# <PATCH CONTROL SCRIPT LOG>
#%# PHKL_20478
#%# </PATCH CONTROL SCRIPT LOG>
 
##### END_OF_CUSTOMIZATION
exit $exitval