# Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
#
# ident "@(#)preremove	1.2 07/09/03"

# preremove script
 
#
# Return pid of named process in variable "pid"
#
# Exit codes for installation scripts
 
export BASEDIR
 
mozdir=$BASEDIR/sfw/lib/mozilla

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
#

installedchrometxt=$mozdir/chrome/installed-chrome.txt
chromerdf=$mozdir/chrome/chrome.rdf
overlayinfo=$mozdir/chrome/overlayinfo
suffix=mozmail
compregdat=$mozdir/components/compreg.dat
xptidat=$mozdir/components/xpti.dat

# update installed-chrome.txt
if [ -f $installedchrometxt ] ; then
	diff $installedchrometxt $mozdir/chrome/installed-chrome.txt.$suffix | \
		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 and overlayinfo
/bin/rm -f $chromerdf
/bin/rm -rf $overlayinfo
/bin/rm -f $compregdat
/bin/rm -f $xptidat

if [ -f $installedchrometxt ] ; then
	LD_LIBRARY_PATH=$mozdir/:$mozdir/components
	MOZILLA_FIVE_HOME=$mozdir
	export LD_LIBRARY_PATH MOZILLA_FIVE_HOME
	$MOZILLA_FIVE_HOME/regchrome
fi
#
exit $e_ok
 

