#!/bin/sh

#
# Script to replace symbolic link of /usr/lib/libresolv.so to
# usr/lib/libresolv.so.1 from libresolv.so.2.  This will only
# happen if a previous version of the patch of revision 2 or
# greater isn't installed.
#

PKG_INSTALL_ROOT=$ROOTDIR
PATID=101359
PATVER=02

INFO="$ROOTDIR/var/sadm/pkg/SUNWcsu*/pkginfo"

#       Look for the patch ID in either SUNW_PATCHID or
#       SUNW_OBSOLETES (one at a time since they have
#       different content).
#

if egrep -s "SUNW_PATCHID.*$PATID" $INFO
then
        #
        #       Some version of the patch we depend on has
        #       been installed.  Extract the patch version
        #       number and see whether it's large enough.
        #
        for patch in `egrep "SUNW_PATCHID.*$PATID" $INFO |
                cut -d= -f2 | sort -ur`
        do
                ver=`echo $patch | sed -e "s/.*$PATID-\([0-9]*\).*/\1/"`
                if [ $ver -ge $PATVER ]
                then
			exit 0
		fi
	done
else
        if egrep -s "SUNW_OBSOLETES.*$PATID" $INFO
        then
                #
                #       Patch has been obsoleted.  Its changes,
                #       including the one we care about, must
                #       have been subsumed in the new patch.
                #
                exit 0
	fi
fi

#
# we know the patch has not been previously installed so it's save
# to replace the symbolic link
#
if test -h $PKG_INSTALL_ROOT/usr/lib/libresolv.so
then
        rm $PKG_INSTALL_ROOT/usr/lib/libresolv.so
fi

if test $PKG_INSTALL_ROOT="/"
then
        ln -s /usr/lib/libresolv.so.1 /usr/lib/libresolv.so
else
        ln -s $PKG_INSTALL_ROOT/usr/lib/libresolv.so.1 $PKG_INSTALL_ROOT/usr/lib/libresolv.so
fi



