#!/bin/sh
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"@(#)preinstall	1.1	08/05/06 SMI"

PATH=/usr/bin:/usr/sbin

#
# Check for the existence of the unbundled pkg data to see if we need to
# cleanup the pkg metadata.
#
if [ ! -f $BASEDIR/usr/lib/brand/solaris8/files/patches/order ]; then
	# No unbundled, done.
	exit 0
fi

#
# The unbundled data is on the system, see of the unbundled pkg exists.
#
if [ -d $BASEDIR/var/sadm/pkg/SUNWs8brandk ]; then
	# The unbundled pkg is already installed, done.
	exit 0
fi

#
# The unbundled files are installed on the system but the pkg data
# is incorrect.  Clean it out of this pkg.
#
removef -R $BASEDIR SUNWs8brandu \
    /usr/lib/brand/solaris8/files/patches >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu \
    /usr/lib/brand/solaris8/files/patches/order >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu \
    /usr/lib/brand/solaris8/files/patches/109147-44.zip >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu \
    /usr/lib/brand/solaris8/files/patches/111023-03.zip >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu \
    /usr/lib/brand/solaris8/files/patches/111431-01.zip >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu \
    /usr/lib/brand/solaris8/files/patches/112605-04.zip >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu \
    /usr/lib/brand/solaris8/files/patches/112050-04.zip >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu \
    /usr/lib/brand/solaris8/files/patches/109221-01.zip >/dev/null 2>&1

removef -R $BASEDIR SUNWs8brandu /usr/share >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu /usr/share/man >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu /usr/share/man/man5 >/dev/null 2>&1
removef -R $BASEDIR SUNWs8brandu /usr/share/man/man5/solaris8.5 >/dev/null 2>&1

removef -R $BASEDIR -f SUNWs8brandu >/dev/null 2>&1

exit 0
