
# Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
#
# 10/07/02 @(#)preremove	1.5


# preremove script for Netscape package.
 
#
# Return pid of named process in variable "pid"
#
# Exit codes for installation scripts
 
export BASEDIR
 
e_ok=0
e_fatal=1      # stop installation on this exit
e_warning=2    # Installation will go on.
e_int=3        # Interrupted. Stop installation
e_reboot=10    # User must reboot after installation of all selected packages
e_rebootnow=20 # User must reboot right after installation of current package
               # To be added to one of the single-digit exit codes above
 
#
# Trap interrupt
#
trap `exit $e_int` 15
#

# test to see if BASEDIR of the CDE & Netscape are the same
if [ "$PKG_INSTALL_ROOT" != "" ]; then
	BASEDIR_CDE=`pkginfo -R ${PKG_INSTALL_ROOT} -l SUNWdtbas | grep BASEDIR | sed 's/BASEDIR: *//' | sed 's/ *//'`
else
	BASEDIR_CDE=`pkginfo -l SUNWdtbas | grep BASEDIR | sed 's/BASEDIR: *//' | sed 's/ *//'`
fi

# do the following only if the package is installed
if [ "$PKG_INSTALL_ROOT" != "" ]; then
	pkginfo -R ${PKG_INSTALL_ROOT} -q $PKGINST
else
	pkginfo -q $PKGINST
fi
if [ $? -eq 0 ]
then
	if [ -h $BASEDIR/SUNWns/plugins/libjavaplugin_oji.so ]; then
		rm -f $BASEDIR/SUNWns/plugins/libjavaplugin_oji.so
	fi
	if [ -h $BASEDIR/SUNWns/java ]; then
		rm -f $BASEDIR/SUNWns/java
	fi
        if [ -h ${PKG_INSTALL_ROOT}$BASEDIR_CDE/dt/bin/sun_netscape ]; then
                rm -f ${PKG_INSTALL_ROOT}$BASEDIR_CDE/dt/bin/sun_netscape
        fi
fi


installedchrometxt=$BASEDIR/SUNWns/chrome/installed-chrome.txt
chromerdf=$BASEDIR/SUNWns/chrome/chrome.rdf

# update installed-chrome.txt
if [ -f $installedchrometxt ] ; then
	diff $installedchrometxt $BASEDIR/SUNWns/chrome/installed-chrome.txt.en-US | \
		grep '^<' | sed -e 's/^< //' > /tmp/$$installed-chrome.txt.new
	count=`cat /tmp/$$installed-chrome.txt.new | wc -l`
	if [ $count -eq 0 ]; then
		rm -r $installedchrometxt
	else
		cat /tmp/$$installed-chrome.txt.new > $installedchrometxt
	fi
	rm -f /tmp/$$installed-chrome.txt.new
fi

# update chrome.rdf
/bin/rm -f $chromerdf

if [ -f $chromerdf ] ; then
	diff $chromerdf $BASEDIR/SUNWns/chrome/chrome.rdf.en-US | \
		grep '^<' | sed -e 's/^< //' > /tmp/$$chrome.rdf.new
	count=`cat /tmp/$$chrome.rdf.new | wc -l`
	if [ $count -eq 4 ]; then
		rm -r $chromerdf
	else
		cat /tmp/$$chrome.rdf.new > $chromerdf
	fi
	rm -f /tmp/$$chrome.rdf.new
fi	

#
exit $e_ok
 

