#!/bin/perl
# This script gathers the OS version, makes sure it is the required version
# for this patch. It then checks to make sure the patches required by this
# patch are installed.

$OS=`uname -r`;

if($OS =~ /5.8/){
        $REQUIRED = "117002";
        $REQREV = "03";
}elsif($OS =~ /5.9/){
        $REQUIRED = "113027";
        $REQREV = "04";
}else{
        print "This patch is for s8 and s9 only!\n";
        exit 1;
}
$SHOW=`showrev -p | grep $REQUIRED`;
@LIST = split(/\n/, $SHOW);
foreach (@LIST){
	(@tmp) = split(/\s+/);
	($patch) = $tmp[1];
	($base, $rev) = split(/-/, $patch);
	if("$REQUIRED" eq "$base"){
		if("$rev" ge "$REQREV"){
			exit 0;		# Required patch is installed
		}
	}
}

print "This patch requires patch $REQUIRED-$REQREV or higher.\n";
exit 1;
