#!/bin/sh
#
# @(#)prepatch.src	1.5		02/05/14	SMI
#
# If S8 is installed, the following patches must be installed:
# 
# 	108919-14 CDE Patch
#	109354-14 CDE Patch
#	109887-13 OCF Patch
#
# The version above is the minimum version which must be installed

retval=0

if [ `uname -r` = "5.8" ]
then
   # REQPATCH1 checks the minimum revision of 108919
   REQPATCH1=`showrev -p | sed -n 's/Patch: 108919-\([^ ]*\).*/\1/p' \
	| sort -n | tail -1`
   # REQPATCH2 checks the minimum revision of 109354
   REQPATCH2=`showrev -p | sed -n 's/Patch: 109354-\([^ ]*\).*/\1/p' \
	| sort -n | tail -1`
   # REQPATCH3 checks the minimum revision of 109887
   REQPATCH3=`showrev -p | sed -n 's/Patch: 109887-\([^ ]*\).*/\1/p' \
	 | sort -n | tail -1`

   # Check the installed version against the minimum version
   if [ x"$REQPATCH1" = "x" ] || [ $REQPATCH1 -lt 14 ]
   then
       echo "You must install patch 108919-14 or later before proceeding"
       # force the patchadd to fail
       retval=1
   fi
   
   if [ x"$REQPATCH2" = "x" ] || [ $REQPATCH2 -lt 14 ]
   then
       echo "You must install patch 109354-14 or later before proceeding"
       # force the patchadd to fail
       retval=1
   fi

   if [ x"$REQPATCH3" = "x" ] || [ $REQPATCH3 -lt 13 ]
   then
       echo "You must install patch 109887-13 or later before proceeding"
       # force the patchadd to fail
       retval=1
   fi
fi

exit $retval
