#!/bin/sh
#ident "@(#)preinstall	1.1 99/12/17 SMI"

PATH=/usr/bin:$PATH
export PATH

found=""
program=`basename $0`

# error "description"
error=0
Error () {
    if [ $error -eq 0 ]; then
        printf "Error: %s:\n" "${program}" 2>&1
    fi
    printf "       %s\n" "$*" 2>&1
    error=1
}

pkglist=`pkginfo -x SUNWmc.* | sort -r | nawk ' /SUNW/{printf(" %s", $1) } '`
for x in $pkglist; do
        if [ "$x" = "." ]; then continue; fi
        b=`pkgparam $x BASEDIR`
        model=`pkgparam $x ARCH`

	if [ "$model" != "$ARCH" ]; then
		continue
	else
		found="true"
		if [ "$b" != "$BASEDIR" ]; then
			Error "BASEDIR for $x and $PKG should be the same." 
			Error "Cannot install $PKG with a BASEDIR different from $x" 
		fi	
	fi
done

exit $error
