#!	/sbin/sh
########
#  Product: vmProvider 
#  Fileset: VM-PROV-CORE
#  checkinstall
########
#
# (c) Copyright Hewlett-Packard Company 2005-2006
#
########
    typeset -r UTILS=/usr/lbin/sw/control_utils
    if [ ! -f $UTILS ]
    then
	echo "ERROR:   Cannot find $UTILS"
	exit 1
    fi
    . $UTILS

exitval=$SUCCESS

###############################################################################
# This script will detect whether there is a T2767BC bundle < A.02.xx 
# installed on the system and require that the T2767BC bundle be 
# removed/upgraded before installing VMprovider A.02.xx
# If T2767BC / VMProvider are both being upgraded, then installation will proceed.
# Choosing to install VMProvider >= A.02.xx with HPVM < A.02.xx will fail.
# VMProvider A.01.xx is only compatible with HPVM A.01.xx
# VMProvider A.02+ is anticipated to be compatible with HPVM, version A.02+ 
################################################################################

##########################################################################
# Check if the T2767BC product < A.02.xx is installed on the system.
##########################################################################

PATH=$PATH:/usr/bin

# Find the revision of the T2767BC bundle, if it is installed.
hpvm_core_rev=`get_sw_rev HPVM.HPVM-CORE` 

# Cut out the 1st 2 digits of the revision string for VMProvider, since 
# the compatibility facter is in the major number.
hpvm_core_revision=`echo $hpvm_core_rev | cut -d ' ' -f 1`

# If an empty string is returned by get_sw_rev, then the bundle is not currently installed
if [[ -z $hpvm_core_revision ]]
then
    release=2
fi

is_software_selected HPVM.HPVM-CORE ; hpvm_selected=$?


# version=1, bundles are incompatible, version=2, they are compatible
# If the versions are incompatible, then only install if VMProvider is selected for upgrade.
if [[ $hpvm_core_revision -eq 1 ]]
	then

	if [[ $hpvm_selected -eq 1 ]]
	# 1=T2767BC not selected
	# 0=T2767BC selected
		then
			# If T2767BC is installed and version <A.02.xx, then FAIL, and give an error.
			# unless T2767BC is selected for upgrade.
			msg "ERROR:   T2767BC versions A.02.xx are only supported with "
			msg "         VMProvider versions A.02.xx.  " 
			msg "         Please remove the T2767BC bundle, version A.01.xx "
			msg "         before proceeding, or install a newer version of T2767BC."
			exitval=$FAILURE
	fi
fi

exit $exitval
