#
#
# Removal script for the OWconfig class
# Remove any extries that belong to this package
# Delete the file if it's empty
# Since the OWconfig entries should only be removed once, and
# since it is assumed that the native architecture's packages are
# installed before alternate architecture's, the binary is only
# executed for a native install.
#

root=${PKG_INSTALL_ROOT:-/}

if [ `/bin/uname -p` = "$ARCH" ] ; then
	echo "removing KCMS entries from OWconfig"
	if [ -f $BASEDIR/openwin/server/etc/OWconfig ] ||
	   [ -f $BASEDIR/../etc/openwin/server/etc/OWconfig ] ; then
		if [ -f $BASEDIR/openwin/share/etc/OWconfig_entries ] && 
		   [ -f $BASEDIR/openwin/lib/libX11.so ] &&
		   [ -f $BASEDIR/openwin/lib/libXext.so ] &&
		   [ -f $BASEDIR/openwin/lib/libowconfig.so ] ; then	
			$BASEDIR/openwin/share/etc/OWconfig_entries -r $root
		fi
	fi
	if [ -f $BASEDIR/openwin/share/etc/OWconfig_entries ] ; then
		rm -rf $BASEDIR/openwin/share/etc/OWconfig_entries
	fi
fi

OW_CONFIG_DIR=$BASEDIR/openwin/server/etc
OW_CONFIG=$OW_CONFIG_DIR/OWconfig
TMP_OW_CONFIG=/tmp/OWconfig

if [ -f $OW_CONFIG ]; then
   if [ ! -w $OW_CONFIG ]; then
        echo "Error: $OW_CONFIG not writeable"
   else
#######################################################
#  Search for SUNWX3D-PEX and delete the entry
#  return this file back to its original state
#######################################################
        \awk '
                BEGIN {
                        i = 0
                        j = 0
                        lines = 0
                }
                {
                        i = index($0, "#")
                        j = index($0, "SUNWX3D-PEX")
                        if (i != 0 && j != 0 && i < j) {
                             lines = 5
                        }
                        if (lines > 0) {
                             lines--
                        }
                        else
                             print $0
                }' < $OW_CONFIG > $TMP_OW_CONFIG
        # copy back the original file
        \cp $TMP_OW_CONFIG $OW_CONFIG
        \rm $TMP_OW_CONFIG
   fi
fi

exit 0
# Removal script for the OWconfig class
# Remove any extries that belong to this package
# Delete the file if it's empty
# Since the OWconfig entries should only be removed once, and
# since it is assumed that the native architecture's packages are
# installed before alternate architecture's, the binary is only
# executed for a native install.
#

root=${PKG_INSTALL_ROOT:-/}

if [ `/bin/uname -p` = "$ARCH" ] ; then
	echo "removing KCMS entries from OWconfig"
	if [ -f $BASEDIR/openwin/server/etc/OWconfig ] ||
	   [ -f $BASEDIR/../etc/openwin/server/etc/OWconfig ] ; then
		if [ -f $BASEDIR/openwin/share/etc/OWconfig_entries ] &&
		   [ -f $BASEDIR/openwin/lib/libX11.so ] &&
		   [ -f $BASEDIR/openwin/lib/libXext.so ] &&
		   [ -f $BASEDIR/openwin/lib/libowconfig.so ] ; then   
			$BASEDIR/openwin/share/etc/OWconfig_entries -r $root
		fi
	fi
	if [ -f $BASEDIR/openwin/share/etc/OWconfig_entries ] ; then
		rm -rf $BASEDIR/openwin/share/etc/OWconfig_entries
	fi
fi
exit 0
