#!/sbin/sh

########
#  Product: GraphicsPHIGSRT
#  Fileset: PHIGS-RUN
#  postremove
#  @(#) $Revision: 206.1 $
########
#
# (c) Copyright Hewlett-Packard Company, 1993
#
########

	UTILS="/usr/lbin/sw/control_utils"

	if [[ ! -f $UTILS ]]
	then
		echo "ERROR: Cannot find $UTILS"
		exit 1
	fi

	. $UTILS

	exitval=$SUCCESS

################################################################################
#set -x # For debugging purposes.  _Never_ ship uncommented!!


	##
	## Set up local environment variables
	##

	SW_INSTALL_DIR="/"
	
	##
	## Test to see if either SW_ROOT_DIRECTORY or SW_LOCATION is
	## set to something other than /.  If so, set up SW_INSTALL_DIR
	## so it will not have spurious /'s in the path name.
	##
	
	if [ $SW_ROOT_DIRECTORY != / -o $SW_LOCATION != / ]
	then
		if [ $SW_ROOT_DIRECTORY != / ]
		then
			if [ $SW_LOCATION != / ]
			then
				SW_INSTALL_DIR="${SW_ROOT_DIRECTORY}${SW_LOCATION}"
			else
				SW_INSTALL_DIR="${SW_ROOT_DIRECTORY}"
			fi
		else
			if [ $SW_LOCATION != / ]
			then
				SW_INSTALL_DIR="${SW_LOCATION}"
			fi
		fi
	fi

	PHIGS_DIR="$SW_INSTALL_DIR"
	COMMON_DIR="/opt/graphics/common"

	##
	##  Remove all of the symbolic links to fonts
	##

	set -- 4 -2 6 -4 8 -6 58 -8 1 1 2 2 
	while [ $# -gt 0 ]
	do
		COMMON_FONT_TARGET=$1
		PHIGS_FONT_LINK=$2
		shift
		shift

		for COMMON_FONT_DIR in font_info hproman usascii jisascii katakana kanji
		do
			if [ ${COMMON_FONT_DIR} = "kanji" ]
			then
				PHIGS_FONT_DIR="kanji.euc"
			else
				PHIGS_FONT_DIR=$COMMON_FONT_DIR
			fi

			##
			## If the symbolic exists in PHIGS, remove it.
			##

			if [ -h ${PHIGS_DIR}char_sets/${PHIGS_FONT_DIR}/${PHIGS_FONT_LINK} ]
			then

				##
				## font -8 only exists for font_info, usascii and hproman
				##
	
				if [ ${PHIGS_FONT_LINK} = "-8" ]
				then
					if [ ${PHIGS_FONT_DIR} = "usascii" \
					  -o ${PHIGS_FONT_DIR} = "hproman" \
					  -o ${PHIGS_FONT_DIR} = "font_info" ]
					then
						rm -f ${PHIGS_DIR}char_sets/${PHIGS_FONT_DIR}/${PHIGS_FONT_LINK} > /dev/null 2>&1
					fi
				else
					rm -f ${PHIGS_DIR}char_sets/${PHIGS_FONT_DIR}/${PHIGS_FONT_LINK} > /dev/null 2>&1
				fi 
			fi
		done
	done

	##
	##  Remove the PHIGS link to libddnull.sl to the Common libddnull.sl
	##

	PHIGS_NULL_DIR="$PHIGS_DIR"
	PHIGS_NULL_LINK="${PHIGS_NULL_DIR}lib/libddnull.sl"

	if [ -h $PHIGS_NULL_LINK ]
	then
		rm -f $PHIGS_NULL_LINK > /dev/null 2>&1
	fi

	##
	##  Remove the transition links for 9.x binary compatibility.
	##

	USR_DIR="${SW_ROOT_DIRECTORY}usr/lib"
	PHIGS_TLINK_DIR="${USR_DIR}/phigs"
	X_APP_DIR="$USR_DIR/X11/app-defaults"
	NLS_C_DIR="${USR_DIR}/nls/C"
	NLS_AMER_DIR="${USR_DIR}/nls/american"
	NLS_NC_DIR="${USR_DIR}/nls/n-computer"

	rm -f ${PHIGS_TLINK_DIR}/cgmiui		> /dev/null 2>&1
	rm -f ${PHIGS_TLINK_DIR}/xinitcolormap	> /dev/null 2>&1
	rm -f ${PHIGS_TLINK_DIR}/xmodsharedcmap	> /dev/null 2>&1
	rm -f ${PHIGS_TLINK_DIR}/xsharedcmap	> /dev/null 2>&1
	rm -f ${PHIGS_TLINK_DIR}/char_sets	> /dev/null 2>&1
	rm -f ${PHIGS_TLINK_DIR}/phg_daemon	> /dev/null 2>&1
	rm -f ${PHIGS_TLINK_DIR}/defaults	> /dev/null 2>&1
	rm -f ${USR_DIR}/libphigs.sl		> /dev/null 2>&1
	rm -f ${USR_DIR}/libphigsXg.sl		> /dev/null 2>&1

	if [ -d $X_APP_DIR ]
	then
		rm -f ${X_APP_DIR}/Phigswidget		> /dev/null 2>&1
	fi

	if [ -d $NLS_C_DIR ]
	then
		rm -f ${NLS_C_DIR}/phigs.cat		> /dev/null 2>&1
	fi

	if [ -d $NLS_AMER_DIR ]
	then
		rm -f ${NLS_AMER_DIR}/phigs.cat		> /dev/null 2>&1
	fi

	exit $exitval

