#!/bin/sh
# #########################################################################
#
# Copyright (c) 1994 Adobe System Incorporated
# All Rights Reserved
#
#	***********************************************************************
#	If you copy this script off of the CD-ROM and then edit it, this
#	script will only work if you pass it the optional parameter "CDDIR=xxx",
#	where "xxx" is the mount point for the CD-ROM (e.g., /cdrom).
#	***********************************************************************
#
# In general, this script accepts command line parameters in the form:
#	xxx=yyy
# where "xxx" is a shell variable name and "yyy" is the value.
# For each parameter with an equal sign, this script does an eval on the parameter.
# Probably, CDDIR is the only parameter which makes sense to alter.
#
##########################################################################

export PATH
export HOME

ABORTCMD='${RM} $PKGLISTFILE; echo ""; echo ""; echo "*** Installation canceled ***"; echo ""; exit 1;'

# For echo without newline under BSD, set EB and EE variables
EB="-n "
EE=""
LASTLINECMD="tail -1"

# Things that are either platform-specific or potentially platform-specific.
osname="UNKNOWN"
osversion="UNKNOWN"
osmajorminor="UNKNOWN"
osmajor="UNKNOWN"
osminor="UNKNOWN"
if [ -x /bin/uname ] ; then
	osname=`/bin/uname -s`
        # 64 bit IRIX6 returns IRIX64 for uname -s
	firstfour=`echo "$osname" | sed -e 's/^\(....\).*$/\1/g'`
        if [ "$firstfour" = "IRIX" ] ; then
                osname="IRIX"
        fi
	osversion=`/bin/uname -r`
	check=`echo "$osversion" | egrep '^[0-9]\.[0-9]*'`
	if [ "$check" != "" ] ; then
		# osmajorminor will be like "4.2". osmajor: "4". osminor:"2".
		osmajorminor=`echo "$osversion" | sed -e 's/^\([0-9]\.[0-9]\).*/\1/'`
		osmajor=`echo "$osversion" | sed -e 's/^\([0-9]\).*/\1/'`
		osminor=`echo "$osversion" | sed -e 's/^[0-9]\.\([0-9]\).*/\1/'`
	fi
fi
if [ $osname = "SunOS" ] ; then
	STDBINDIR="/usr/bin"
	RETURNKEYNAME="Return"
	if [ $osmajor -ge 5 ] ; then
		DFTTAPEPATH=/dev/rmt/0
		# For echo without newline under Sys V, set EB and EE variables
		EB=""
		EE="\c"
		PATH=/usr/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/openwin/bin:/sbin:/usr/sbin:/etc:/usr/etc
		WHOAMI=`$STDBINDIR/id | $STDBINDIR/sed 's/^[^(]*.\([^)]*\).*/\1/'`
		DFTDAEMONDIR=sun4/sunOS5
		DFCMD="$STDBINDIR/df -k"
		DUCMD="$STDBINDIR/du -sk"
		DUFACTOR=1
		NLINES_CMD="$STDBINDIR/wc -l"
	else
		DFTTAPEPATH=/dev/rst0
		# For echo without newline under BSD, set EB and EE variables
		EB="-n "
		EE=""
		PATH=/usr/ucb:/usr/bin:/bin:/usr/bin/X11:/usr/openwin/bin:/sbin:/etc:/usr/etc
		WHOAMI=`/usr/ucb/whoami`
		DFTDAEMONDIR=sun4/sunOS4
		DFCMD="$STDBINDIR/df"
		DUCMD="$STDBINDIR/du -s"
		DUFACTOR=1
		NLINES_CMD="/usr/ucb/wc -l"
	fi
	CLEAR=/usr/ucb/clear
	DFTCDROMPATH=/cdrom
	DFTTOPDIR=/usr/adobe
	KEYSYMDBFILE=/usr/openwin/lib/XKeysymDB
	KBYTES_AVAIL_FIELD=4
	GETHOSTID="hostid"
	RSH="/usr/ucb/rsh"

elif [ $osname = "IRIX" ] ; then
	STDBINDIR="/usr/bin"
	RETURNKEYNAME="Enter"
	DFTTAPEPATH=/dev/tape
	DFTCDROMPATH=/CDROM
	DFTTOPDIR=/usr/adobe
	KEYSYMDBFILE=/usr/lib/X11/XKeysymDB
	DFCMD="$STDBINDIR/df -k"
	DUCMD="$STDBINDIR/du -sk"
	DUFACTOR=1
	KBYTES_AVAIL_FIELD=5
	GETHOSTID='/etc/sysinfo | /usr/bsd/head -2 | $STDBINDIR/tail -1 | $STDBINDIR/awk '\''{ printf "%s%s%s%s", $1, $2, $3, $4; }'\'
	CLEAR=/usr/bsd/clear
	WHOAMI=`$STDBINDIR/id | $STDBINDIR/sed 's/^[^(]*.\([^)]*\).*/\1/'`
	# For echo without newline under Sys V, set EB and EE variables
	EB=""
	EE="\c"
	PATH=/usr/sbin:/sbin:/usr/bin:/bin:/usr/bsd:/usr/bin/X11:/usr/openwin/bin:/etc:/usr/etc
	DFTDAEMONDIR=sgi/v5
	NLINES_CMD="$STDBINDIR/wc -l"
	RSH="/usr/bsd/rsh"

elif [ $osname = "HP-UX" ] ; then
	STDBINDIR="/bin"
	RETURNKEYNAME="Return"
	DFTTAPEPATH=/dev/rmt/0m
	DFTCDROMPATH=/cdrom
	DFTTOPDIR=/usr/adobe
	KEYSYMDBFILE=/usr/lib/X11/XKeysymDB
	DFCMD="/usr/bin/bdf"
	DUCMD="$STDBINDIR/du -s"
	DUFACTOR=.5
	KBYTES_AVAIL_FIELD=4
	GETHOSTID="$STDBINDIR/uname -i"
	CLEAR="/usr/bin/clear"
	WHOAMI=`/usr/bin/whoami`
	# For echo without newline under Sys V, set EB and EE variables
	EB=""
	EE="\c"
	PATH=/usr/sbin:/sbin:/usr/bin:/bin:/usr/bin/X11:/etc:/usr/etc
	DFTDAEMONDIR="???/???"
	NLINES_CMD="$STDBINDIR/wc -l"
	RSH="/usr/bin/remsh"
fi
if [ "$osname" = "UNKNOWN" -o "$osversion" = "UNKNOWN" ] ; then
	echo ""
	echo "Unrecognized operating system: $osname $osversion."
	echo "Cannot install: $DISTRIB_DESC"
	eval ${ABORTCMD}
fi

export PATH

TAR_OPTS_C="-cf"
TAR_OPTS_X="-xfv"
TAR="$STDBINDIR/tar"
MKDIR="$STDBINDIR/mkdir -p "
RMDIR="$STDBINDIR/rmdir "
CP="$STDBINDIR/cp"
LN="$STDBINDIR/ln -s"
RM="$STDBINDIR/rm -f"
MV="$STDBINDIR/mv"
CAT="$STDBINDIR/cat"
SED="$STDBINDIR/sed"
AWK="$STDBINDIR/awk"
EXPR="$STDBINDIR/expr"
PWDCMD="$STDBINDIR/pwd"
DIRCP="$STDBINDIR/cp -pr"
DIRRM="$STDBINDIR/rm -rf"
LS="$STDBINDIR/ls"
# On some systems, cd is a shell intrinsic
# Also, executable is not always compatible with scripts, so
# just use plain "cd"
CD="cd"

# Temporary directory used by this install script.
if [ "$INSTALLTEMPDIR" = "" ] ; then
	INSTALLTEMPDIR="/tmp"
fi
PKGLISTFILE=$INSTALLTEMPDIR"/Packages."$$

# Installation device (CDROM or TAPE)
if [ "$INSTALLDEVICE" = "" ] ; then
	INSTALLDEVICE="CDROM"
fi

# Make sure we have proper access to installation temp file.
if [ ! -w $INSTALLTEMPDIR ] ; then
	echo "Permission denied in writing to directory $INSTALLTEMPDIR."
	echo "Please change permissions and rerun this script."
	echo ""
	exit 1
fi
if [ -f $PKGLISTFILE -a ! -w $PKGLISTFILE ] ; then
	echo "Permission denied in creating file $PKGLISTFILE."
	echo "Please change permissions and rerun this script."
	echo ""
	exit 1
fi

# Description of this distribution.
DISTRIB_DESC="Adobe Illustrator Version 5.5 for SGI IRIX 5.2"

# Whether this software is protected by an electronic license (y or n).
if [ "$ELECTRONIC_LICENSE" = "" ] ; then
	ELECTRONIC_LICENSE="n"
fi

# Name of file containing the electronic license
# (relative to directory containing this install script).
if [ "$ELECTRONIC_LICENSE_FILE" = "" ] ; then
	ELECTRONIC_LICENSE_FILE="license"
fi

# Which packages to install (prompt or ALL or list of numbers)
WHICH_PACKAGES="prompt"
if [ "$WHICH_PACKAGES" = "" ] ; then
	WHICH_PACKAGES="prompt"
fi

# Descriptions of packages included with this distribution.
# NPKGS indicates how many packages are included in this distribution.
# Following NPKGS is the printed table which appears to the user when
# choosing which packages to install.
# This table is stored in a temporary file while the install script runs.
# PKG_$i_PKGFULLDESC: Full product description (version, platform included)
# PKG_$i_PKGDESC: Descriptive product name
# PKG_$i_VERSIONDESC: Descriptive product version
# PKG_$i_PLATFORMDESC: Description of platform required to run package
# PKG_$i_KBYTES: Space required for package (in kilobytes. No trailing K)
# PKG_$i_PKGABBR: Abbreviated product name (no spaces or underscores)
# PKG_$i_PKGVERS: Abbreviated version number (no spaces or underscores)
# PKG_$i_BINLINKS: List of programs requiring auto sym links to $DFTSYMLINKDIR
# PKG_$i_FONTDIR: Directory to put FONTPATTERN fonts in
# PKG_$i_FONTUPR: UPR file describing FONTPATTERN fonts
# PKG_$i_XKEYSYMDB: Set this to "1" if package required updates to XKeysymDB
# PKG_$i_SCRIPT: Name of script to run after package is installed (or empty string)
# PKG_$i_LMFEATURE: Describes components requiring a password (null string if none)
# PKG_$i_LMVERSION: Corresponding FlexLM version string.
# PKG_$i_LMQUOTES: Corresponding FlexLM string within quotes.
# PKG_$i_CDROM_FROMFILES: Name of files on CDROM to copy into install tree.
#                    Relative to dir with install script.
# PKG_$i_CDROM_TOFILES: What to rename the files specified in CDROM_FROMFILES.
#                    Relative to base dir for product tree.
# PKG_$i_FORCED_PKGS: Numbers of other packages whose installation is forced by
#                    installation of this package. Default: none.
# PKG_$i_OLD_VERSION_ACTION: What to do if same package is already installed
#                    in same location: "quiet:leavealone", "quiet:overwrite",
#                    "prompt:oktodelete", "prompt:leavealone/overwrite".
#                    Default: "prompt:oktodelete".
# PKG_$i_HIDDEN: Set this to "1" if package should be hidden from user.
#                    Hidden packages have to be at end of list! Default: 0.
# PKG_$i_PSRES_WRITEFILE: Set to "y" if package should write out
#		custom/SITE_PSRESOURCEPATH. Default: use value of PSRES_WRITEFILE.
# PKG_$i_LM_WRITEFILE: Set to "y" if package should write out
#		custom/LM_WRITEFILE. Default: use value of LM_WRITEFILE.
# PKG_$i_AUTOSYMLINK: Value for AUTOSYMLINK for this package. Default: use AUTOSYMLINK.
#		Only values that make sense: 1 or 0.
# PKG_$i_INSTALL_METHOD: Method to use to install package.
#		"tarfile" means there is a *.tar file and to use "tar xf" to install.
#		"tar-to-tar" means there are flat files that should be copied by
#		(cd <sourcedir> tar cf - <files> | cd <destdir> tar xfv -)
#		"cp" means to do a directory copy from CD to disk.
#		Default: "tarfile".
# PKG_$i_TARFILE: If INSTALL_METHOD="tarfile" or "" and if using a different tarfile
#                 than $CDARCHIVEFILE, name of tarfile that contains this package.
# PGK_$i_FILES: If INSTALL_METHOD="tar-to-tar" or "cp", list of files to copy directly from CD 
#               onto user's disk.
# PGK_$i_FILES_DIRECTORY: If INSTALL_METHOD="tar-to-tar" or "cp", directory on CD 
#		(relative to install script) for PKG_$i_FILES.
NPKGS="3"
cat << EOF > $PKGLISTFILE
         # Package Description       Version    Platform      KBytes
        -- -------------------       -------    --------      ------
         1 AdobeIllustrator            5.5    IRIX 5.2      28000
         2 AdobeIllustrator Extras     5.5    IRIX 5.2      73000

EOF
PKG_1_PKGFULLDESC="Adobe Illustrator Version 5.5 for IRIX 5.2"
PKG_1_PKGDESC="Adobe Illustrator"
PKG_1_VERSIONDESC="Version 5.5"
PKG_1_PLATFORMDESC="IRIX 5.2/5.3"
PKG_1_KBYTES="28000"
PKG_1_PKGABBR="Illustrator"
PKG_1_PKGVERS="5.5"
PKG_1_BINLINKS="bin/illustrator bin/separator"
PKG_1_XKEYSYMDB="0"
PKG_1_SCRIPT="installscripts/postinstall"
PKG_1_LMFEATURE="AdobeIllustrator"
PKG_1_LMVERSION="5.500"
PKG_1_LMQUOTES=""
PKG_1_CDROM_FROMFILES="readme getstart.ps support.ps KeyMapping.ps"
PKG_1_CDROM_TOFILES="readme doc/getstart.ps doc/support.ps doc/KeyMapping.ps"
PKG_1_FORCED_PKGS="3"
PKG_1_OLD_VERSION_ACTION="prompt:leavealone/overwrite"
PKG_1_HIDDEN="0"
PKG_1_TARFILE=""
PKG_2_PKGFULLDESC="Adobe Illustrator Version 5.5 Extras"
PKG_2_PKGDESC="Adobe Illustrator Extras"
PKG_2_VERSIONDESC="Version 5.5"
PKG_2_PLATFORMDESC="IRIX 5.2/5.3"
PKG_2_KBYTES="73000"
PKG_2_PKGABBR="IllustratorExtras"
PKG_2_PKGVERS="5.5"
PKG_2_BINLINKS=""
PKG_2_XKEYSYMDB="0"
PKG_2_SCRIPT=""
PKG_2_LMFEATURE=""
PKG_2_LMVERSION=""
PKG_2_LMQUOTES=""
PKG_2_CDROM_FROMFILES=""
PKG_2_CDROM_TOFILES=""
PKG_2_FORCED_PKGS=""
PKG_2_OLD_VERSION_ACTION="prompt:leavealone/overwrite"
PKG_2_HIDDEN="0"
PKG_2_INSTALL_METHOD="cp"
PKG_2_FILES_DIRECTORY="../illextra"
PKG_2_FILES="IllustratorExtras_5.5"
PKG_2_PSRES_WRITEFILE="n"
PKG_2_LM_WRITEFILE="n"
PKG_2_AUTOSYMLINK="0"
PKG_3_PKGFULLDESC="DPS NX Basic Version 2.1 for "
PKG_3_PKGDESC="DPS NX Basic"
PKG_3_VERSIONDESC="Version 2.1"
PKG_3_PLATFORMDESC="IRIX 5.2/5.3"
PKG_3_KBYTES="4181"
PKG_3_PKGABBR="DPSNXBasic"
PKG_3_PKGVERS="2.1"
PKG_3_BINLINKS="bin/dpsnx.agent"
PKG_3_XKEYSYMDB="0"
PKG_3_SCRIPT=""
PKG_3_LMFEATURE=""
PKG_3_LMVERSION=""
PKG_3_LMQUOTES=""
PKG_3_CDROM_FROMFILES=""
PKG_3_CDROM_TOFILES=""
PKG_3_FORCED_PKGS=""
PKG_3_OLD_VERSION_ACTION="prompt:leavealone/overwrite"
PKG_3_HIDDEN="1"
PKG_3_TARFILE="../nxbasic/nxbasic.tar"
PKG_3_SCRIPT="installscripts/postinstall"

# Determine how many un-hidden (i.e., visible) packages are included.
NPKGS_VISIBLE=0
package_num=1
while [ $package_num -le $NPKGS ] ; do
	packagehidden=`eval echo '$PKG_'$package_num'_HIDDEN'`
	if [ "$packagehidden" != "1" ] ; then
		NPKGS_VISIBLE=`expr $NPKGS_VISIBLE + 1`
	fi
	package_num=`expr $package_num + 1`
done

# Name of CD-ROM archive file.
CDARCHIVEFILE="illus.tar"

# Name of directory where CD is mounted.
# If null, then directory is figured out automatically by script.
#CDDIR=""
# Determine name of this file on CDROM.
if [ "$CDDIR" = "" ] ; then
	CDDIR=`expr "$0" : '\(.*\)/'`
        abspath=`expr "$0" : '^/'`
	if [ "$CDDIR" = "" -o "$CDDIR" = "." ] ; then
		CDDIR=`pwd`
        elif [ "$abspath" != 1 ] ; then
                CDDIR=`pwd`/$CDDIR
	fi
fi

# Whether you must be root to run the installer.
ROOT_REQUIRED="1"
if [ "$ROOT_REQUIRED" = "" ] ; then
	ROOT_REQUIRED="1"
fi

# Whether to prompt for root directory (y or n)
ROOTDIR_PROMPT="y"
if [ "$ROOTDIR_PROMPT" = "" ] ; then
	ROOTDIR_PROMPT="y"
fi

# Whether to prompt for license data file location (y or n)
LICENSE_PROMPT="y"
if [ "$LICENSE_PROMPT" = "" ] ; then
	LICENSE_PROMPT="y"
fi

# Directory for security files.
# If a relative path is given, then the path is relative to 
# the directory into which the software is installed.
if [ "$DFTSECURITYDIR" = "" ] ; then
	DFTSECURITYDIR="/usr/local/flexlm/licenses"
fi

# Directory for Adobe license daemon.
# If a relative path is given, then the path is relative to 
# the directory above the directory containing the license file.
DAEMONDIR="sgi/v5"
if [ "$DAEMONDIR" = "" ] ; then
	DAEMONDIR="$DFTDAEMONDIR"
fi

# License security file within license security directory.
if [ "$DFTSECURITYFILE" = "" ] ; then
	DFTSECURITYFILE="license.dat"
fi

# Whether to install automatic symbolic links for programs
# (1 or 0 or prompt or makescript)
AUTOSYMLINK="makescript"
if [ "$AUTOSYMLINK" = "" ] ; then
	AUTOSYMLINK="makescript"
fi

# Prompt to give for whether to establish automatic symbolic links
if [ "$SYMLINK_PROMPT_1_TEXT" = "" ] ; then
	SYMLINK_PROMPT_1_TEXT="This installation script places programs and/or scripts in locations that
probably are not on your PATH. Do you want symbolic links for the programs
and/or scripts installed in another directory (e.g., /usr/bin or /usr/local/bin)?"
fi

# Prompt to give for whether to establish automatic symbolic font links
if [ "$FONTLINK_PROMPT_1_TEXT" = "" ] ; then
	FONTLINK_PROMPT_1_TEXT="This installation script places fonts in locations that
probably are not on your PSRESOURCEPATH. Do you want symbolic links for the fonts
installed in the directory for your site (e.g., /usr/psres)?"
fi

# Prompt to ask for directory for automatic symbolic links
if [ "$SYMLINK_PROMPT_2_TEXT" = "" ] ; then
	SYMLINK_PROMPT_2_TEXT="Enter name of alternate directory for program launch scripts"
fi

# Location of script which will be created if AUTOSYMLINK=makescript
SYMLINKSCRIPT="/tmp/illustrator.makelinks"
if [ "$SYMLINKSCRIPT" = "" ] ; then
	SYMLINKSCRIPT="/tmp/adobe_install_make_links"
fi

# Whether to prompt for directory for installing automatic symbolic links
# (y or n)
SYMLINKDIR_PROMPT="n"
if [ "$SYMLINKDIR_PROMPT" = "" ] ; then
	SYMLINKDIR_PROMPT="y"
fi

# Directory to install automatic symbolic links for programs
# If a relative path is given, then the path is relative to 
# the directory into which the software is installed.
if [ "$DFTSYMLINKDIR" = "" ] ; then
	DFTSYMLINKDIR="/usr/bin"
fi

# Directory relative to installation root dir for keeping XKeysymDB file.
if [ "$XKEYSYMDBDIR" = "" ] ; then
	XKEYSYMDBDIR="installscripts"
fi

# File name for XKeysymDB fixes relative to XKEYSYMDBDIR.
if [ "$XKEYSYMDBFILE" = "" ] ; then
	XKEYSYMDBFILE="XKeysymDB"
fi

# Whether to prompt for PS resource path (y or n)
PSRES_PROMPT="y"
if [ "$PSRES_PROMPT" = "" ] ; then
	PSRES_PROMPT="n"
fi

# Whether to write out a file pointing to PSRES_PATH (y or n)
PSRES_WRITEFILE="y"
if [ "$PSRES_WRITEFILE" = "" ] ; then
	PSRES_WRITEFILE="n"
fi

# Default list of directories into which application will look for
# PostScript resources
if [ "$PSRES_DEFAULT" = "" ] ; then
	PSRES_DEFAULT='$HOME/psres:/usr/psres'
fi

# File name to write out value of PSRES_PATH (for PSRES_WRITEFILE=y)
# If a relative path is given, then the path is relative to 
# the directory into which the software is installed.
if [ "$PSRES_FILE" = "" ] ; then
	PSRES_FILE="custom/SITE_PSRESOURCEPATH"
fi

# Whether to write out a file pointing to LM_LICENSE_FILE (y or n)
LM_WRITEFILE="y"
if [ "$LM_WRITEFILE" = "" ] ; then
	LM_WRITEFILE="n"
fi

# File name to write out value of LM_LICENSE_FILE (for LM_WRITEFILE=y)
# If a relative path is given, then the path is relative to 
# the directory into which the software is installed.
if [ "$LM_FILE" = "" ] ; then
	LM_FILE="custom/LM_LICENSE_FILE"
fi

# Number of times prompting loops are permitted to loop.
# This is necessary on some platforms where double-clicking
# on a script from the desktop causes script to run with
# Return automatically supplied to all possible prompts.
if [ "$LOOP_LIMIT" = "" ] ; then
	LOOP_LIMIT="25"
fi

# Search pattern for listing font subdirectories
if [ "$FONTPATTERN" = "" ] ; then
	FONTPATTERN="fonts/*.font"
fi

# Are there any fonts to install?  1 for yes, 0 for no.
if [ "$ANYFONTLINKS" = "" ] ; then
	ANYFONTLINKS=0
fi

# Whether to write out a file with user environment info
if [ "$USER_INFO_WRITEFILE" = "" ] ; then
	USER_INFO_WRITEFILE="n"
fi

# File name to write out user info (for USER_INFO_WRITEFILE=y)
# If a relative path is given, then the path is relative to 
# the directory into which the software is installed.
if [ "$USER_INFO_FILE" = "" ] ; then
	USER_INFO_FILE="custom/user.adobe"
fi


#
# Useful shell function for eliminating automounting cruft
# and symbolic links.
#

fix_path()
{
    dir="$1"
    if [ ! -d "$dir" ] ; then
    	return 1
    fi

    # Undo automounter stuff
    ORIGDIR=`(cd "$dir" ; $PWDCMD)`
    TESTDIR=`expr $ORIGDIR : '/[^/]*\(.*\)'`
    HEAD=`expr $ORIGDIR : '\(/[^/]*\)'/`
    
    if [ -z "$HEAD" -o -z "$TESTDIR" ] ; then
        if [ `expr $ORIGDIR : '/[/]*[^/]*$'` -gt 0 ] ; then
	    FIXED_PATH="$ORIGDIR"
	    return 0
	fi
	return 1
    fi
    
    if [ ! -d "$ORIGDIR" ] ; then
        return 1
    fi
    
    if [ ! -z "$TESTDIR" -a ! -d "$TESTDIR" ] ; then
        # definitely not automounted
	FIXED_PATH="$ORIGDIR"
	return 0
    fi
 
    if [ `cd $ORIGDIR && $PWDCMD` = `cd $TESTDIR && $PWDCMD` ] ; then
        # definitely automounted
	FIXED_PATH="$TESTDIR"
	return 0
    fi
    
    # definitely not automounted
    FIXED_PATH="$ORIGDIR"
    return 0
}

#
# Prints out a file name indented four spaces
# following by the type of file in parentheses.
#

echo_file_name_and_type()
{
	filename="$1"
	echo $EB"    $filename"$EE
	if [ -d "$filename" ] ; then
		echo "    (Directory)"
	elif [ -h "$filename" ] ; then
		echo "    (Symbolic link)"
	elif [ -f "$filename" ] ; then
		echo "    (File)"
	else
		echo ""
	fi
}


# Process command line parameters.
while [ $# -gt 0 ] ; do

	# "xxx=yyy" allows particular values from this script
	# to be overwritten from the command line.
	# For example, CDDIR=/usr/cdrom
	nequal=`expr $1 : '[^=][^=]*=[^=][^=]*'`
	if [ $nequal -ge 1 ] ; then
		eval "$1"
		shift
	else
		echo "Invalid parameter: $1"
		echo "Usage: $0 [<var>=<value>]..."
		exit 1
	fi
done

# Initialize variables
RHOST=""
DEVNAME=""
DOSYMLINKS=0
DOFONTLINKS=0
CREATED=0
SKIPFONTS=1

umask 022

if [ $ROOT_REQUIRED = 1 ] ; then
	# Abort installation if user not superuser
	if [ "$WHOAMI" != root ] ; then
		echo ""
		echo "You must be logged in as root to install"
		echo "$DISTRIB_DESC."
		echo 'Type "su root" and enter the password to become root.'
		eval ${ABORTCMD}
	fi
fi

# Stop the script if user hit interrupt
trap 'eval ${ABORTCMD}' 2

# Loop until user says to continue with the installation.
outermost_loop=0
while : ; do
	outermost_loop=`expr $outermost_loop + 1`
	if [ $outermost_loop -ge $LOOP_LIMIT ] ; then
		echo ""
		echo "LOOP_LIMIT exceeded."
		eval ${ABORTCMD}
	fi

	ALLOK1=1
	$CLEAR
	echo ""
	echo "	Installation Script For"
	echo "	${DISTRIB_DESC}"
	echo ""
	echo "	Copyright (c) 1994 Adobe Systems Incorporated"
	echo "	All Rights Reserved "
	echo ""
	sleep 2

	if [ "$ELECTRONIC_LICENSE" = "y" ] ; then
		while : ; do
			echo ""
			echo "Before proceeding with the installation, you need to read and accept"
			echo "the following Electronic End User License Agreement."
			echo ""
			echo "Press $RETURNKEYNAME to continue."
			read A
			$CLEAR
			nlines=`$NLINES_CMD $CDDIR/$ELECTRONIC_LICENSE_FILE`
			firstline=1
			while : ; do
				if [ $firstline -gt "$nlines" ] ; then
					break
				fi
				lastline=`$EXPR $firstline + 19`
				$CLEAR
				echo ""
				sedcmd="$SED -n -e 's/^/    /g' -e '$firstline,$lastline p' $CDDIR/$ELECTRONIC_LICENSE_FILE"
				eval "$sedcmd"
				echo ""
				echo "Press $RETURNKEYNAME to continue, or type 1 and press $RETURNKEYNAME to re-print"
				echo "the Electronic End User License Agreement from the beginning."
				read A
				if [ "$A" = "1" ] ; then
					firstline=1
				else
					firstline=`$EXPR $lastline + 1`
				fi
			done

			$CLEAR
			accepted=0
			while : ; do
				echo ""
				echo "PLEASE INDICATE YOUR ACCEPTANCE OR DECLINE OF THE FOREGOING AGREEMENT"
				echo "BY ENTERING THE WORD 'ACCEPT' OR 'DECLINE' AND THEN PRESS $RETURNKEYNAME."
				echo ""
				echo "If you wish to re-read the Electronic End User License Agreement,"
				echo "just press $RETURNKEYNAME."
				echo ""
				echo $EB"Do you ACCEPT or DECLINE the Electronic End User License Agreement? "$EE
				read A
				if [ "$A" = ACCEPT -o "$A" = accept ] ; then
					accepted=1
					$CLEAR
					echo ""
					echo "You have accepted the Electronic End User License Agreement."
					echo "Press $RETURNKEYNAME to continue with the installation process."
					read A
					$CLEAR
					break
				elif [ "$A" = DECLINE -o "$A" = decline ] ; then
					echo ""
					echo "Installation cancelled."
					echo ""
					eval ${ABORTCMD}
				elif [ "$A" != "" ] ; then
					echo ""
					echo "Invalid response. Valid responses are: ACCEPT,accept,DECLINE,decline."
					echo ""
				else
					break
				fi
			done
			if [ $accepted = 1 ] ; then
				break
			fi
		done
	fi

	if [ $NPKGS_VISIBLE = 1 ] ; then
		A="ALL"
	elif [ "$WHICH_PACKAGES" != "prompt" ] ; then
		A="$WHICH_PACKAGES"
	else
		echo ""
		echo "The following packages are available for installation:"
		echo ""
		cat $PKGLISTFILE
		echo ""
		echo 'Choose from the following options:'
		echo '  Press '$RETURNKEYNAME' for All packages.'
		echo '  Type a list of package numbers separated by a space (for example: 1 2).'
		echo '  Type q to quit.'
		echo ''
		echo $EB'Which packages do you want to install [Press '$RETURNKEYNAME' for All]? '$EE
		read A
		ntokens=`echo ${A} | wc -w`
		if [ $ntokens -eq 0 ] ; then
			A="ALL"
		elif [ "$A" = "Q" -o "$A" = "q" -o "$A" = "Quit" -o "$A" = "quit" -o "$A" = "QUIT" ] ; then
			eval ${ABORTCMD}
		elif [ "$A" = "ALL" -o "$A" = "All" -o "$A" = "all" ] ; then
			A="ALL"
		else
			# Convert commas to spaces
			A=`echo "$A" | tr ',' ' '`

			# Make sure only valid numbers are present.
			for i in $A ; do
				package_num=1
				found=0
				while [ $package_num -le $NPKGS_VISIBLE ] ; do
					if [ "$i" -eq "$package_num" ] ; then
						found=1
						break
					fi
					package_num=`expr $package_num + 1`
				done
				if [ $found = 0 ] ; then
					echo ""
					echo "Invalid entry: $i. Try again."
					echo "Press $RETURNKEYNAME to continue"
					read UNUSED
					ALLOK1=0
					break
				fi
			done
		fi
		$CLEAR
	fi

	if [ $ALLOK1 = 1 ] ; then
		if [ "$A" = "ALL" ] ; then
			A=""
			package_num=1
			while [ $package_num -le $NPKGS_VISIBLE ] ; do
				A="$A $package_num"
				package_num=`expr $package_num + 1`
			done
		fi

		# Sort, remove duplicates in list of requested packages to install.
		PKGS_TO_INSTALL_REQUESTED=""
		package_num=1
		while [ $package_num -le $NPKGS_VISIBLE ] ; do
			for i in $A ; do
				if [ "$i" = "$package_num" ] ; then
					PKGS_TO_INSTALL_REQUESTED="$PKGS_TO_INSTALL_REQUESTED $i"
					break
				fi
			done
			package_num=`expr $package_num + 1`
		done

		# Add any packages which are forced by presence of other packages.
		REQUESTED_PLUS_FORCED="$PKGS_TO_INSTALL_REQUESTED"
		for i in $PKGS_TO_INSTALL_REQUESTED ; do
			forced_pkgs=`eval echo '$PKG_'$i'_FORCED_PKGS'`
			if [ "$forced_pkgs" != "" ] ; then
				REQUESTED_PLUS_FORCED="$REQUESTED_PLUS_FORCED $forced_pkgs"
			fi
		done

		# Sort, remove duplicates in total list of packages (forced packages also) to install.
		PKGS_TO_INSTALL_TOTAL=""
		package_num=1
		while [ $package_num -le $NPKGS ] ; do
			for i in $REQUESTED_PLUS_FORCED ; do
				if [ "$i" = "$package_num" ] ; then
					PKGS_TO_INSTALL_TOTAL="$PKGS_TO_INSTALL_TOTAL $i"
					break
				fi
			done
			package_num=`expr $package_num + 1`
		done

		echo ""
		echo ""
		for package_num in ${PKGS_TO_INSTALL_REQUESTED} ; do
			packagedesc=`eval echo '$PKG_'$package_num'_PKGDESC'`
			platformdesc=`eval echo '$PKG_'$package_num'_PLATFORMDESC'`
			echo "$platformdesc is required to use $packagedesc"
		done
		echo "$osname $osversion is currently installed on this machine."
	fi

	if [ $ALLOK1 = 1 ] ; then
		if [ "$INSTALLDEVICE" = "" ] ; then
			echo ""
			cdtape_loop=0
			while : ; do
				cdtape_loop=`expr $cdtape_loop + 1`
				if [ $cdtape_loop -ge $LOOP_LIMIT ] ; then
					echo ""
					echo "LOOP_LIMIT exceeded."
					eval ${ABORTCMD}
				fi
				echo ""
				echo ""
				echo "Do you want to install"
				echo "from a CD-ROM drive or a tape drive?"
				echo $EB"Type in 'c' for CD-ROM or 't' for TAPE (cdrom/tape) "$EE
				read A
				if [ "$A" = "CD-ROM" -o "$A" = "C" -o "$A" = "cdrom" -o "$A" = "c" ] ; then
					USECD=1
					DFTDEVPATH=$DFTCDROMPATH
					break
				elif [ "$A" = "TAPE" -o "$A" = "T" -o "$A" = "tape" -o "$A" = "t" ] ; then
					USECD=0
					DFTDEVPATH=$DFTTAPEPATH
					break
				else
					echo ""
					echo "You must select CD-ROM or TAPE.  Try again."
				fi
			done
		elif [ "$INSTALLDEVICE" = "CDROM" ] ; then
			USECD=1
		else
			USECD=0
		fi

		# Determine host and path from where release can be extracted
		if [ $USECD = 1 ] ; then
			DEVPATH=${CDDIR}'/'${CDARCHIVEFILE}
			if [ ! -f $DEVPATH ] ; then
				echo ""
				echo "Cannot find CDROM release in ${CDDIR}."
				echo "Re-read installation instructions and start again."
				eval ${ABORTCMD}
			fi
		else
			tapelr1_loop=0
			while : ; do
				tapelr1_loop=`expr $tapelr1_loop + 1`
				if [ $tapelr1_loop -ge $LOOP_LIMIT ] ; then
					echo ""
					echo "LOOP_LIMIT exceeded."
					eval ${ABORTCMD}
				fi
				tapelr2_loop=0
				while : ; do
					tapelr2_loop=`expr $tapelr2_loop + 1`
					if [ $tapelr2_loop -ge $LOOP_LIMIT ] ; then
						echo ""
						echo "LOOP_LIMIT exceeded."
						eval ${ABORTCMD}
					fi
					echo ""
					echo ""
					echo $EB"Do you want to install from a tape "$EE
					echo "drive connected to your local"
					echo $EB"computer or from a remote host (local/remote)? "$EE
					read A
					if [ "$A" = "LOCAL" -o "$A" = "L" -o "$A" = "local" -o "$A" = "l" -o \
							$A = "REMOTE" -o "$A" = "R" -o "$A" = "remote" -o "$A" = "r" ] ; then
						if [ "$A" = "REMOTE" -o "$A" = "R" -o "$A" = "remote" -o "$A" = "r" ] ; then
							remotehost_loop=0
							while : ; do
								remotehost_loop=`expr $remotehost_loop + 1`
								if [ $remotehost_loop -ge $LOOP_LIMIT ] ; then
									echo ""
									echo "LOOP_LIMIT exceeded."
									eval ${ABORTCMD}
								fi
								echo ""
								echo $EB"Enter name of the remote host: "$EE
								read RHOST
								if [ "$RHOST" = "" ] ; then
									echo ""
									echo "You must specify a remote host.  Try again."
								else
									break
								fi
							done
							# check if we can connect to remote host
							if $RSH -n $RHOST $TEST 1> /dev/null 2>&1 ; then status=0; else status=1; fi
							if [ $status != 0 ] ; then
							   echo ""
							   echo "You are not authorized to connect to $RHOST"
							   echo "Check that your machine is listed in /.rhosts file on $RHOST."
							   echo "For more help, talk to your System Administrator."
							   ALLOK1=0
							fi 
						else
							RHOST=""
						fi


						if [ $ALLOK1 = 1 ]; then
							echo ""
							echo $EB"Specify the pathname of the device mounted on "$EE
							if [ "$RHOST" = "" ] ; then
								echo "this computer."
							else
								echo "$RHOST."
							fi
							echo "A tape drive usually has a default mountpoint of "$DFTDEVPATH"."
							echo "Please refer to the Installation Guide for additional information."
							echo ""
							echo $EB'Pathname of device [press '$RETURNKEYNAME' for '$DFTDEVPATH']: '$EE
							read A
							if [ "$A" = "" ] ; then
								DEVPATH=$DFTDEVPATH
							else
								DEVPATH=$A
							fi
						fi
						break
					else
						echo ""
						echo "You must specify LOCAL or REMOTE.  Try again."
					fi
				done


				if [ $ALLOK1 = 1 ] ; then
					if [ "$RHOST" = ""  ] ; then
						if [ ! -r $DEVPATH ] ; then
							echo ""
							echo "The device $DEVPATH does not exist."
							echo "You must select an available device.  Try again."
						fi
					fi
				break
				fi
			done
		fi
	fi
# INDENDATION START: <
	
		if [ $ALLOK1 = 1 ] ; then
			if [ "$ROOTDIR_PROMPT" = "y" ] ; then
				rootdir_loop=0
				while : ; do
					rootdir_loop=`expr $rootdir_loop + 1`
					if [ $rootdir_loop -ge $LOOP_LIMIT ] ; then
						echo ""
						echo "LOOP_LIMIT exceeded."
						eval ${ABORTCMD}
					fi
					ALLOK2=1
					echo ""
					echo ""
					echo "This script installs software relative to a specified installation"
					echo "directory <installdir>. If you accept the default value for"
					echo "<installdir>, which is $DFTTOPDIR, the following directories"
					echo "will be created:"
					echo ""
					for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
						packagedesc=`eval echo '$PKG_'$package_num'_PKGDESC'`
						pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
						pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
						package_dir=$pabbr"_"$pver
						echo "    $DFTTOPDIR/$package_dir"
					done
					echo ""
					echo "Enter the full pathname for the installation directory"
					echo 'where you want to install the software'
					echo $EB'[press '$RETURNKEYNAME' for '$DFTTOPDIR']: '$EE
					read A
					if [ "$A" = ""  ] ; then
						TOPDIR="$DFTTOPDIR"
					else
						TOPDIR="$A"
					fi
	
					# Rmove trailing '/' if any
					TOPDIR=`echo "$TOPDIR" | $SED -e 's/\/$//'`
					if [ ! -d $TOPDIR  ] ; then
						if $MKDIR $TOPDIR ; then status=0 ; else status=1; fi
						if [ $status != 0  ] ; then
							echo ""
							echo "Could not create directory $TOPDIR."
							eval ${ABORTCMD}
						fi
	
					elif [ ! -w $TOPDIR  ] ; then
						echo ""
						echo "You do not have write permissions for the directory"
						echo "$TOPDIR.  Please choose another directory."
						ALLOK2=0
					fi
					if [ $ALLOK2 = 1 ] ; then
						break
					fi
				done
			else
				TOPDIR="$DFTTOPDIR"
				if [ ! -d $TOPDIR  ] ; then
					if $MKDIR $TOPDIR ; then status=0 ; else status=1; fi
					if [ $status != 0  ] ; then
						echo ""
						echo "Could not create directory $TOPDIR."
						eval ${ABORTCMD}
					fi
	
				elif [ ! -w $TOPDIR  ] ; then
					echo ""
					echo "You do not have write permissions for the directory"
					echo "$TOPDIR."
					eval ${ABORTCMD}
				fi
			fi
		fi
	
		if [ $ALLOK1 = 1 ] ; then
			ANYSECURED=0
			for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
				lmfeature=`eval echo '$PKG_'$package_num'_LMFEATURE'`
				ntokens=`echo $lmfeature | wc -w`
				if [ $ntokens -gt 0 ] ; then
					ANYSECURED=1
					break
				fi
			done
			if [ $ANYSECURED = 1 ] ; then
				abspath=`expr "$DFTSECURITYDIR" : '^/'`
				if [ $abspath = 1 ] ; then
					SECURITYDIR="$DFTSECURITYDIR"
				else
					SECURITYDIR=${TOPDIR}'/'"$DFTSECURITYDIR"
				fi
				if [ "$LICENSE_PROMPT" = "y" ] ; then
					licensefile_loop=0
					while : ; do
						licensefile_loop=`expr $licensefile_loop + 1`
						if [ $licensefile_loop -ge $LOOP_LIMIT ] ; then
							echo ""
							echo "LOOP_LIMIT exceeded."
							eval ${ABORTCMD}
						fi
						echo ""
						echo "Enter name of license data file."
						echo $EB'[press '$RETURNKEYNAME' for '$SECURITYDIR'/'$DFTSECURITYFILE']: '$EE
						read A
						if [ "$A" != "" ] ; then
							SECURITYFILE="$A"
						else
							SECURITYFILE="$SECURITYDIR/$DFTSECURITYFILE"
						fi
						dir=`expr "$SECURITYFILE" : '\(.*\)/'`
						if [ "$dir" = "" -o "$dir" = "." ] ; then
							echo ""
							echo ""
							echo "You must enter a fully qualified name beginning with '/'."
							continue
						else
							break
						fi
					done
				else
					SECURITYFILE="$SECURITYDIR/$DFTSECURITYFILE"
				fi
			fi
		fi
		if [ $ALLOK1 = 1 ] ; then
			ANYSYMLINKS=0
			for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
				binlinks=`eval echo '$PKG_'$package_num'_BINLINKS'`
				ntokens=`echo $binlinks | wc -w`
				if [ $ntokens -gt 0 ] ; then
					ANYSYMLINKS=1
				fi
				if [ $ANYSYMLINKS -eq 1 ] ; then
					break
				fi
			done
			DOSYMLINKS=$ANYSYMLINKS
			DOFONTLINKS=$ANYFONTLINKS
			if [ $ANYSYMLINKS -eq 1 -o $ANYFONTLINKS -eq 1 ] ; then
				if [ "$AUTOSYMLINK" = "makescript" ] ; then
					dir=`expr "$SYMLINKSCRIPT" : '\(.*\)/'`
					if [ ! -w "$dir" ] ; then
						echo ""
						echo ""
						echo "You do not have permission to write to directory $dir."
						echo "Change permissions and then rerun $0."
						eval ${ABORTCMD}
					fi
					if [ -s "$SYMLINKSCRIPT" -o -f "$SYMLINKSCRIPT" ] ; then
						if [ ! -w "$SYMLINKSCRIPT" ] ; then
							echo ""
							echo ""
							echo "You do not have permission to write to file $SYMLINKSCRIPT."
							echo "Change permissions and then rerun $0."
							eval ${ABORTCMD}
						fi
						${RM} "$SYMLINKSCRIPT"
					fi
					DOSYMLINKS=0
					DOFONTLINKS=0
				elif [ "$AUTOSYMLINK" = "prompt" ] ; then
	
					dosymlinks_loop=0
					while : ; do
						dosymlinks_loop=`expr $dosymlinks_loop + 1`
						if [ $dosymlinks_loop -ge $LOOP_LIMIT ] ; then
							echo ""
							echo "LOOP_LIMIT exceeded."
							eval ${ABORTCMD}
						fi
						echo ""
						echo ""
						echo "$SYMLINK_PROMPT_1_TEXT"
						echo $EB"[YES/NO: Press $RETURNKEYNAME for YES]: "$EE
						read A
						if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" -o "$A" = ""  ] ; then
							break
						elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
							DOSYMLINKS=0
							break
						else
							echo ""
							echo "You must specify YES or NO.  Try again."
						fi
					done
					dosymlinks_loop=0
					if [ $ANYFONTLINKS -eq 1 ] ; then
						while : ; do
							dosymlinks_loop=`expr $dosymlinks_loop + 1`
							if [ $dosymlinks_loop -ge $LOOP_LIMIT ] ; then
								echo ""
								echo "LOOP_LIMIT exceeded."
								eval ${ABORTCMD}
							fi
							echo ""
							echo ""
							echo "$FONTLINK_PROMPT_1_TEXT"
							echo $EB"[YES/NO: Press $RETURNKEYNAME for YES]: "$EE
							read A
							if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" -o "$A" = ""  ] ; then
								break
							elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
								DOFONTLINKS=0
								break
							else
								echo ""
								echo "You must specify YES or NO.  Try again."
							fi
						done
					fi
				fi
	
	
				if [ $DOSYMLINKS -eq 1 ] ; then
					abspath=`expr $DFTSYMLINKDIR : '^/'`
					if [ $abspath = 1 ] ; then
						AUTOSYMLINKDIR="$DFTSYMLINKDIR"
					else
						AUTOSYMLINKDIR=${TOPDIR}'/'"$DFTSYMLINKDIR"
					fi
					if [ "$SYMLINKDIR_PROMPT" = "y" ] ; then
						symlinkdir_loop=0
						while : ; do
							symlinkdir_loop=`expr $symlinkdir_loop + 1`
							if [ $symlinkdir_loop -ge $LOOP_LIMIT ] ; then
								echo ""
								echo "LOOP_LIMIT exceeded."
								eval ${ABORTCMD}
							fi
							echo ""
							echo "$SYMLINK_PROMPT_2_TEXT"
							echo $EB'[press '$RETURNKEYNAME' for '$AUTOSYMLINKDIR']: '$EE
							read A
							if [ "$A" != "" ] ; then
								AUTOSYMLINKDIR="$A"
							fi
							if [ ! -d "$AUTOSYMLINKDIR"  ] ; then
								if $MKDIR $AUTOSYMLINKDIR ; then error=0; else error=1; fi
								if [ $error != 0  ] ; then
									echo "cannot create directory $AUTOSYMLINKDIR"
									eval ${ABORTCMD}
								fi
								chmod u+w $AUTOSYMLINKDIR
							fi
							if [ ! -w $AUTOSYMLINKDIR ] ; then
								echo ""
								echo ""
								echo "You do not have permission to write to $AUTOSYMLINKDIR."
								ALLOK1=0
							else
								break
							fi
						done
					else
						if [ ! -d "$AUTOSYMLINKDIR"  ] ; then
							if $MKDIR $AUTOSYMLINKDIR ; then error=0; else error=1; fi
							if [ $error != 0  ] ; then
								echo "cannot create directory $AUTOSYMLINKDIR"
								eval ${ABORTCMD}
							fi
							chmod u+w $AUTOSYMLINKDIR
						fi
						if [ ! -w $AUTOSYMLINKDIR ] ; then
							echo ""
							echo ""
							echo "You do not have permission to write to $AUTOSYMLINKDIR."
							eval ${ABORTCMD}
						fi
					fi
				fi
				NEWFONTHOME=""
				if [ $DOFONTLINKS -eq 1 ] ; then
				    while : ; do
					for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
						FONTHOME=`eval echo '$PKG_'$package_num'_FONTDIR'`
						AUTOFONTLINKDIR="$FONTHOME"
						fonthome="$AUTOFONTLINKDIR"
						if [ "$SYMLINKDIR_PROMPT" = "y" ] ; then
							symlinkdir_loop=0
							while : ; do
								symlinkdir_loop=`expr $symlinkdir_loop + 1`
								if [ $symlinkdir_loop -ge $LOOP_LIMIT ] ; then
									echo ""
									echo "LOOP_LIMIT exceeded."
									eval ${ABORTCMD}
								fi
								echo ""
								echo ""
								echo "Enter the full path of the directory in which you want"
								echo "applications to look for fonts, or press $RETURNKEYNAME to accept"
								echo "the default directory.  The directory will be created if it does"
								echo "not exist."
								echo $EB'[press '$RETURNKEYNAME' for '$AUTOFONTLINKDIR']: '$EE
								read A
								if [ "$A" != "" ] ; then
									AUTOFONTLINKDIR="$A"
								fi
								if [ ! -d "$AUTOFONTLINKDIR"  ] ; then
									if $MKDIR $AUTOFONTLINKDIR ; then error=0; else error=1; fi
									if [ $error != 0  ] ; then
										echo "cannot create directory $AUTOFONTLINKDIR"
										eval ${ABORTCMD}
									fi
									chmod u+w $AUTOFONTLINKDIR
									chmod a+rx $AUTOFONTLINKDIR
									CREATED=1
								fi
								if [ ! -w $AUTOFONTLINKDIR ] ; then
									echo ""
									echo ""
									echo "You do not have permission to write to $AUTOFONTLINKDIR."
									ALLOK1=0
								else
									break
								fi
							done
						else
							if [ ! -d "$AUTOFONTLINKDIR"  ] ; then
								if $MKDIR $AUTOFONTLINKDIR ; then error=0; else error=1; fi
								if [ $error != 0  ] ; then
									echo "cannot create directory $AUTOFONTLINKDIR"
									eval ${ABORTCMD}
								fi
								chmod u+w $AUTOFONTLINKDIR
								chmod a+rx $AUTOFONTLINKDIR
								CREATED=1
							fi
							if [ ! -w $AUTOFONTLINKDIR ] ; then
								echo ""
								echo ""
								echo "You do not have permission to write to $AUTOFONTLINKDIR."
								eval ${ABORTCMD}
							fi
						fi
						# Get last line of df statement.
						# Prepend X because if the mount point is too long,
						# the df command will result in two lines, with the
						# second line having blanks for the first field.
						lastdfline="X"`$DFCMD $AUTOFONTLINKDIR | $LASTLINECMD`
			
						# Determine if there is enough disk space for this install.
						case $KBYTES_AVAIL_FIELD in
							1)
								disk_kbytes=`echo $lastdfline | awk '{ print $1 }'`
								;;
							2)
								disk_kbytes=`echo $lastdfline | awk '{ print $2 }'`
								;;
							3)
								disk_kbytes=`echo $lastdfline | awk '{ print $3 }'`
								;;
							4)
								disk_kbytes=`echo $lastdfline | awk '{ print $4 }'`
								;;
							5)
								disk_kbytes=`echo $lastdfline | awk '{ print $5 }'`
								;;
							*)
								echo ""
								echo "Internal error. Unable to determine disk space."
								eval ${ABORTCMD}
								;;
						esac
						font_kbytes=`eval echo '$PKG_'$package_num'_KBYTES'`
						if [ $font_kbytes -ge $disk_kbytes ] ; then
							echo ""
							echo ""
							echo "There is not enough disk space for the installation."
							echo "The installation you requested requires $font_kbytes kilobytes of disk space"
							echo "and you currently have only $disk_kbytes kilobytes of available disk space"
							echo "in directory $AUTOFONTLINKDIR."
							if [ "$NPKGS_VISIBLE" -gt 1 ] ; then
								echo "Either install fewer packages or choose a different location to install"
								echo "the packages."
							else
								echo "Choose a different location to install the packages."
							fi
							echo ""
							echo ""
							echo "Press $RETURNKEYNAME to continue"
							read A
			
							# Make sure that SYMLINKDIR_PROMPT is "y" so that the next
							# time through the user has an opportunity to pick a
							# non-default directory.
							SYMLINKDIR_PROMPT="y"
							ALLOK1=0
						fi
						NEWFONTHOME="$NEWFONTHOME $AUTOFONTLINKDIR"
					done
					if [ $ALLOK1 -eq 1 ] ; then
						break
					else
						ALLOK1=1
						NEWFONTHOME=""
					fi
				    done # while
				fi
			fi
		fi
		
		# See if we will override any existing fonts with auto symbolic links.
		FONTLINKANYOLD=0
		tfonthome="$NEWFONTHOME"
		if [ $ALLOK1 -eq 1 -a $DOFONTLINKS -eq 1 ] ; then
			for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
				fonthome=`eval echo '$PKG_'$package_num'_FONTDIR'`
				newfonthome=`expr "$tfonthome" : '[ ]*\([^ ]*\)[ ]*'`
				tfonthome=`expr "$tfonthome" : '[ ]*[^ ]*\(.*\)'`
				if [ ! -z "$newfonthome" -a "$fonthome" != "$newfonthome" ] ; then
					fonthome="$newfonthome"
				fi
				if [ ! -z "$fonthome" ] ; then
					if [ -d $fonthome -o -h $fonthome ]; then
						FONTLINKANYOLD=1
						break
					fi
				fi
			done
		fi
		if [ $FONTLINKANYOLD -eq 1 ] ; then
		    if [ $CREATED -ne 1 ] ; then
		        while : ; do
				echo ""
				echo ""
				echo "*** Warning ***"
				echo "Some fonts are already installed in $fonthome.  This script"
				echo "checks the name of each font to be installed against those already"
				echo "installed in $fonthome.  You may choose to skip the"
				echo "installation of fonts whose names match, or you may replace matching"
				echo "fonts.  Fonts with no matching name will be installed regardless."   
				echo ""
				echo $EB"Do you want to replace fonts with matching names (YES/NO)? "$EE
				read A
				if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" -o "$A" = ""  ] ; then
					SKIPFONTS=0
					break
				elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
					SKIPFONTS=1
					break
				else
					echo ""
					echo "You must specify YES or NO.  Try again."
				fi
			done
		    fi
		fi
# INDENDATION END

	if [ $ALLOK1 = 1 ] ; then
		PSRES_PATH=""
		if [ "$PSRES_PROMPT" = "y" ] ; then
			echo ""
			echo ""
			# FLAGTAG Don't we have a variable we can use for the application name?
			echo "Enter a list of directories, separated by colons, where the application"
			echo "you are installing should look for fonts.  The following recommended"
			echo "directories are included automatically and need not be specified."
			echo ""
			echo "   $PSRES_DEFAULT"
			echo ""
			echo "Enter a list of additional font directories"
			echo $EB"[Press $RETURNKEYNAME to accept the recommended directories]: "$EE
			read PSRES_PATH
		fi
		if [ "$PSRES_PATH" = "" ] ; then
			PSRES_PATH="$PSRES_DEFAULT"
		elif [ "$PSRES_DEFAULT" != "" ] ; then
			PSRES_PATH="$PSRES_PATH:$PSRES_DEFAULT"
		fi
	fi

	ANY_XKEYSYMDB=0
	for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
		xkeysymdb=`eval echo '$PKG_'$package_num'_XKEYSYMDB'`
		if [ "$xkeysymdb" = 1 ] ; then
			ANY_XKEYSYMDB=1
			break
		fi
	done

	# Only ask next set of questions if user answered YES above.
	if [ $ALLOK1 = 1 ] ; then

		# See if any files and/or directories already exist with target names.
		for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
			eval "PKG_"$package_num"_OLD_VERSION_CHOICE=newinstallation"
			packagedesc=`eval echo '$PKG_'$package_num'_PKGDESC'`
			pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
			pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
			binlinks=`eval echo '$PKG_'$package_num'_BINLINKS'`
			paction=`eval echo '$PKG_'$package_num'_OLD_VERSION_ACTION'`
			package_dir=$pabbr"_"$pver
			autosymlink=`eval echo '$PKG_'$package_num'_AUTOSYMLINK'`
			if [ "$autosymlink" = "" ] ; then
				autosymlink="$DOSYMLINKS"
			fi
			fulldir=$TOPDIR/$package_dir
			if [ -d $fulldir -o -f $fulldir -o -h $fulldir ] ; then
				package_exists=1
			else
				package_exists=0
			fi
			link_exists=0
			ntokens=`echo $binlinks | wc -w`
			if [ "$autosymlink" = 1 -a $ntokens -gt 0 ] ; then
				for bin in $binlinks ; do
					# Next line is equiv to csh: set name=$bin:t
					name=`expr //$bin : '.*/\(.*\)'`
					if [ -f $AUTOSYMLINKDIR/$name -o -d $AUTOSYMLINKDIR/$name -o -h $AUTOSYMLINKDIR/$name ]; then
						link_exists=1
						break
					fi
				done
			fi
			if [ "$package_exists" = 1 -o "$link_exists" = 1 ] ; then

				case "$paction" in
				"quiet:leavealone"|"quiet:overwrite")
					break
					;;
 				"prompt:leavealone/overwrite")
					leavealonedir_loop=0
					while : ; do
						leavealonedir_loop=`expr $leavealonedir_loop + 1`
						if [ $leavealonedir_loop -ge $LOOP_LIMIT ] ; then
							echo ""
							echo "LOOP_LIMIT exceeded."
							eval ${ABORTCMD}
						fi
						echo "" 
						echo ""
						echo "*** WARNING ***"
						echo "Components of $packagedesc are already installed on"
						echo "your system in the following locations. You can either"
						echo "leave the existing installation unchanged or re-install"
						echo "$packagedesc, thereby replacing all of the"
						echo "files/directories listed below. If you choose to re-install,"
						echo "be sure to copy any personal files or customizations within"
						echo "these files/directories to another location before continuing"
						echo "with this procedure:"
						echo ""
						if [ "$package_exists" = 1 ] ; then
							echo_file_name_and_type "$fulldir"
						fi
						if [ "$link_exists" = 1 ] ; then
							ntokens=`echo $binlinks | wc -w`
							if [ $ntokens -gt 0 ] ; then
								for bin in $binlinks ; do
									# Next line is equiv to csh: set name=$bin:t
									name=`expr //$bin : '.*/\(.*\)'`
									if [ -f $AUTOSYMLINKDIR/$name -o -d $AUTOSYMLINKDIR/$name -o -h $AUTOSYMLINKDIR/$name ]; then
										echo_file_name_and_type "$AUTOSYMLINKDIR/$name"
									fi
								done
							fi
						fi

						echo ""
						echo "Do you wish to install $packagedesc, replacing the"
						echo $EB"above components (YES/NO) [press $RETURNKEYNAME for NO]: "$EE
						read A
						echo ""
						if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" ] ; then
							eval "PKG_"$package_num"_OLD_VERSION_CHOICE=overwrite"
							break
						elif [ "$A" = "" -o "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
							eval "PKG_"$package_num"_OLD_VERSION_CHOICE=leavealone"
							break
						else
							echo ""
							echo "You must specify YES or NO or simply press $RETURNKEYNAME for NO.  Try again."
						fi
					done
					;;
				*|"prompt:oktodelete")
					overwritedir_loop=0
					while : ; do
						overwritedir_loop=`expr $overwritedir_loop + 1`
						if [ $overwritedir_loop -ge $LOOP_LIMIT ] ; then
							echo ""
							echo "LOOP_LIMIT exceeded."
							eval ${ABORTCMD}
						fi
						echo "" 
						echo ""
						echo "*** WARNING ***"
						echo "The following files and/or directories already exist for"
						echo "$packagedesc.  If you continue with this installation"
						echo "you will overwrite them.  Be sure to copy any personal"
						echo "files to another location before continuing the installation."
						echo ""
						echo "    $fulldir"
						ntokens=`echo $binlinks | wc -w`
						if [ $ntokens -gt 0 ] ; then
							for bin in $binlinks ; do
								# Next line is equiv to csh: set name=$bin:t
								name=`expr //$bin : '.*/\(.*\)'`
								if [ -f $AUTOSYMLINKDIR/$name -o -d $AUTOSYMLINKDIR/$name -o -h $AUTOSYMLINKDIR/$name ]; then
									echo "    $AUTOSYMLINKDIR/$name"
								fi
							done
						fi
						echo ""
						echo $EB"OK to proceed (YES/NO)? "$EE
						read A
						echo ""
						if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" ] ; then
							eval "PKG_"$package_num"_OLD_VERSION_CHOICE=overwrite"
							break
						elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
							echo ""
							echo "Please specify a different location for installing the packages"
							if [ "$WHICH_PACKAGES" = "prompt" ] ; then
								echo "or a different set of packages to install"
							fi
							echo "Press $RETURNKEYNAME to restart the script or use your interrupt key to exit the script"
							read A
							ALLOK1=0
							break
						else
							echo ""
							echo "You must specify YES or NO.  Try again."
						fi
					done
					;;
				esac
			fi
			if [ "$ALLOK1" != 1 ] ; then
				break
			fi
		done

		# Adjust PKGS_TO_INSTALL_REQUESTED and PKGS_TO_INSTALL_TOTAL to reflect
		# decisions not to install over existing packages.
		NEW_PKGS_REQUESTED=""
		for package_num in ${PKGS_TO_INSTALL_REQUESTED} ; do
			pchoice=`eval echo '$PKG_'$package_num'_OLD_VERSION_CHOICE'`
			if [ "$pchoice" != "leavealone" ] ; then
				NEW_PKGS_REQUESTED="$NEW_PKGS_REQUESTED $package_num"
			fi
		done
		NEW_PKGS_TOTAL=""
		for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
			pchoice=`eval echo '$PKG_'$package_num'_OLD_VERSION_CHOICE'`
			if [ "$pchoice" != "leavealone" ] ; then
				NEW_PKGS_TOTAL="$NEW_PKGS_TOTAL $package_num"
			fi
		done
		PKGS_TO_INSTALL_REQUESTED="$NEW_PKGS_REQUESTED"
		PKGS_TO_INSTALL_TOTAL="$NEW_PKGS_TOTAL"

		if [ "$PKGS_TO_INSTALL_TOTAL" = "" ] ; then
			echo ""
			echo "No packages require installation."
			eval ${ABORTCMD}
		fi

		if [ $ALLOK1 = 1 ] ; then
			# Get last line of df statement.
			# Prepend X because if the mount point is too long,
			# the df command will result in two lines, with the
			# second line having blanks for the first field.
			lastdfline="X"`$DFCMD ${TOPDIR} | $LASTLINECMD`

			# Determine if there is enough disk space for this install.
			case $KBYTES_AVAIL_FIELD in
				1)
					disk_kbytes=`echo $lastdfline | awk '{ print $1 }'`
					;;
				2)
					disk_kbytes=`echo $lastdfline | awk '{ print $2 }'`
					;;
				3)
					disk_kbytes=`echo $lastdfline | awk '{ print $3 }'`
					;;
				4)
					disk_kbytes=`echo $lastdfline | awk '{ print $4 }'`
					;;
				5)
					disk_kbytes=`echo $lastdfline | awk '{ print $5 }'`
					;;
				*)
					echo ""
					echo "Internal error. Unable to determine disk space."
					eval ${ABORTCMD}
					;;
			esac
			total_kbytes=0
			for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
				pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
				pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
				package_dir=$pabbr"_"$pver
				fulldir=$TOPDIR/$package_dir
				pchoice=`eval echo '$PKG_'$package_num'_OLD_VERSION_CHOICE'`
				if [ "$pchoice" = "newinstallation" ] ; then
					kbytes=`eval echo '$PKG_'$package_num'_KBYTES'`
					total_kbytes=`expr $total_kbytes + $kbytes`
				elif [ "$pchoice" = "overwrite" ] ; then
					oldkbytes=`$DUCMD $fulldir | $AWK '{print $1;}'`
					# IRIX 5.3 du command returns nothing if the $fulldir does not exist
					if [ "X$oldkbytes" = "X" ] ; then
						oldkbytes=0
					fi
					# HP-UX has no option for printing kbytes, only blocks.
					# So, scale down by .5 on that platform.
					oldkbytes=`expr $oldkbytes \* $DUFACTOR`
					newkbytes=`eval echo '$PKG_'$package_num'_KBYTES'`
					total_kbytes=`expr $total_kbytes + $newkbytes - $oldkbytes`
				fi
			done
			if [ $total_kbytes -ge $disk_kbytes ] ; then
				echo ""
				echo ""
				echo "There is not enough disk space for the installation."
				echo "The installation you requested requires $total_kbytes kilobytes of disk space"
				echo "and you currently have only $disk_kbytes kilobytes of available disk space"
				echo "in directory ${TOPDIR}."
				if [ "$NPKGS_VISIBLE" -gt 1 ] ; then
					echo "Either install fewer packages or choose a different location to install"
					echo "the packages."
				else
					echo "Choose a different location to install the packages."
				fi
				echo ""
				echo ""
				echo "Press $RETURNKEYNAME to continue"
				read A

				# Make sure that ROOTDIR_PROMPT is "y" so that the next
				# time through the user has an opportunity to pick a
				# non-default <root directory>.
				ROOTDIR_PROMPT="y"
				ALLOK1=0
			fi
		fi
	fi

	if [ $ALLOK1 = 1 ] ; then
		$CLEAR
		echo ""
		echo "Installation summary:"
		echo ""

		okproceed_loop=0
		while : ; do
			okproceed_loop=`expr $okproceed_loop + 1`
			if [ $okproceed_loop -ge $LOOP_LIMIT ] ; then
				echo ""
				echo "LOOP_LIMIT exceeded."
				eval ${ABORTCMD}
			fi
			# Check to see if anything will be deleted.
			anydelete=0
			for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
				pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
				pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
				binlinks=`eval echo '$PKG_'$package_num'_BINLINKS'`
				pchoice=`eval echo '$PKG_'$package_num'_OLD_VERSION_CHOICE'`
				package_dir=$pabbr"_"$pver
				autosymlink=`eval echo '$PKG_'$package_num'_AUTOSYMLINK'`
				if [ "$autosymlink" = "" ] ; then
					autosymlink="$DOSYMLINKS"
				fi
				fulldir=$TOPDIR/$package_dir
				if [ -d $fulldir -o -f $fulldir -o -h $fulldir ] ; then
					package_exists=1
				else
					package_exists=0
				fi
				link_exists=0
				ntokens=`echo $binlinks | wc -w`
				if [ "$autosymlink" = 1 -a $ntokens -gt 0 ] ; then
					for bin in $binlinks ; do
						# Next line is equiv to csh: set name=$bin:t
						name=`expr //$bin : '.*/\(.*\)'`
						if [ -f $AUTOSYMLINKDIR/$name -o -d $AUTOSYMLINKDIR/$name -o -h $AUTOSYMLINKDIR/$name ]; then
							link_exists=1
							break
						fi
					done
				fi
				if [ "$package_exists" = 1 -o "$link_exists" = 1 ] ; then
					if [ "$pchoice" = "overwrite" ] ; then
						anydelete=1
						break
					fi
				fi
			done
			if [ "$anydelete" = 1 ] ; then
				echo ""
				echo "The following files and/or directories will be overwritten."
				echo ""
				for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
					pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
					pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
					binlinks=`eval echo '$PKG_'$package_num'_BINLINKS'`
					pchoice=`eval echo '$PKG_'$package_num'_OLD_VERSION_CHOICE'`
					package_dir=$pabbr"_"$pver
					autosymlink=`eval echo '$PKG_'$package_num'_AUTOSYMLINK'`
					if [ "$autosymlink" = "" ] ; then
						autosymlink="$DOSYMLINKS"
					fi
					fulldir=$TOPDIR/$package_dir
					if [ "$pchoice" = "overwrite" ] ; then
						if [ -d $fulldir -o -f $fulldir -o -h $fulldir ] ; then
							echo_file_name_and_type "$fulldir"
						fi
						ntokens=`echo $binlinks | wc -w`
						if [ "$autosymlink" = 1 -a $ntokens -gt 0 ] ; then
							for bin in $binlinks ; do
								# Next line is equiv to csh: set name=$bin:t
								name=`expr //$bin : '.*/\(.*\)'`
								if [ -f $AUTOSYMLINKDIR/$name -o -d $AUTOSYMLINKDIR/$name -o -h $AUTOSYMLINKDIR/$name ]; then
									echo_file_name_and_type "$AUTOSYMLINKDIR/$name"
								fi
							done
						fi
					fi
				done
			fi
			echo ""
			echo "The following packages will be installed."
			echo ""
			for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
				pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
				pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
				package_dir=$pabbr"_"$pver
				fulldir=$TOPDIR/$package_dir
				kbytes=`eval echo '$PKG_'$package_num'_KBYTES'`
				echo "    "$fulldir '('$kbytes'K)'
			done

			if [ $DOSYMLINKS = 1 ] ; then
				echo ""
				echo "The following symbolic links will be created:"
				echo ""
				for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
					packagedesc=`eval echo '$PKG_'$package_num'_PKGDESC'`
					pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
					pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
					package_dir=$pabbr"_"$pver
					fulldir=$TOPDIR/$package_dir
					binlinks=`eval echo '$PKG_'$package_num'_BINLINKS'`
					ntokens=`echo $binlinks | wc -w`
					if [ $ntokens -gt 0 ] ; then
						for bin in $binlinks ; do
							# Next line is equiv to csh: set name=$bin:t
							name=`expr //$bin : '.*/\(.*\)'`
							echo "    ${LN} $fulldir/$bin $AUTOSYMLINKDIR/$name"
						done
					fi
				done
			fi
			if [ $DOFONTLINKS = 1 ] ; then
				echo ""
				echo "The following commands will be executed for fonts:"
				echo ""
				tfonthome="$NEWFONTHOME"
				for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
					packagedesc=`eval echo '$PKG_'$package_num'_PKGDESC'`
					pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
					pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
					package_dir=$pabbr"_"$pver
					fulldir=$TOPDIR/$package_dir
					uprfile=`eval echo '$PKG_'$package_num'_FONTUPR'`
					fonthome=`eval echo '$PKG_'$package_num'_FONTDIR'`
					newfonthome=`expr "$tfonthome" : '[ ]*\([^ ]*\)[ ]*'`
					tfonthome=`expr "$tfonthome" : '[ ]*[^ ]*\(.*\)'`
					if [ ! -z "$newfonthome" -a "$fonthome" != "$newfonthome" ] ; then
						fonthome="$newfonthome"
					fi
					echo "    ${DIRCP} $fulldir/$FONTPATTERN $fonthome"
					if [ "$AUTOSYMLINK" != "makescript" ] ; then
						echo "    ${DIRRM} $fulldir/$FONTPATTERN"
					fi
					name=`expr //$uprfile : '.*/\(.*\)'`
					if [ -z "$name" ] ; then
						name="$uprfile"
					fi
					dir=`expr "$fonthome" : '\(.*\)/'`
					echo "    ${CP} $fulldir/$uprfile $dir/$name"
					# X font info files
					fdir=`expr "$FONTPATTERN" : '\(.*\)/'`
					if [ -f $fulldir/$fdir/fonts.dir ] ; then
						echo "    ${CP} $fulldir/$fdir/fonts.dir $fonthome"
					fi
					if [ -f $fulldir/$fdir/fonts.alias ] ; then
						echo "    ${CP} $fulldir/$fdir/fonts.alias $fonthome"
					fi
				done
			fi
			echo ""
			echo ""
			echo $EB'Do you want to proceed with the installation (YES/NO)? '$EE
			read A
			if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" ] ; then
				echo ""
				break
			elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
				eval ${ABORTCMD}
			else
				echo ""
				echo "You must specify YES or NO.  Try again."
			fi
		done
	fi

	# Can we proceed with the installation?
	if [ $ALLOK1 = 1 ] ; then
		break
	fi
done

$CLEAR
echo "" 
echo ""
echo "Beginning installation..."
echo ""
echo "This may take some time, depending on the number of items"
echo "you have selected and the performance of your chosen device."
echo ""

# Remove any files and/or directories that will be overwritten.
if [ "$anydelete" = 1 ] ; then
	echo ""
	echo "Removing the following files and/or directories:"
	for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
		pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
		pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
		binlinks=`eval echo '$PKG_'$package_num'_BINLINKS'`
		pchoice=`eval echo '$PKG_'$package_num'_OLD_VERSION_CHOICE'`
		package_dir=$pabbr"_"$pver
		fulldir=$TOPDIR/$package_dir
		autosymlink=`eval echo '$PKG_'$package_num'_AUTOSYMLINK'`
		if [ "$autosymlink" = "" ] ; then
			autosymlink="$DOSYMLINKS"
		fi
		if [ "$pchoice" = "overwrite" ] ; then
			if [ -d $fulldir -o -f $fulldir -o -h $fulldir ] ; then
				echo $EB"    "$fulldir"..."$EE
				${RM} -r $fulldir
				echo done
			fi
			if [ "$autosymlink" = 1 ] ; then
				ntokens=`echo $binlinks | wc -w`
				if [ $ntokens -gt 0 ] ; then
					for bin in $binlinks ; do
						# Next line is equiv to csh: set name=$bin:t
						name=`expr //$bin : '.*/\(.*\)'`
						if [ -f $AUTOSYMLINKDIR/$name -o -d $AUTOSYMLINKDIR/$name -o -h $AUTOSYMLINKDIR/$name ] ; then
							echo $EB"    $AUTOSYMLINKDIR/$name..."$EE
							${RM} -r $AUTOSYMLINKDIR/$name
							echo done
						fi
					done
				fi
			fi
		fi
	done
	echo ""
fi

# First, with package_num_tar==0, loop through all packages to see which
# ones use the default tar file ($DEVPATH). Build a list and extract the files.
# Then, for each package with own special tar file, loop through all
# packages to see what other packages use that special tar file.
# The logic causes each package to be extracted exactly once.
# For each different tar file, build a list of packages to extract.
# Then, extract the desired packages.
for package_num_tar in 0 ${PKGS_TO_INSTALL_TOTAL} ; do
	INSTALL_METHOD=`eval echo '$PKG_'$package_num_tar'_INSTALL_METHOD'`
	if [ "$INSTALL_METHOD" = "" -o "$INSTALL_METHOD" = "tarfile" ] ; then
		if [ "$package_num_tar" -eq 0 ] ; then
			TARFILE="$DEVPATH"
			if [ "$TARFILE" = "" ] ; then
				continue
			fi
		else
			TARFILE_RELATIVE=`eval echo '$PKG_'$package_num_tar'_TARFILE'`
			if [ "$TARFILE_RELATIVE" = "" ] ; then
				continue
			fi
			TARFILE="$CDDIR/$TARFILE_RELATIVE"
		fi

		# Build the list of packages to extract from this tar file.
		FILELIST=""
		for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
			pextracted=`eval echo '$PKG_'$package_num'_EXTRACTED'`
			if [ "$pextracted" = 1 ] ; then
				continue
			fi
			installmethod=`eval echo '$PKG_'$package_num'_INSTALL_METHOD'`
			if [ "$installmethod" = "" -o "$installmethod" = "tarfile" ] ; then
				ptarfile=`eval echo '$PKG_'$package_num'_TARFILE'`
				pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
				pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
				package_dir=$pabbr"_"$pver
				if [ "$ptarfile" = "" -a "$package_num_tar" -eq 0 ] ; then
					FILELIST=${FILELIST}\'$package_dir\'' '
					eval "PKG_"$package_num"_EXTRACTED=1"
				elif [ "$ptarfile" = "$TARFILE_RELATIVE" ] ; then
					FILELIST=${FILELIST}\'$package_dir\'' '
					eval "PKG_"$package_num"_EXTRACTED=1"
				fi
			fi
		done

		# Extract the desired packages.
		if [ "$FILELIST" != "" ] ; then
			if [ "$RHOST" = "" ] ; then
				INSTALLCOMMAND="$TAR $TAR_OPTS_X $TARFILE ${FILELIST}"
			else
				INSTALLCOMMAND="rsh -n $RHOST dd if=$TARFILE | $TAR $TAR_OPTS_X ${FILELIST}"
			fi
			olddir=`pwd`
			cd $TOPDIR
			eval "${INSTALLCOMMAND}"
			cd $olddir
		fi
	elif [ "$INSTALL_METHOD" = "tar-to-tar" -o "$INSTALL_METHOD" = "cp" ] ; then
		FILES=`eval echo '$PKG_'$package_num_tar'_FILES'`
		FILES_DIRECTORY=`eval echo '$PKG_'$package_num_tar'_FILES_DIRECTORY'`

		# Extract the desired packages.
		if [ "$FILES" != "" ] ; then
			if [ "$RHOST" = "" ] ; then
				if [ "$INSTALL_METHOD" = "tar-to-tar" ] ; then
					INSTALLCOMMAND='('"cd $CDDIR/$FILES_DIRECTORY"';'"$TAR $TAR_OPTS_C - ${FILES}"')|('"cd $TOPDIR"';'"$TAR $TAR_OPTS_X -"')'
				elif [ "$INSTALL_METHOD" = "cp" ] ; then
					INSTALLCOMMAND='('"cd $CDDIR/$FILES_DIRECTORY"';'"$DIRCP ${FILES} $TOPDIR"')'
				else
					# Shouldn't happen.
					INSTALLCOMMAND="Error in install script"
				fi
			else
				echo ""
				echo "Cannot extract package from remote host."
				eval ${ABORTCMD}
			fi
                        if [ "$INSTALL_METHOD" = "cp" ] ; then
                                echo $EB"Copy ${FILES} to $TOPDIR..."$EE
                        fi
			eval "${INSTALLCOMMAND}"
                        if [ "$INSTALL_METHOD" = "cp" ] ; then
                                echo "done"
                        fi
		fi
	else
		echo ""
		echo 'Invalid value for PKG_'$package_num_tar'_INSTALL_METHOD.'
		eval ${ABORTCMD}
	fi
	
done

# Process packages
ALREADY_XKEYSYMDB=0
LMFEATURELIST=""
MAKESCRIPT=0
ONESCRIPT=0
for package_num in 0 ${PKGS_TO_INSTALL_TOTAL} ; do
	PERPKGFONTSIZE=""
	packagedesc=`eval echo '$PKG_'$package_num'_PKGDESC'`
	pabbr=`eval echo '$PKG_'$package_num'_PKGABBR'`
	pver=`eval echo '$PKG_'$package_num'_PKGVERS'`
	package_dir=$pabbr"_"$pver
	fulldir=$TOPDIR/$package_dir
	autosymlink=`eval echo '$PKG_'$package_num'_AUTOSYMLINK'`
	if [ "$autosymlink" = "" ] ; then
		autosymlink="$DOSYMLINKS"
	fi

	# Install makelinks scripts for all installed packages in /tmp if "makescript" and
	# any symlinks in this installation.
	# Install makelinks scripts for each package in installscripts/ if
	# package_num>0 and any symlinks.
	lnks=`expr $ANYSYMLINKS + $ANYFONTLINKS`
	if [ package_num -eq 0 -a "$AUTOSYMLINK" = "makescript" -a $lnks -ge 1 -o $package_num -ge 1 -a "$autosymlink" != "0" ] ; then

		# Put a script in $SYMLINKSCRIPT that creates symbolic
		# links for all installed packages. Also, put a
		# script in the installscripts directory for each package which
		# can be run to create links for that package.
		# The "0" option below covers the $SYMLINKSCRIPT case.
		binlist=""
		uprfiles=""
		fonthome=""
		tfonthome="$NEWFONTHOME"
		if [ "$package_num" = 0 ] ; then
			scriptfile="$SYMLINKSCRIPT"
			# Construct a list of absolute paths to launch scripts.
			for package_num0 in ${PKGS_TO_INSTALL_TOTAL} ; do
				pabbr0=`eval echo '$PKG_'$package_num0'_PKGABBR'`
				pver0=`eval echo '$PKG_'$package_num0'_PKGVERS'`
				package_dir0=$pabbr0"_"$pver0
				fulldir0=$TOPDIR/$package_dir0
				binlinks0=`eval echo '$PKG_'$package_num0'_BINLINKS'`
				ntokens0=`echo $binlinks0 | wc -w`
				if [ $ntokens0 -gt 0 ] ; then
					for bin0 in $binlinks0 ; do
						binlist="$binlist $fulldir0/$bin0"
					done
				fi
				uprfile0=`eval echo '$PKG_'$package_num0'_FONTUPR'`
				ftokens=`echo $uprfile0 | wc -w`
				if [ $ftokens -gt 0 ] ; then
					for upr0 in $uprfile0 ; do
						uprfiles="$uprfiles $fulldir0/$upr0"
					done
				fi
				fonthome0=`eval echo '$PKG_'$package_num0'_FONTDIR'`
				newfonthome=`expr "$tfonthome" : '[ ]*\([^ ]*\)[ ]*'`
				tfonthome=`expr "$tfonthome" : '[ ]*[^ ]*\(.*\)'`
				if [ ! -z "$newfonthome" -a "$fonthome0" != "$newfonthome" ] ; then
					fonthome0="$newfonthome"
				fi
				fonthome="$fonthome $fonthome0"
				font_kbytes=`eval echo '$PKG_'$package_num0'_KBYTES'`
				PERPKGFONTSIZE="$PERPKGFONTSIZE $font_kbytes"
			done
			MAKESCRIPT=1
			ONESCRIPT=1
			fulldir=$fulldir0
		else
			binlinks=`eval echo '$PKG_'$package_num'_BINLINKS'`
			ntokens=`echo $binlinks | wc -w`
			MAKESCRIPT=0
			if [ $ntokens -gt 0 ] ; then
				scriptdir=$fulldir/installscripts
				if [ ! -d "$scriptdir" ] ; then
					$MKDIR $scriptdir
					chmod a+rx $scriptdir
				fi
				scriptfile="$scriptdir"/makelinks
				for bin in $binlinks ; do
					binlist="$binlist $bin"
				done
				MAKESCRIPT=1
			fi
			fonthome=`eval echo '$PKG_'$package_num0'_FONTDIR'`
			newfonthome=`expr "$tfonthome" : '[ ]*\([^ ]*\)[ ]*'`
			tfonthome=`expr "$tfonthome" : '[ ]*[^ ]*\(.*\)'`
			if [ ! -z "$newfonthome" -a "$fonthome" != "$newfonthome" ] ; then
				fonthome="$newfonthome"
			fi
			scriptdir=$fulldir/installscripts
			if [ ! -d "$scriptdir" ] ; then
				$MKDIR $scriptdir
				chmod a+rx $scriptdir
			fi
			scriptfile="$scriptdir"/makelinks
			uprfile=`eval echo '$PKG_'$package_num'_FONTUPR'`
			ftokens=`echo $uprfile | wc -w`
			if [ $ftokens -gt 0 ] ; then
				for upr in $uprfile ; do
					uprfiles="$uprfiles $upr"
				done
				MAKESCRIPT=1
			fi
			font_kbytes=`eval echo '$PKG_'$package_num'_KBYTES'`
			PERPKGFONTSIZE="$font_kbytes"
		fi
		if [ "$MAKESCRIPT" = 1 ] ; then
			echo '#!/bin/sh
# Shell script for automatically installing launch scripts and
# other small programs into an alternate launch script directory.' > "$scriptfile"
						echo 'binlinks="'"$binlist"'"' >> "$scriptfile"
						if [ $ANYFONTLINKS -eq 1 ] ; then
							echo 'uprfiles="'"$uprfiles"'"' >> $scriptfile
							echo 'fonthome="'"$fonthome"'"' >> $scriptfile
							echo 'fontpattern="'"$FONTPATTERN"'"' >> $scriptfile
							echo 'PSRES_PATH="'"$PSRES_PATH"'"' >> $scriptfile
							echo 'USER_INFO_FILE="'"$USER_INFO_FILE"'"' >> $scriptfile
							echo 'DOFONTLINKS=1' >> $scriptfile
							echo 'DFCMD="'"$DFCMD"'"' >> $scriptfile
							echo 'PERPKGFONTSIZE="'"$PERPKGFONTSIZE"'"' >> $scriptfile
							echo 'KBYTES_AVAIL_FIELD="'"$KBYTES_AVAIL_FIELD"'"' >> $scriptfile
						else
							echo 'DOFONTLINKS=0' >> $scriptfile
						fi
						echo 'LOOP_LIMIT='$LOOP_LIMIT >> "$scriptfile"
						echo 'defaultinstalldir="'"$fulldir"'"' >> "$scriptfile"
						echo 'defaultdir="/usr/bin"
# For echo without newline under BSD, set EB and EE variables
osname="UNKNOWN"
osversion="UNKNOWN"
EB="-n "
EE=""
if [ -x /bin/uname ]
then
	osname=`/bin/uname -s`
        # 64 bit IRIX6 returns IRIX64 for uname -s
	firstfour=`echo "$osname" | sed -e '\''s/^\(....\).*$/\1/g'\''`
        if [ "$firstfour" = "IRIX" ]
	then
                osname="IRIX"
        fi
	osversion=`/bin/uname -r`
	check=`echo "$osversion" | egrep '\''^[0-9]\.[0-9]*'\''`
	if [ "$check" != "" ]
	then
		# osmajorminor will be like "4.2". osmajor: "4". osminor:"2".
		osmajorminor=`echo "$osversion" | sed -e '\''s/^\([0-9]\.[0-9]\).*/\1/'\''`
		osmajor=`echo "$osversion" | sed -e '\''s/^\([0-9][0-9]*\).*/\1/'\''`
		osminor=`echo "$osversion" | sed -e '\''s/^[0-9]\.\([0-9][0-9]*\).*/\1/'\''`
	fi
fi
if [ $osname = "SunOS" ]
then
	STDBINDIR="/usr/bin"
	RETURNKEYNAME="Return"
	if [ $osmajor -ge 5 ]
	then
		# For echo without newline under Sys V, set EB and EE variables
		EB=""
		EE="'\\\\'c"
		PATH=/usr/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/openwin/bin:/sbin:/usr/sbin:/etc:/usr/etc
	else
		# For echo without newline under BSD, set EB and EE variables
		EB="-n "
		EE=""
		PATH=/usr/bin:/bin:/usr/bin/X11:/usr/openwin/bin:/sbin:/etc:/usr/etc
	fi

elif [ $osname = "IRIX" ]
then
	STDBINDIR="/usr/bin"
	RETURNKEYNAME="Enter"
	# For echo without newline under Sys V, set EB and EE variables
	EB=""
	EE="'\\\\'c"
	PATH=/usr/sbin:/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/openwin/bin:/etc:/usr/etc
elif [ $osname = "HP-UX" ]
then
	STDBINDIR="/bin"
	RETURNKEYNAME="Return"
	# For echo without newline under Sys V, set EB and EE variables
	EB=""
	EE="'\\\\'c"
	PATH=/usr/sbin:/sbin:/usr/bin:/bin:/usr/bin/X11:/etc:/usr/etc
fi
if [ "$osname" = "UNKNOWN" -o "$osversion" = "UNKNOWN" ]
then
	echo ""
	echo "Unrecognized operating system. Cannot make links."
	exit 1
fi
MKDIR="$STDBINDIR/mkdir -p "
RMDIR="$STDBINDIR/rmdir "
LN="$STDBINDIR/ln -s"
RM="$STDBINDIR/rm -f"
ECHO="$STDBINDIR/echo"
SED="$STDBINDIR/sed"
LS="$STDBINDIR/ls"
EXPR="$STDBINDIR/expr"
PWDPROG="$STDBINDIR/pwd"
DIRCP="$STDBINDIR/cp -pr"
DIRRM="$STDBINDIR/rm -rf"
CP="$STDBINDIR/cp"
CD="cd"
CAT="$STDBINDIR/cat"
installdir="$defaultinstalldir"

umask 22

# Try to determine the parent directory to this launch script.
# Follow any symbolic links in thisscriptname.
thisscriptname=$0
while :
do
	lsresult=`$LS -l $thisscriptname`
	symlink=`$EXPR "$lsresult" : '\''.*>'\''.*`
	if [ "$symlink" -gt 0 ]
	then
		oldscriptname="$thisscriptname"
		thisscriptname=`$ECHO $lsresult|$SED -e '\''s/^.*-> *\(.*\) *$/\1/g'\''`
		abspath_new=`$EXPR "$thisscriptname" : '\''^/'\''`
		if [ $abspath_new != 1 ]
		then
			abspath_old=`$EXPR "$oldscriptname" : '\''^/'\''`
			if [ $abspath_old != 1 ]
			then
				olddir=`$PWDPROG`
			else
				olddir=`$EXPR "$oldscriptname" : '\''\(.*\)/'\''` 
			fi
			thisscriptname="$olddir/$thisscriptname"
		fi
	else
		break
	fi
done
# Determine directory containing this shell script.
scriptdir=`$EXPR $thisscriptname : '\''\(.*\)/'\''` 
if [ "$scriptdir" = "" -o "$scriptdir" = "." ]
then
	scriptdir=`$PWDPROG`
fi
# If scriptdir is /tmp, then do not try to override defaultdir.
if [ "$scriptdir" != "/tmp" ]
then
	# Determine root directory for installation ($scriptdir/..).
	parentdir=`$EXPR $scriptdir : '\''\(.*\)/'\''` 
	if [ "$parentdir" != "" ]
	then
		installdir="$parentdir"
	fi
fi
echo ""
echo ""
echo "Enter the full path of the directory into which you want to create"
echo "symbolic links for programs and/or scripts"
echo $EB"[Press $RETURNKEYNAME for /usr/bin]: "$EE
read launchdir
if [ "$launchdir" = "" ] 
then
	launchdir="$defaultdir"
fi
if [ ! -d "$launchdir"  ] 
then
	if $MKDIR $launchdir
	then error=0
	else error=1
	fi
	if [ $error != 0  ]
	then
		echo "Cannot create directory $launchdir"
		echo "You must choose different options or change permissions"
		echo "and then rerun this script."
		exit 1
	fi
	chmod u+w "$launchdir"
	chmod a+rx "$launchdir"
fi
if [ ! -w $launchdir ]
then
	echo ""
	echo ""
	echo "You do not have permission to write to $launchdir."
	echo "You must choose different options or change permissions"
	echo "and then rerun this script."
	exit 1
fi
makelinks_loop=0
while :
do
	makelinks_loop=`expr $makelinks_loop + 1`
	if [ $makelinks_loop -ge $LOOP_LIMIT ]
	then
		echo ""
		echo "LOOP_LIMIT exceeded."
		exit 1
	fi
	echo ""
	echo ""
	echo "This script will issue the following commands to install the"
	echo "programs and/or scripts:"
	echo ""
	for bin in $binlinks ; do
		# Next line extracts filename from full path
		name=`expr //$bin : '\''.*/\(.*\)'\''`
		abspath_bin=`$EXPR "$bin" : '\''^/'\''`
		if [ $abspath_bin != 1 ] ; then
			echo ${LN} "$installdir/$bin" "$launchdir/$name"
		else
			echo ${LN} "$bin" "$launchdir/$name"
		fi
	done
	echo ""
	echo $EB"OK to proceed (YES/NO)? "$EE
	read A
	if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" ] ; then
		break
	elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
		DOSYMLINKS=0
		echo "Installation of programs and/or scripts cancelled."
		exit 1
	else
		echo ""
		echo "You must specify YES or NO.  Try again."
	fi
done

#BEGIN link_loop_func
	funclist="$binlinks"
	funcdir="$installdir"
	for bin in $funclist ; do
		# Next line extracts filename from full path
		name=`expr //$bin : '\''.*/\(.*\)'\''`
		if [ -f "$launchdir/$name" -o -d "$launchdir/$name" -o -h "$launchdir/$name" ]
		then
			overwritelink_loop=0
			while :
			do
				overwritelink_loop=`expr $overwritelink_loop + 1`
				if [ $overwritelink_loop -ge $LOOP_LIMIT ] ; then
					echo ""
					echo "LOOP_LIMIT exceeded."
					eval ${ABORTCMD}
				fi
				echo ""
				echo "File $launchdir/$name already exists. OK to replace"
				echo $EB"(YES/NO)? "$EE
				read A
				if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" ] ; then
					${RM} "$launchdir/$name"
					abspath_bin=`expr "$bin" : '\''^/'\''`
					if [ $abspath_bin != 1 ] ; then
						${LN} "$funcdir/$bin" "$launchdir/$name"
					else
						${LN} "$bin" "$launchdir/$name"
					fi
					break
				elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
					break
				else
					echo ""
					echo "You must specify YES or NO.  Try again."
				fi
			done
		else
			abspath_bin=`expr "$bin" : '\''^/'\''`
			if [ $abspath_bin != 1 ] ; then
				${LN} "$funcdir/$bin" "$launchdir/$name"
			else
				${LN} "$bin" "$launchdir/$name"
			fi
		fi
	done
#END link_loop_func

echo ""
echo ""
echo "Installation of programs and/or scripts successful."
echo ""

if [ $DOFONTLINKS -eq 1 ] ; then
	while : ; do
		CREATED=0
		DOFONTLINKS=0
		NCNT=1
		newfonthome=""
		FLOK=1
		fontsize=$PERPKGFONTSIZE
		for fonth in $fonthome ; do
			# WARNING: This prompt does not account for $NCNT packages.  It will appear to ask the same question over and over.
			echo ""
			echo "Enter the full path of the directory in which you want"
			echo "applications to look for fonts, or press $RETURNKEYNAME to accept"
			echo "the default directory.  The directory will be created if it does"
			echo "not exist."
			echo $EB"[Press $RETURNKEYNAME for $fonth]: "$EE
			read launchdir
			if [ "$launchdir" = "" ] 
			then
				launchdir="$fonth"
			fi
			if [ ! -d "$launchdir"  ] 
			then
				if $MKDIR $launchdir
				then error=0
				else error=1
				fi
				if [ $error != 0  ]
				then
					echo "Cannot create directory $launchdir"
					echo "You must choose different options or change permissions"
					echo "and then rerun this script."
					exit 1
				fi
				chmod u+w "$launchdir"
				chmod a+rx "$launchdir"
				CREATED=1
			fi
			if [ ! -w $launchdir ]
			then
				echo ""
				echo ""
				echo "You do not have permission to write to $launchdir."
				echo "You must choose different options or change permissions"
				echo "and then rerun this script."
				exit 1
			fi
			# Get last line of df statement.
			# Prepend X because if the mount point is too long,
			# the df command will result in two lines, with the
			# second line having blanks for the first field.
			lastdfline="X"`$DFCMD $launchdir | sed -n '\''$p'\''`
	
			# Determine if there is enough disk space for this install.
			case $KBYTES_AVAIL_FIELD in
				1)
					disk_kbytes=`echo $lastdfline | awk '\''{ print $1 }'\''`
					;;
				2)
					disk_kbytes=`echo $lastdfline | awk '\''{ print $2 }'\''`
					;;
				3)
					disk_kbytes=`echo $lastdfline | awk '\''{ print $3 }'\''`
					;;
				4)
					disk_kbytes=`echo $lastdfline | awk '\''{ print $4 }'\''`
					;;
				5)
					disk_kbytes=`echo $lastdfline | awk '\''{ print $5 }'\''`
					;;
				*)
					echo ""
					echo "Internal error. Unable to determine disk space."
					eval ${ABORTCMD}
					;;
			esac
			font_kbytes=`expr "$fontsize" : '\''[ ]*\([^ ]*\)'\''`
			fontsize=`expr "$fontsize" : '\''[ ]*[^ ]*\(.*\)'\''`
			if [ $font_kbytes -ge $disk_kbytes ] ; then
				echo ""
				echo ""
				echo "There is not enough disk space for the fonts."
				echo "The installation you requested requires $font_kbytes kilobytes of disk space"
				echo "and you currently have only $disk_kbytes kilobytes of available disk space"
				echo "in directory $launchdir."
				echo ""
				echo "Choose a different location to install the fonts."
				echo ""
				echo ""
				echo "Press $RETURNKEYNAME to continue"
				read A
				FLOK=0
				break
			fi
			newfonthome="$newfonthome $launchdir"
		done
		if [ $FLOK -eq 1 ] ; then
			break
		fi
	done # while
	makelinks_loop=0
	while :
	do
		makelinks_loop=`expr $makelinks_loop + 1`
		if [ $makelinks_loop -ge $LOOP_LIMIT ]
		then
			echo ""
			echo "LOOP_LIMIT exceeded."
			exit 1
		fi
		echo ""
		echo ""
		echo "This script will issue the following commands to install the"
		echo "fonts:"
		echo ""
		tfonthome=$newfonthome
		tuprfiles=$uprfiles
		for fonth in $newfonthome ; do
			echo "${DIRCP} $installdir/$fontpattern $fonth"
			#echo "${DIRRM} $installdir/$fontpattern"
			uprf=`expr "$tuprfiles" : '\''[ ]*\([^ ]*\)[ ]*'\''`
			tuprfiles=`expr "$tuprfiles" : '\''[ ]*[^ ]*\(.*\)'\''`
			if [ ! -z "$uprf" ] ; then
				name=`expr //$uprf : '\''.*/\(.*\)'\''`
				if [ -z "$name" ] ; then
					name="$uprf"
				fi
				abspath_bin=`expr "$uprf" : '\''^/'\''`
				udir=`expr "$fonth" : '\''\(.*\)/'\''`
				if [ $abspath_bin != 1 ] ; then
					dir=`expr "$fontpattern" : '\''\(.*\)/'\''`
					if [ -z "$dir" ] ; then
						echo ${CP} "$installdir/$uprf" "$udir/$name"
					else
						echo ${CP} "$installdir/$dir/$uprf" "$udir/$name"
					fi
				else
					echo ${CP} "$uprf" "$udir/$name"
				fi
			fi
			# X font info files
			fdir=`expr "$fontpattern" : '\''\(.*\)/'\''`
			if [ -f $installdir/$fdir/fonts.dir ] ; then
				echo ${CP} $installdir/$fdir/fonts.dir $fonth
			fi
			if [ -f $installdir/$fdir/fonts.alias ] ; then
				echo ${CP} $installdir/$fdir/fonts.alias $fonth
			fi
		done
		for fonth in $newfonthome ; do
			if [ -d $fonth ] ; then
			    if [ $CREATED -ne 1 ] ; then
				while : ; do
					echo ""
					echo ""
					echo "*** Warning ***"
					echo "Some fonts are already installed in $fonth.  This script"
					echo "checks the name of each font to be installed against those already"
					echo "installed in $fonth.  You may choose to skip the"
					echo "installation of fonts whose names match, or you may replace matching"
					echo "fonts.  Fonts with no matching name will be installed regardless."   
					echo ""
					echo $EB"Do you want to replace fonts with matching names (YES/NO)? "$EE
					read A
					if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" -o "$A" = ""  ] ; then
						SKIPFONTS=0
						break
					elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
						SKIPFONTS=1
						break
					else
						echo ""
						echo "You must specify YES or NO.  Try again."
					fi
				done
			    fi
			fi
		done
		echo ""
		echo $EB"OK to proceed (YES/NO)? "$EE
		read A
		if [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" ] ; then
			DOFONTLINKS=1
			break
		elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
			DOFONTLINKS=0
			echo "Installation of fonts cancelled."
			break
		else
			echo ""
			echo "You must specify YES or NO.  Try again."
		fi
	done
	
	if [ $DOFONTLINKS -eq 1 ] ; then
		echo ""
		tuprfiles=$uprfiles
		fdir=`expr "$fontpattern" : '\''\(.*\)/'\''`
		fpat=`expr "//$fontpattern" : '\''.*/\(.*\)'\''`
		ferrs=""
		fudirs=""
		for fonth in $newfonthome ; do
			# must list each subdirectory
			allfonts="`(cd $installdir/$fdir ; echo $fpat)`"
			for font in $allfonts ; do
				if [ -d "$fonth/$font" ] ; then
					if [ $SKIPFONTS -eq 1 ] ; then
						echo "Skipping $font"
						continue
					else
						if ${DIRRM} $fonth/$font ; then
							echo "Replacing $font"
						else
							echo "Could not replace $font"
							ferrs="$ferrs $font"
							continue
						fi
					fi
				fi
				if ${DIRCP} $installdir/$fdir/$font $fonth ; then
					# ${DIRRM} $installdir/$fdir/$font
					:
				else
					ferrs="$ferrs $font"
				fi
			done
			# X font info files
			for fxinfo in fonts.dir fonts.alias ; do
				if [ -f $installdir/$fdir/$fxinfo ] ; then
					if [ -f $fonth/$fxinfo ] ; then
						echo "    *** Warning ***"
						echo "    Cannot copy new $fxinfo to destination directory."
						echo "    $fonth/$fxinfo already exists.  The new file will"
						echo "    be left in $installdir/$fdir/$fxinfo."
						echo "    You will have to merge the files manually."
					else
						${CP} $installdir/$fdir/$fxinfo $fonth
					fi
				fi
			done
			# UPR Files
			uprf=`expr "$tuprfiles" : '\''[ ]*\([^ ]*\)[ ]*'\''`
			tuprfiles=`expr "$tuprfiles" : '\''[ ]*[^ ]*\(.*\)'\''`
			udir=`expr "$fonth" : '\''\(.*\)/'\''`
			if [ -z "$udir" ] ; then
				udir="$fonth"
			fi
			fudirs="$fudirs $udir"
			if [ ! -z "$uprf" ] ; then
				name=`expr //$uprf : '\''.*/\(.*\)'\''`
				if [ -z "$name" ] ; then
					name="$uprf"
				fi
				if [ -f "$udir/$name" -o -h "$udir/$name" ] ; then
					nf=1
					nfxxx=`echo $nf | awk '\''{printf "%03d", $1 }'\''`
					newname="`echo $name | sed -e s/.upr/_${nfxxx}.upr/`"
					while [ -f "$udir/$newname" -o -h "$udir/$newname" ] ; do
						newname="`echo $newname | sed -e s/_${nfxxx}.upr/.upr/`"
						nf=`expr $nf + 1`
						nfxxx=`echo $nf | awk '\''{printf "%03d", $1 }'\''`
						newname="`echo $newname | sed -e s/.upr/_${nfxxx}.upr/`"
					done
					echo "$udir/$name already exists."
					echo "The new resource file will be added to the directory with"
					echo "the new name $newname."
					name="$newname"
				fi
				abspath_bin=`expr "$uprf" : '\''^/'\''`
				if [ $abspath_bin != 1 ] ; then
					${CP} "$installdir/$uprf" "$udir/$name"
				else
					${CP} "$uprf" "$udir/$name"
				fi
			fi
		done
		# Concatanate final psresourcepath
		resdir=""
		for udir in $fudirs ; do
			resdir="$resdir $udir"
		done
		if [ ! -z "$HOME" ] ; then
			PSRES_PATH="`echo $PSRES_PATH | $SED -e s%$HOME/psres%'\''$HOME/psres'\''%`"
		fi

		psres="`echo $PSRES_PATH | tr : '\'' '\''`"
		for udir in $resdir ; do
			needit=1
			for oldudir in $psres ; do
				if [ "$udir" = "$oldudir" -o "$udir" = "$HOME/psres" ] ; then
					needit=0
					break
				fi
			done
			if [ $needit -eq 1 ] ; then
				PSRES_PATH="$udir:$PSRES_PATH"
			fi
		done
		# Determine parent dir for psres_file and make, if necessary.
		abspath=`expr $USER_INFO_FILE : '\''^/'\''`
		if [ $abspath = 1 ] ; then
			user_file="$USER_INFO_FILE"
		else
			user_file="$installdir/$USER_INFO_FILE"
		fi
		# Determine parent dir for psres_file and make, if necessary.
		dir=`expr "$user_file" : '\''\(.*\)/'\''`
		if [ ! -d "$dir" ] ; then
			$MKDIR $dir
			chmod u+w $dir
			chmod a+rx $dir
		fi
		$RM -f "$user_file"
		$CAT << INHERE > "$user_file"
# USER INFORMATION FILE FOR ADOBE SOFTWARE
#
# Adobe software has been installed at your site.  To use it
# you must add the following configuration information to your
# environment (typically .login or .cshrc file).
#
# PostScript Resources
# Add the following directories to your PSRESOURCEPATH, and make
# sure that your PSRESOURCEPATH definition ends with "::"
#    $PSRES_PATH
#
# For example, try the following if you use csh:
setenv PSRESOURCEPATH $PSRES_PATH::
#
# Some applications, such as Adobe Illustrator 5.5, provide
# a file called SITE_PSRESOURCEPATH, where the directories
# listed above can be included for all users of the application,
# so that individual modification of PSRESOURCEPATH is not
# required.  All that is required is the use of "::", or
# for PSRESOURCEPATH to be left undefined.  See your application
# user'\''s manual for details.
#
# Some applications have the directories:
#    \$HOME/psres:/usr/psres
# as their built-in locations.  These are the standard locations
# recommended by Adobe.  If your application supports the standard
# locations, no modification or definition of PSRESOURCEPATH is
# required.
#
INHERE
		echo ""
		name=`expr //$user_file : '\''.*/\(.*\)'\''`
		echo "********************* IMPORTANT *********************"
		echo '\''A customized file "'\''$name'\''", which describes environment'\''
		echo "settings that are essential for using the fonts you have"
		echo "just installed, has been stored in"
		echo "$dir.  Please distribute this"
		echo "file to any users of these fonts."
		echo ""
		if [ ! -z "$ferrs" ] ; then
			echo ""
			echo "***** NOTICE *****"
			echo "The following fonts have been left in the installation"
			echo "directory, because they did not install properly:"
			for fff in $ferrs ; do
				echo "  $fff"
			done
			echo ""
		else
			echo ""
			echo ""
			echo "Installation of fonts successful."
			echo ""
		fi
	fi 
fi

echo ""
echo ""
echo "*** Installation complete ***"
echo ""

' >> "$scriptfile"
			chmod 555 "$scriptfile"
		fi
	fi

	# Skip the rest of the processing for package_num = 0
	if [ "$package_num" = 0 ] ; then
		continue
	fi

	if [ ! -d ${fulldir} ] ; then
		echo ""
		echo $EB"Your "$EE
		if [ $USECD = 1 ] ; then
			echo $EB"CD-ROM "$EE
		else
			echo $EB"tape "$EE
		fi
		if [ "$RHOST" = "" ] ; then
		   echo "could not be read from $DEVPATH."
		else
		   echo "could not be read from $DEVPATH on $RHOST."
		fi
		eval "${RM} ${FILELIST}"
		eval ${ABORTCMD}
	fi

	# Force proper permissions.
	# Comment out for now. Assume permissions were set properly
	# when application created the tree for each package.
	#find $fulldir -type f -exec chmod a+r,a-w {} \;
	#find $fulldir -type d -exec chmod 755 {} \;
	#chown -Rf root.staff $fulldir

	# Establish automatic symbolic links if so desired.
	if [ $DOSYMLINKS = 1 ] ; then
		binlinks=`eval echo '$PKG_'$package_num'_BINLINKS'`
		ntokens=`echo $binlinks | wc -w`
		if [ $ntokens -gt 0 ] ; then
			for bin in $binlinks ; do
				# Next line is equiv to csh: set name=$bin:t
				name=`expr //$bin : '.*/\(.*\)'`
				${RM} -f $AUTOSYMLINKDIR/$name
				${LN} $fulldir/$bin $AUTOSYMLINKDIR/$name
			done
		fi
	fi

	# Automatically move fonts if so desired.
	if [ $DOFONTLINKS = 1 ] ; then
		fonthome=$NEWFONTHOME
		tuprfiles=$uprfiles
		fdir=`expr "$FONTPATTERN" : '\(.*\)/'`
		fpat=`expr "//$FONTPATTERN" : '.*/\(.*\)'`
		ferrs=""
		FONTUDIRS=""
		for fonth in $fonthome ; do
			# must list each subdirectory
			allfonts="`(cd $fulldir/$fdir ; echo $fpat)`"
			for font in $allfonts ; do
				if [ -d "$fonth/$font" ] ; then
					if [ $SKIPFONTS -eq 1 ] ; then
						echo "Skipping $font"
						continue
					else
						if ${DIRRM} $fonth/$font ; then
							echo "Replacing $font"
						else
							echo "Could not replace $font"
							ferrs="$ferrs $font"
							continue
						fi
					fi
				fi
				if ${DIRCP} $fulldir/$fdir/$font $fonth ; then
					${DIRRM} $fulldir/$fdir/$font
					:
				else
					ferrs="$ferrs $font"
				fi
			done
			# X font info files
			for fxinfo in fonts.dir fonts.alias ; do
				if [ -f $fulldir/$fdir/$fxinfo ] ; then
					if [ -f $fonth/$fxinfo ] ; then
						echo "    *** Warning ***"
						echo "    Cannot copy new $fxinfo to destination directory."
						echo "    $fonth/$fxinfo already exists.  The new file will"
						echo "    be left in $fulldir/$fdir/$fxinfo."
						echo "    You will have to merge the files manually."
					else
						${CP} $fulldir/$fdir/$fxinfo $fonth
					fi
				fi
			done
			# UPR files
			uprf=`expr "$tuprfiles" : '[ ]*\([^ ]*\)[ ]*'`
			tuprfiles=`expr "$tuprfiles" : '[ ]*[^ ]*\(.*\)'`
			udir=`expr "$fonth" : '\(.*\)/'`
			if [ -z "$udir" ] ; then
				udir="$fonth"
			fi
			FONTUDIRS="$FONTUDIRS $udir"
			if [ ! -z "$uprf" ] ; then
				name=`expr //$uprf : '.*/\(.*\)'`
				if [ -z "$name" ] ; then
					name="$uprf"
				fi
				if [ -f "$udir/$name" -o -h "$udir/$name" ] ; then
					nf=1
					nfxxx=`echo $nf | awk '{printf "%03d", $1 }'`
					newname="`echo $name | sed -e s/.upr/_${nfxxx}.upr/`"
					while [ -f "$udir/$newname" -o -h "$udir/$newname" ] ; do
						newname="`echo $newname | sed -e s/_${nfxxx}.upr/.upr/`"
						nf=`expr $nf + 1`
						nfxxx=`echo $nf | awk '{printf "%03d", $1 }'`
						newname="`echo $newname | sed -e s/.upr/_${nfxxx}.upr/`"
					done
					echo "$udir/$name already exists."
					echo "The new resource file will be added to the directory with"
					echo "the new name $newname."
					name="$newname"
				fi
				abspath_bin=`expr "$uprf" : '^/'`
				if [ $abspath_bin != 1 ] ; then
					${CP} "$fulldir/$uprf" "$udir/$name"
				else
					${CP} "$uprf" "$udir/$name"
				fi
			fi
		done
		# Concatanate final psresourcepath
		resdir=""
		for udir in $FONTUDIRS ; do
			resdir="$resdir $udir"
		done
		if [ ! -z "$HOME" ] ; then
			PSRES_PATH="`echo $PSRES_PATH | $SED -e s%$HOME/psres%'$HOME/psres'%`"
		fi
		psres="`echo $PSRES_PATH | tr : ' '`"
		for udir in $resdir ; do
			needit=1
			for oldudir in $psres ; do
				if [ "$udir" = "$oldudir" -o "$udir" = "$HOME/psres" ] ; then
					needit=0
					break
				fi
			done
			if [ $needit -eq 1 ] ; then
				PSRES_PATH="$udir:$PSRES_PATH"
			fi
		done
		# Determine parent dir for psres_file and make, if necessary.
		abspath=`expr $USER_INFO_FILE : '^/'`
		if [ $abspath = 1 ] ; then
			user_file="$USER_INFO_FILE"
		else
			user_file="$fulldir/$USER_INFO_FILE"
		fi
		# Determine parent dir for psres_file and make, if necessary.
		dir=`expr "$user_file" : '\(.*\)/'`
		if [ ! -d "$dir" ] ; then
			$MKDIR $dir
			chmod u+w $dir
			chmod a+rx $dir
		fi
		$RM -f "$user_file"
		$CAT << INHERE > "$user_file"
# USER INFORMATION FILE FOR ADOBE SOFTWARE
#
# Adobe software has been installed at your site.  To use it
# you must add the following configuration information to your
# environment (typically .login or .cshrc file).
#
# PostScript Resources
# Add the following directories to your PSRESOURCEPATH, and make
# sure that your PSRESOURCEPATH definition ends with "::"
#    $PSRES_PATH
#
# For example, try the following if you use csh:
setenv PSRESOURCEPATH $PSRES_PATH::
#
# Some applications, such as Adobe Illustrator 5.5, provide
# a file called SITE_PSRESOURCEPATH, where the directories
# listed above can be included for all users of the application,
# so that individual modification of PSRESOURCEPATH is not
# required.  All that is required is the use of "::", or
# for PSRESOURCEPATH to be left undefined.  See your application
# user's manual for details.
#
# Some applications have the directories:
#    \$HOME/psres:/usr/psres
# as their built-in locations.  These are the standard locations
# recommended by Adobe.  If your application supports the standard
# locations, no modification or definition of PSRESOURCEPATH is
# required.
#
INHERE
		echo ""
		name=`expr //$user_file : '.*/\(.*\)'`
		echo "********************* IMPORTANT *********************"
		echo 'A customized file "'$name'", which describes environment'
		echo "settings that are essential for using the fonts you have"
		echo "just installed, has been stored in"
		echo "$dir.  Please distribute this"
		echo "file to any users of these fonts."
		echo ""
		if [ ! -z "$ferrs" ] ; then
			echo ""
			echo "***** NOTICE *****"
			echo "The following fonts have been left in the installation"
			echo "directory, because they did not install properly:"
			for fff in $ferrs ; do
				echo "  $fff"
			done
			echo ""
		fi
	fi

	# Put addlicense and requestlicense scripts in correct place.
	lmfeature=`eval echo '$PKG_'$package_num'_LMFEATURE'`
	lmversion=`eval echo '$PKG_'$package_num'_LMVERSION'`
	lmquotes=`eval echo '$PKG_'$package_num'_LMQUOTES'`
	pkgdesc=`eval echo '$PKG_'$package_num'_PKGDESC'`
	pkgvers=`eval echo '$PKG_'$package_num'_PKGVERS'`
	ntokens=`echo $lmfeature | wc -w`
	if [ $ntokens -gt 0 ] ; then
		licensedir=$fulldir/installscripts
		if [ ! -d "$licensedir" ] ; then
			$MKDIR "$licensedir"
		fi
		num=1
		while [ $num -le $ntokens ] ; do
			lmfeat=`eval 'echo $lmfeature | awk '\''{ print $'$num' }'\'`
			lmvers=`eval 'echo $lmversion | awk '\''{ print $'$num' }'\'`
			lmquot=`eval 'echo $lmquotes | awk '\''{ print $'$num' }'\'`
			already_lmfeat=`echo $LMFEATURELIST | grep '^'"$lmfeat"'$'`
			# Skip this if this feature has already been processed.
			if [ "$already_lmfeat" != "" ] ; then
				break
			fi
			LMFEATURELIST=$LMFEATURELIST$lmfeat'
'

			# Copy addlicense script to ./installscripts and
			# automatically make changes in place.
			addlicensefname="$licensedir/$lmfeat"'.addlicense'
			if [ -f "$addlicensefname" ] ; then
				licensefname="$SECURITYFILE"
				$CAT "$addlicensefname" \
				| sed 's%^LM_LICENSE_FILE=""$%LM_LICENSE_FILE="'$licensefname'"%' \
				| sed 's%^LM_REF_FILE=""$%LM_REF_FILE="'$LM_FILE'"%' \
				| sed 's%^LM_DAEMON_DIR=""$%LM_DAEMON_DIR="'$DAEMONDIR'"%' \
				| sed 's%^LM_FEATURE=""$%LM_FEATURE="'$lmfeat'"%' \
				| sed 's%^LM_VERSION=""$%LM_VERSION="'$lmvers'"%' \
				| sed 's%^LM_QUOTES=""$%LM_QUOTES="'$lmquot'"%' \
				| sed 's%^PRODUCT_NAME=""$%PRODUCT_NAME="'"$pkgdesc"'"%' \
				| sed 's%^PRODUCT_VERSION=""$%PRODUCT_VERSION="'"$pkgvers"'"%' \
				> "$addlicensefname".temp
				${MV} "$addlicensefname".temp "$addlicensefname"
				chmod 555 $addlicensefname
			fi

			# Copy requestlicense script to ./installscripts and
			# automatically make changes in place.
			requestlicensefname="$licensedir/$lmfeat"'.requestlicense'
			if [ -f "$requestlicensefname" ] ; then
				licensefname="$SECURITYFILE"
				$CAT "$requestlicensefname" \
				| sed 's%^LM_LICENSE_FILE=""$%LM_LICENSE_FILE="'$licensefname'"%' \
				| sed 's%^LM_REF_FILE=""$%LM_REF_FILE="'$LM_FILE'"%' \
				| sed 's%^LM_DAEMON_DIR=""$%LM_DAEMON_DIR="'$DAEMONDIR'"%' \
				| sed 's%^LM_FEATURE=""$%LM_FEATURE="'$lmfeat'"%' \
				| sed 's%^LM_VERSION=""$%LM_VERSION="'$lmvers'"%' \
				| sed 's%^LM_QUOTES=""$%LM_QUOTES="'$lmquot'"%' \
				| sed 's%^PRODUCT_NAME=""$%PRODUCT_NAME="'"$pkgdesc"'"%' \
				| sed 's%^PRODUCT_VERSION=""$%PRODUCT_VERSION="'"$pkgvers"'"%' \
				> "$requestlicensefname".temp
				${MV} "$requestlicensefname".temp "$requestlicensefname"
				chmod 555 $requestlicensefname
			fi
			num=`expr $num + 1`
		done
	fi

	# Write out PSRES_PATH to PSRES_FILE, if necessary.
	psres_writefile=`eval echo '$PKG_'$package_num'_PSRES_WRITEFILE'`
	if [ "$psres_writefile" = "" ] ; then
		psres_writefile="$PSRES_WRITEFILE"
	fi
	if [ "$psres_writefile" = "y" ] ; then
		abspath=`expr $PSRES_FILE : '^/'`
		if [ $abspath = 1 ] ; then
			psres_file="$PSRES_FILE"
		else
			psres_file=${fulldir}'/'"$PSRES_FILE"
		fi
		# Determine parent dir for psres_file and make, if necessary.
		dir=`expr "$psres_file" : '\(.*\)/'`
		if [ ! -d "$dir" ] ; then
			$MKDIR $dir
		fi
		echo '#
# This file contains the default path which the application should use for
# finding its PostScript resources, such as fonts. The format is
# a single line beginning in column 1 of the form SITE_PSRESOURCEPATH=xxx,
# where xxx is a list of directories separated by colons.
# The application might add its own set of directories to this default
# path - consult the application launch script if you have questions.
# Users can override the default path by setting environment variable
# PSRESOURCEPATH to the list of directories to use for PostScript resources.
# If the user sets PSRESOURCEPATH, he is very much encouraged to include a 
# double colon (::) in the path (e.g., /usr/lib/dps/fonts::) so that the 
# application will still find its own default PostScript resources.

SITE_PSRESOURCEPATH='"$PSRES_PATH" > "$psres_file"
	fi

	# Write out LM_FILE with proper value for LM_LICENSE_FILE, if necessary.
	lm_writefile=`eval echo '$PKG_'$package_num'_LM_WRITEFILE'`
	if [ "$lm_writefile" = "" ] ; then
		lm_writefile="$LM_WRITEFILE"
	fi
	if [ "$lm_writefile" = "y" ] ; then
		abspath=`expr $LM_FILE : '^/'`
		if [ $abspath = 1 ] ; then
			lm_file="$LM_FILE"
		else
			lm_file=${fulldir}'/'"$LM_FILE"
		fi
		# Determine parent dir for lm_file and make, if necessary.
		dir=`expr "$lm_file" : '\(.*\)/'`
		if [ ! -d "$dir" ] ; then
			$MKDIR $dir
		fi
		echo '#
# This file contains the path which the application should use for
# finding its license data file. The format is a single line beginning
# in column 1 of the form LM_LICENSE_FILE=xxx, where xxx is usually a
# single file name but can be a list of files separated by colons.

LM_LICENSE_FILE='"$SECURITYFILE" > "$lm_file"
	fi

	# Copy files such as README from CDROM to installation tree, if so requested.
	cdrom_fromfiles=`eval echo '$PKG_'$package_num'_CDROM_FROMFILES'`
	if [ "$cdrom_fromfiles" = "" ] ; then
		# Backwards compatibility. Also accept CDROM_FROMFILE
		cdrom_fromfiles=`eval echo '$PKG_'$package_num'_CDROM_FROMFILE'`
	fi
	cdrom_tofiles=`eval echo '$PKG_'$package_num'_CDROM_TOFILES'`
	if [ "$cdrom_tofiles" = "" ] ; then
		# Backwards compatibility. Also accept CDROM_TOFILE
		cdrom_tofiles=`eval echo '$PKG_'$package_num'_CDROM_TOFILE'`
	fi
	ntokens_from=`echo $cdrom_fromfiles | wc -w`
	ntokens_to=`echo $cdrom_tofiles | wc -w`
	if [ $ntokens_from -eq $ntokens_to -a $ntokens_from -gt 0 ] ; then
		i=1
		for fromfile in $cdrom_fromfiles ; do
			eval fromfile_$i=$fromfile
			i=`expr $i + 1`
		done
		i=1
		for tofile in $cdrom_tofiles ; do
			eval tofile_$i=$tofile
			i=`expr $i + 1`
		done
		i=1
		while [ $i -le $ntokens_from ] ; do
			eval fromfile=\$fromfile_$i
			eval tofile=\$tofile_$i
			if [ "$fromfile" != "" -a -f "$CDDIR/$fromfile" ] ; then
				$RM "$fulldir/$tofile"
				$CP -p "$CDDIR/$fromfile" "$fulldir/$tofile"
			fi
			i=`expr $i + 1`
		done
	fi

	# Run the post-installation scripts, if present
	script=`eval echo '$PKG_'$package_num'_SCRIPT'`
	ntokens=`echo $script | wc -w`
	if [ $ntokens -gt 0 ] ; then
		script=$fulldir"/"$script
		if [ ! -f "$script" ] ; then
			echo ""
			echo "Install script error:"
			echo "Cannot find post-install script $script."
			eval "${RM} ${FILELIST}"
			eval ${ABORTCMD}
		fi
		if [ ! -x "$script" ] ; then
			echo ""
			echo "Install script error:"
			echo "Cannot execute post-install script $script."
			eval "${RM} ${FILELIST}"
			eval ${ABORTCMD}
		fi
		if $script $fulldir $SECURITYFILE ; then error=0; else error=1; fi
		if [ $error != 0  ] ; then
			echo "Post installation script returned an unexpected error code!"
			eval "${RM} ${FILELIST}"
			eval ${ABORTCMD}
		fi
	fi

	# Check for Motif keysyms
	xkeysymdb=`eval echo '$PKG_'$package_num'_XKEYSYMDB'`
	if [ "$xkeysymdb" = 1 ] ; then
		# Write out XKeysymDB file.
		if [ ! -d ${fulldir}/${XKEYSYMDBDIR} ] ; then
			$MKDIR ${fulldir}/${XKEYSYMDBDIR}
		fi
		fixfile=${fulldir}/${XKEYSYMDBDIR}/${XKEYSYMDBFILE}
		if [ -r ${fixfile} -a ! -w ${fixfile}  ] ; then
			echo ""
			echo "${fixfile} already exists and this script cannot overwrite."
		else
			${RM} ${fixfile}
			echo '!' > ${fixfile}
			echo '!		OSF Keysyms' >> ${fixfile}
			echo '!' >> ${fixfile}
			echo 'osfBackSpace			:1004FF08' >> ${fixfile}
			echo 'osfInsert			:1004FF63' >> ${fixfile}
			echo 'osfDelete			:1004FFFF' >> ${fixfile}
			echo 'osfCopy				:1004FF02' >> ${fixfile}
			echo 'osfCut				:1004FF03' >> ${fixfile}
			echo 'osfPaste			:1004FF04' >> ${fixfile}
			echo '' >> ${fixfile}
			echo 'osfAddMode			:1004FF31' >> ${fixfile}
			echo 'osfPrimaryPaste			:1004FF32' >> ${fixfile}
			echo 'osfQuickPaste			:1004FF33' >> ${fixfile}
			echo '' >> ${fixfile}
			echo 'osfPageUp			:1004FF41' >> ${fixfile}
			echo 'osfPageDown			:1004FF42' >> ${fixfile}
			echo '' >> ${fixfile}
			echo 'osfEndLine			:1004FF57' >> ${fixfile}
			echo 'osfBeginLine			:1004FF58' >> ${fixfile}
			echo '' >> ${fixfile}
			echo 'osfActivate			:1004FF44' >> ${fixfile}
			echo '' >> ${fixfile}
			echo 'osfMenuBar			:1004FF45' >> ${fixfile}
			echo '' >> ${fixfile}
			echo 'osfClear			:1004FF0B' >> ${fixfile}
			echo 'osfCancel			:1004FF69' >> ${fixfile}
			echo 'osfHelp				:1004FF6A' >> ${fixfile}
			echo 'osfMenu				:1004FF67' >> ${fixfile}
			echo 'osfSelect			:1004FF60' >> ${fixfile}
			echo 'osfUndo				:1004FF65' >> ${fixfile}
			echo '' >> ${fixfile}
			echo 'osfLeft				:1004FF51' >> ${fixfile}
			echo 'osfUp				:1004FF52' >> ${fixfile}
			echo 'osfRight			:1004FF53' >> ${fixfile}
			echo 'osfDown				:1004FF54' >> ${fixfile}
		fi

		if [ "$ALREADY_XKEYSYMDB" != 1 ] ; then
			# check if XKeysymDB file contains osf bindings. If it doesn't then
			# append them to /usr/openwin/lib/XKeysymDB file. On many systems
			# XKeysymDB file contains keysym like osfXK_. These are wrong so
			# just ignore them

			if grepout=`grep -v '^osfXK' "$KEYSYMDBFILE" | grep '^osf'` ; then status=0; else status=1; fi
			if [ $status != 0 ] ; then
				echo ""
				echo "It seems that your $KEYSYMDBFILE does not contain"
				echo "OSF keysyms."
				# The next line is equiv to csh: set dirpath=$KEYSYMDBFILE:h
				dirpath=`expr $KEYSYMDBFILE : '\(.*\)/' \| $KEYSYMDBFILE`
				if [ ! -w $KEYSYMDBFILE -o ! -w $dirpath  ] ; then
					echo "This script does not have permission to automatically alter $KEYSYMDBFILE."
					echo "In case you see messages complaining about unknown OSF keysyms"
					echo "at program startup, then append file ${fixfile}"
					echo "to the end of $KEYSYMDBFILE."
				else
					echo "Appending additional keysyms to $KEYSYMDBFILE."
					echo "Old $KEYSYMDBFILE file will be saved in ${KEYSYMDBFILE}.org"
					$RM ${KEYSYMDBFILE}.org
					$MV $KEYSYMDBFILE ${KEYSYMDBFILE}.org
					$CAT ${KEYSYMDBFILE}.org ${fixfile} > $KEYSYMDBFILE
				fi
			else
				echo ""
				echo "It is good that you have OSF keysyms in $KEYSYMDBFILE."
				echo "In case you see messages complaining about unknown OSF keysyms"
				echo "at program startup, then append ${fixfile}"
				echo "to the end of $KEYSYMDBFILE"
			fi
			ALREADY_XKEYSYMDB=1
		fi
	fi
done

echo ""
echo ""
lnks=`expr $ANYSYMLINKS + $ANYFONTLINKS`
if [ "$AUTOSYMLINK" = "makescript" -a $lnks -ge 1 ] ; then
	echo "*** To complete installation, follow the remaining instructions ***"
	echo "*** in the Getting Started Guide for this product. ***"
else
	echo "*** Installation complete ***"
fi
echo ""

# Notify user that license keys are needed.
if [ $ALLOK1 = 1 -a $ANYSECURED = 1 ] ; then
	echo ""
	echo "You will need license activation keys for the following applications:"
	echo ""
	LMFEATURELIST=""
	for package_num in ${PKGS_TO_INSTALL_TOTAL} ; do
		lmfeat=`eval echo '$PKG_'$package_num'_LMFEATURE'`
		ntokens=`echo $lmfeat | wc -w`
		if [ $ntokens -gt 0 ] ; then
			already_lmfeat=`echo $LMFEATURELIST | grep '^'"$lmfeat"'$'`
			# Skip this if this feature has already been processed.
			if [ "$already_lmfeat" != "" ] ; then
				break
			fi
			LMFEATURELIST=$LMFEATURELIST$lmfeat'
'
			echo "        "$lmfeat
		fi
	done
	echo ""
	echo "Refer to the Getting Started guide for information on how to"
	echo "obtain and install your license activation keys."
	echo ""
fi

${RM} $PKGLISTFILE
exit 0

