#!/bin/sh

# @(#)prePatch	1.1	00/06/09

# If the patch 108303-02 exists on the system it must be removed
# before the current patch may be added
#
# No need to test for later revs as if 108303-02 is installed,
# no later rev can be installed.  If a later rev is installed
# the -02 rev must have either never been installed or previosly
# removed

ROOTDIR=${2:-/}

#
# we can't use showrev(1M) here as this can break if this patch
# is being added during a jumpstart. patchadd -p does the trick though
#
PATCHEXISTS=`patchadd -p | awk '/Patch: 108303-02/ { print $2 }' 2>/dev/null`

if [ "$PATCHEXISTS" = "108303-02" ]; then
	echo "Removing instance of 108303-02"

	if [ "$ROOTDIR" != "/" ]; then
		patchrm -R $ROOTDIR 108303-02 > /tmp/.patchrm$$ 2>&1
	else
		patchrm 108303-02 > /tmp/.patchrm$$ 2>&1
	fi

	if [ $? -ne 0 ]; then
		echo "Removal of 108303-02 failed"
		echo "See error log at /tmp/.patchrm$$"
		exit 1
	fi
fi

exit 0
