#!/usr/bin/ksh
# $Id: checkinstall,v 3.9 2002/07/09 07:57:40 yalla Exp $  - %Q%
#ident "%Z%isis:$RCSfile: checkinstall,v $ $Revision: 3.9 $"

# Copyright(C)2000 VERITAS Software Corporation.  ALL RIGHTS RESERVED.
# UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
# LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
# IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
# OR DISCLOSURE.
# 
# THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
# TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
# OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
# EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE.
# 
#               RESTRICTED RIGHTS LEGEND
# USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT IS
# SUBJECT TO RESTRICTIONS AS SET FORTH IN SUBPARAGRAPH
# (C) (1) (ii) OF THE RIGHTS IN TECHNICAL DATA AND
# COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013.
#               VERITAS SOFTWARE
# 1600 PLYMOUTH STREET, MOUNTAIN VIEW, CA 94043

#
# Perform checkinstall processing for the ISIS package.
#

PATH=/usr/sadm/bin:/sbin:/usr/sbin/:/usr/bin:/bin:$PATH
REVISION=3.0.2.272
INCOMPLETEINSTALL="You have an incomplete installation of VRTSobgui on your system. Please remove it before installing this version of VRTSobgui"
FOUND="Found VRTSobgui"
NEWERVER="A newer version of Isis is already installed"
SAMEVER="already installed."
USEADMINFILE="You need to use the VRTSobadmin file provided"

#
# If BASEDIR parameter is modified in request script, the modified value
# is not available here.
#
#
# $PKG_INSTALL_ROOT is nothing when user does not specify -R "root_dir".
# In preintsall, postinstall, preremove, postremove scripts $BASEDIR is
# $PKG_INSTALL_ROOT$CLIENT_BASEDIR.
# For example, if $PKG_INSTALL_ROOT is root_dir, $CLIENT_BASEDIR is /opt/VRTSob, then
# $BASEDIR is root_dir/opt/VRTSob.
#

#
# It should be noted that $BASEDIR and $CLIENT_BASEDIR are /opt/VRTSob in
# request and checkinstall scripts irrespective of $PKG_INSTALL_ROOT existance.
# By the time preinstall, postinstall, preremove and postremove scripts
# are executed BASEDIR itself is relocated to $PKG_INSTALL_ROOT and takes on the value
# $PKG_INSTALL_ROOT$BASEDIR. Where as $CLIENT_BASEDIR is same as erlier $BASEDIR.
#


if [ "X$PKG_INSTALL_ROOT" = "X" ]
then
    JUMPSTART_PATH="/"
else
    JUMPSTART_PATH=$PKG_INSTALL_ROOT
fi


   #
   # Check if an VRTSobgui package is already installed.
   #

   if pkginfo -R $JUMPSTART_PATH -l VRTSobgui >/dev/null 2>&1
   then

#       INSTANCE=`echo $PKGINST | sed -e s#VRTSobgui##g`
#       if [ "X$INSTANCE" != "X" ]

       if [ "X$UPDATE" != "Xyes" ]
       then
           errstr -e "$USEADMINFILE"
           exit 3
       fi

       if pkginfo -R $JUMPSTART_PATH -il VRTSobgui 2>/dev/null >/dev/null
       then
           echo ""
       else
           errstr -e "$INCOMPLETEINSTALL"
           exit 3
       fi

       revision=`pkgparam -R $JUMPSTART_PATH VRTSobgui REV` 2>/dev/null

       #
       # Check if a newer package is already installed.
       #
       if expr "$revision" \> "$REVISION" 2>/dev/null >/dev/null
       then
           errstr -e "$FOUND $revision $NEWERVER"
           exit 3
       fi

       #
       # Check whether the same package is installed.
       #
       if expr "$revision" = "$REVISION" 2>/dev/null >/dev/null
       then
           puttext -l 5 "$REVISION $SAMEVER"
           exit 3
       fi
       echo "PREVIOUS_INSTALL=yes" > $1
   else
       echo "PREVIOUS_INSTALL=no" > $1 
   fi
 
exit 0
