#!/bin/ksh

KU_PATCH_BASE=118844
INCOMPAT_KU_REVS="12 13 14 15"

GetKuPatches() {
	typeset -r ku_patch_base=$1
	typeset -r root_dir=${ROOTDIR:-/}

	showrev -R $root_dir -p | grep "Patch: $ku_patch_base" | \
		awk '{print $2}'
}

typeset -r installed_ku_patches=$(GetKuPatches $KU_PATCH_BASE)

typeset ku_patch= incompat_revs=
for ku_patch in $installed_ku_patches ; do
	for ku_rev in $INCOMPAT_KU_REVS ; do
		if [ "$ku_patch" = "${KU_PATCH_BASE}-${ku_rev}" ] ; then
			incompat_revs="$incompat_revs $ku_patch"
		fi
	done
done

if [ -n "$incompat_revs" ] ; then
	msg="This patch is INCOMPATIBLE with $incompat_revs"
	echo "$msg patch(es) installed on the system" >&2
	exit 1
else
	exit 0
fi
