#ident	"@(#)pkg.terminf:terminf/INSTALL	1.11"
#
#	Save the mount point of the floppy & the package name.
#

INSPATH="/install/new"
INSINS="/install/install"
PKGNAME="`cat ${INSPATH}/usr/options/terminf.name`"
ORDER="`cat ${INSINS}/ORDER`"

#
# How much space is needed by this floppy?
#

USRneeds=`expr "\`du -s ${INSPATH}/usr\`" : "\([0-9]*\).*"`
ROOTneeds=`expr "\`du -s ${INSPATH}\`" : "\([0-9]*\).*"`
ROOTneeds=`expr ${ROOTneeds} - ${USRneeds}`

#
# How much space is available in the necessary filesystems?
#

USRspace=`expr "\`df /usr 2>/dev/null\`" : '.*: *\([0-9]*\)'`
ROOTspace=`expr "\`df / 2>/dev/null\`" : '.*: *\([0-9]*\)'`

#
# Now see if the package fits!
# Inform the user and exit immediately, if not.
#

if
	[ "$USRspace" -lt "$USRneeds" ]
then
	echo "**ERROR**   ${PKGNAME} cannot be installed --"
	echo "Not enough space on the hard disk."
	echo "There are $USRspace blocks available"
	echo "on the /usr file system --"
	echo "$USRneeds blocks are needed."
	exit
elif
	[ "$ROOTspace" -lt "$ROOTneeds" ]  
then
	echo "**ERROR**   ${PKGNAME} cannot be installed --"
	echo "Not enough space on the hard disk."
	echo "There are $ROOTspace blocks available"
	echo "on the / (root) file system --"
	echo "$ROOTneeds blocks are needed."
	exit
fi

if [ -s /usr/lib/libcurses.a ]
then
	if [ "${ORDER}" = "1" -o "${ORDER}" = "2" ]
	then
		echo "Installing the ${PKGNAME}."
		echo "Copyright (c) 1984 AT&T"
		echo "All Rights Reserved"
	fi
elif [ ! -s /usr/lib/libcurses.a -a "${ORDER}" = "1" ]
then
		echo "Installing the ${PKGNAME}."
		echo "Copyright (c) 1984 AT&T"
		echo "All Rights Reserved"
fi

if [ "`cat /install/install/ORDER`" = "1" ]
then
	cd ${INSPATH}
	echo "The following files are being installed:"
	find . -print | cpio -pduvm /
	ln /usr/lib/libcurses.a /usr/lib/libtermcap.a
	echo /usr/lib/libtermcap.a
	ln /usr/lib/libcurses.a /usr/lib/libtermlib.a
	echo /usr/lib/libtermlib.a
	echo
	echo
	echo "The installation of the 1st diskette is now complete."
	echo "When prompted, you may install /etc/termcap and"
	echo "selected terminfo entries from the 2nd diskette."
	echo
	echo
elif [ "`cat /install/install/ORDER`" = "2" ]
then
	#
	#	Export the INSINS variable for setup script on 2nd diskette.
	#
	export INSINS

	if [ ! -s /usr/lib/libcurses.a ]
	then
		echo "Please install the first diskette of this package."
		exit 1
	fi

	cd ${INSPATH}
	echo "The following files are being installed:"
	find . -print | cpio -pduvm /
	echo
	echo
	echo "Please install the terminfo entries you wish."

	echo "Selective installation of the ${PKGNAME} database."
	cd ${INSINS}
	${INSINS}/setup
	echo "The installation of ${PKGNAME} is now complete."
fi
