#! /bin/sh 
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#
# Check for JFCA
[ -z "$ROOTDIR" ] && ROOTDIR=/

version=`/usr/sbin/patchadd -R $ROOTDIR -p | \
	nawk '$2 ~ /114878/{printf "%d\n", substr($2,8,2)}' | \
	sort | tail -1`

if [ -n "$version" ]; then
  # Patch 114878 is installed.

  # Check obsoleted field
  /usr/sbin/patchadd -R $ROOTDIR -p | \
	nawk -F: '{print $3}' | grep 114878 > /dev/null

  if [ $? -ne 0 ] ; then
    # Patch 114878 is not obsoleted by newer patch

    if [ $version -le 7 ] ; then
      echo "This patch is not compatable with 114878-07 (or earlier)."
      echo "See README for details."
      echo "Aborting install."
      exit 1
    fi

  fi
fi

#
# Check for SUNWsan

pkginfo -R $ROOTDIR SUNWsan > /dev/null 2>&1
[ $? -eq 0 ] && exit 0

echo "This patch requires the installation of \c"
echo "the Sun SAN Foundation Kit, SUNWsan."
echo
echo "Please load the package SUNWsan before continuing \c"
echo "with this patch installation."
echo

exit 1
