#!/sbin/sh

########
#  Product: GraphicsPHIGSDK
#  Fileset: PHIGS-PRG
#  preinstall
#  @(#) $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_LOCATION"

	##
	## Prepare any existing files which may be affected by
	## new versions shipped in ".../newconfig/..."
	##

	newconfig_prep ${PHIGS_DIR}src/Xg/PhigsDraw.c
	newconfig_prep ${PHIGS_DIR}src/Xg/makefile
	newconfig_prep ${PHIGS_DIR}src/cgmiui.c
	newconfig_prep ${PHIGS_DIR}src/makefile
	newconfig_prep ${PHIGS_DIR}src/xinitcolor.c

        ## Correct permission and ownership
 
        PHIG_DIR=/opt/graphics/phigs/newconfig
        if [[ -d $PHIG_DIR ]]
           then
              chown -R bin $PHIG_DIR > /dev/null 2>&1
              chgrp -R bin $PHIG_DIR > /dev/null 2>&1
              chmod 555 $PHIG_DIR/opt > /dev/null 2>&1
              chmod 555 $PHIG_DIR/opt/graphics > /dev/null 2>&1
              chmod 555 $PHIG_DIR/opt/graphics/phigs > /dev/null 2>&1
        fi

	exit $exitval
################################################################################
