#! /bin/sh
#
#    Look for file /var/tmp/fd6u2
#    if it exists, then it contains the path to FD6u2 installation
#    else
#       use "pkginfo -q SPROws; pkgparam SPROws BASEDIR" to get
#       the most obvious Nozomi location, to be used as the default
#       when asking user for the path to fd6u2
#
#       ask user for the path to fd6u2
#    fi
#
#    test to see if user supplied $BASEDIR path or $PATH path
#       strip back as necessary to get $BASEDIR

if [ "${FD6U2PATH}" = "" ]; then
  if [ -r /var/tmp/fd6u2 ]; then
    FD6U2PATH=`cat /var/tmp/fd6u2`
  else
    /usr/bin/pkginfo -q SPROws
    if [ "$?" = "0" ]; then
      ver=`/usr/bin/pkgparam SPROws SUNW_PRODVERS`
      if [ "${ver}" = "6.2" ]; then
        FD6U2PATH=`/usr/bin/pkgparam SPROws BASEDIR`
      fi
    fi

    if [ "${FD6U2PATH}" = "" ]; then
      FD6U2PATH=`ckpath -aoy \
	-p "Enter path to Forte Developer 6 update 2"` || exit $?
    else
      FD6U2PATH=`ckpath -d ${FD6U2PATH} -aoy \
	-p "Enter path to Forte Developer 6 update 2 (${FD6U2PATH})"` || exit $?
    fi
  fi
fi

if [ "${FD6U2PATH}" = "" ]; then
  echo "Path to FD6u2 not valid: '${FD6U2PATH}'"
  exit 1
elif [ -d ${FD6U2PATH}/WS6U2 ]; then
  FD6U2PATH=${FD6U2PATH}
elif [ -d ${FD6U2PATH}/SUNWspro/WS6U2 ]; then
  FD6U2PATH=${FD6U2PATH}/SUNWspro
else
  temp=`dirname ${FD6U2PATH}`
  if [ -d ${temp}/WS6U2 ]; then
    FD6U2PATH=${temp}
  else
    echo "Path to FD6u2 not valid: '${FD6U2PATH}'"
    exit 1
  fi
fi

cat >$1 <<!
FD6U2PATH=${FD6U2PATH}
!

