#!/usr/bin/ksh
#
#
# PatchNum & ROOTDIR are inherited from patch scripts
#
#
# Remove symbolic links in SUNWsclb, SUNWsclbx and SUNWsc
# 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. 
   

[ "$ROOTDIR" = / ] && ROOTDIR=""
 
TOP32=$ROOTDIR/opt/SUNWcluster/lib
TOP64=$ROOTDIR/opt/SUNWcluster/lib/sparcv9
LINK_lib=libscutil.so

for SYMLINK in $TOP32/$LINK_lib $TOP64/$LINK_lib 
do
         if [ -L $SYMLINK -a ! -a $SYMLINK ]
         then    
            echo "Removing symlink $SYMLINK"
            rm -f $SYMLINK

            if echo $SYMLINK | egrep -s sparcv9
            then
                removef SUNWsclbx $SYMLINK
                removef -f SUNWsclbx
            else
                removef SUNWsclb $SYMLINK
                removef -f SUNWsclb
             fi
        fi
done

exit 0
