#!/bin/ksh
#
# This script removes the extra space in the "ARCH" entry of the SUNWispm
# pkginfo file so that this package can be patched with patchadd.

PKGDIR=/var/sadm/pkg/SUNWispm

if [[ "$ROOTDIR" != "/" ]]; then
	PKGDIR=$ROOTDIR/var/sadm/pkg/SUNWispm
fi	

# If SUNWispm package is installed...
# Make sure the VERSION of SUNWispm installed and patched pkgs match

if [[ -d $PKGDIR ]]; then 
	installedVers=$(/usr/bin/pkgparam -R $ROOTDIR SUNWispm VERSION)
	installingVers=$(/usr/bin/pkgparam -f $patchdir/SUNWispm/pkginfo VERSION)

	if [[ "$installedVers" != "$installingVers" ]]; then
		echo "Installed and patched versions of SUNWispm pkg don't match"
		exit 1
	fi

	pkginfo=$PKGDIR/pkginfo
	tmp=/tmp/tmp$$

	/usr/bin/sed -e '/ARCH=/s/ //' $pkginfo > $tmp
	/usr/bin/mv $tmp $pkginfo
fi

exit 0

