# This script deletes the used backout data for a patch package
# and removes the deletes file entries.
#
# directory format options.
#
#       @(#)patch_postinstall 1.3 98/07/29 SMI
#
# Copyright (c) 1995 by Sun Microsystems, Inc.
# All rights reserved
#

PATH=/usr/sadm/bin:$PATH
THIS_DIR=`dirname $0`

Our_Deletes=$THIS_DIR/deletes

#
# Delete the used backout data
#
if [ -f $Our_Deletes ]; then
	cat $Our_Deletes | while read path; do
		if valpath -l $path; then
			Client_Path=`echo "$CLIENT_BASEDIR/$path" | sed "s|//|/|"`
		else	# It's an absolute path
			Client_Path=$path
		fi
		rm `removef $PKGINST $Client_Path`
	done
	removef -f $PKGINST

	rm $Our_Deletes
fi

#
# Remove the deletes file, checkinstall and the postinstall
#
rm -r $PKGSAV/$ACTIVE_PATCH
rm -f $THIS_DIR/checkinstall $THIS_DIR/postinstall

#
                           # Rebuilds the fonts.dir files if mkfontdir exists otherwise does nothing
                           #

                           FONTINSTDIR=$BASEDIR/openwin/lib/X11/fonts
                           export FONTINSTDIR

                           if [ `/bin/uname -p` = "$ARCH" ] ; then
                                   EXEC_BASE=$BASEDIR
                           else
                                   if [ $BASEDIR != "/usr" ]; then 
                                           EXEC_BASE=${BASEDIR}
                                   else
                                           EXEC_BASE=/usr
                                   fi
                           fi

                           if [ $EXEC_BASE != "/usr" ]; then 
                                   LD_LIBRARY_PATH=$EXEC_BASE/openwin/server/lib:$EXEC_BASE/openwin/lib 
                                   export LD_LIBRARY_PATH 
                           fi

                           if [ -x $EXEC_BASE/openwin/bin/mkfontdir ]; then
                               for dir in Type1/outline
                               do
                                   if [ -d $FONTINSTDIR/$dir ]; then
                                     (
                                           cd $FONTINSTDIR/$dir
                                           $EXEC_BASE/openwin/bin/mkfontdir . || exit 2
                                           $EXEC_BASE/openwin/lib/installalias fonts.alias.req . 
                                     )
                                   fi
                               done
fi 


exit 0
