#!/bin/ksh


rmpkg=SUNWusb
addpkg=SUNWckr
kbtrans=/kernel/misc/sparcv9/kbtrans

relocate_kbtrans() {


        if [ ! -f $ROOTDIR/$kbtrans ] ; then
                return
        fi

	## This patch will add kbtrans to SUNWckr.  Manually remove it from SUNWusb
	## if it exists
	##
	Pgk=`pkgchk -R $ROOTDIR -l -p $kbtrans | grep $rmpkg`
	if [ "$?" =  "0" ] ; then
		removef -R $ROOTDIR $rmpkg $ROOTDIR/$kbtrans 1>/dev/null 2>&1
		removef -R $ROOTDIR -f $rmpkg
		installf -R $ROOTDIR $addpkg $ROOTDIR/$kbtrans
		installf -R $ROOTDIR -f $addpkg
	fi
}

if [ "$ROOTDIR" != "/" ]; then
    	# Handle diskless, alternate root case.
	relocate_kbtrans
    	return
fi

if [ -x '/usr/bin/zonename' ] ; then
	if [ `/usr/bin/zonename` != "global" ] ; then
		# We are in a local zone
		# kbtrans is taken care of in global zone.
		return
	else
		# In a global zone
		relocate_kbtrans
	fi
else
  	# we are in the global zone or on a system
   	# without zones support.
   	relocate_kbtrans
fi
