#! /bin/sh
#
# Check the target system for the existance of an incompatible version of
# the packages updated by this patch. If an incompatible version is installed,
# then print a message stating that the package  needs to be 
# backed and a compatible version installed before this patch.
#
ROOTDIR=$2
INFO_DIR="$ROOTDIR/var/sadm/pkg"
#
pkgmessage() {
        echo 
        echo "This patch may not be installed on this target system"
        echo "without first removing VERSION $PKGVERSION of package "
        echo "$PKGNAME and installing a compatible version as identified"
        echo "in the patch README special install instructions."
        echo
}

#
checkpkg() {
   PKGNAME=$1
   PKGVERSION=$2

   if [ -d $INFO_DIR/$PKGNAME ]
   then
        INSTVER=`/bin/pkgparam $PKGNAME VERSION`
        if [ "x$INSTVER" = "x$PKGVERSION" ]; then
           pkgmessage
	   exit 1
        fi
   fi
   return 0 
}

#----------------------------------
# Main
#
# Call the checkpkg function for each package
# we care about. It will exit with an error as
# soon as a match is found. Otherwise it will
# return here.
#----------------------------------
checkpkg SUNWjaxp   7.0,REV=2003.04.30.22.55
checkpkg SUNWxrgrt  7.0,REV=2003.04.30.22.55
checkpkg SUNWxrpcrt 7.0,REV=2003.04.30.22.55
checkpkg SUNWxsrt   7.0,REV=2003.04.30.22.55

#
# If we make it here no incompatible version of the package was found and
# we can return to installpatch.
exit 0
