#!/usr/bin/ksh
#
# PatchNum & ROOTDIR are inherited from patch scripts
#
#
# Remove symbolic links in SUNWcsxu SUNWcsu SUNWtoo
# SUNWtoox introduced by the patch.
#
# This is a workaround for a patchrm bug where symlinks do not
# get removed on backout and also handles not to remove them if
# this patch is installed on top of a previous version or
# accumulated version of this patch.  After files have been
# restored on backout, check to see if there is an existing source
# pointed to by the symlink, if so, assume a previous patch
# installed the file.  If no source exists, meaning sym link 
# points to nothing, remove the sym links. 
   
for SYMLINK in usr/lib/link_audit/64 usr/lib/link_audit/32 \
               usr/lib/secure/64 usr/lib/secure/32
do
	if [ -L ${ROOTDIR}/${SYMLINK} -a ! -a ${ROOTDIR}/${SYMLINK} ]
	then
		echo "Removing symlink ${ROOTDIR}/${SYMLINK}"
		rm -f ${ROOTDIR}/${SYMLINK}

		case $SYMLINK in

		usr/lib/link_audit/64)
			removef -R $ROOTDIR SUNWtoox $SYMLINK
			removef -R $ROOTDIR -f SUNWtoox ;;
		usr/lib/secure/64)
			removef -R $ROOTDIR SUNWcsxu $SYMLINK
			removef -R $ROOTDIR -f SUNWcsxu ;;
		usr/lib/link_audit/32)
			removef -R $ROOTDIR SUNWtoo $SYMLINK
			removef -R $ROOTDIR -f SUNWtoo  ;;
		usr/lib/secure/32)
			removef -R $ROOTDIR SUNWcsu $SYMLINK
			removef -R $ROOTDIR -f SUNWcsu

		esac

	fi
done

exit 0 
