:
# $Id: dosinst.sh,v 1.4 2003/07/21 18:15:20 rwb Exp $ 
# SCCSID(@(#)dosinst.sh	1.107) Modified 11:24:15 10/16/01
#############################################################################
# Installation script for MS DOS
#############################################################################
#	Copyright (c) 1991-2000 TreLOS, Inc.
#############################################################################


# Get the VARMERGE and STATICMERGE settings.
. /etc/mrgssv.sh

# If INST_ROOT is set to some directory, then DOS will be installed
# there.  For this to work that directory must contain a VARMERGE
# directory with appropriate sub-directories.  This is a feature that
# is not to be used by end-users, so force to install in the real root.
INST_ROOT=
export INST_ROOT

VARM=${INST_ROOT}${VARMERGE}
DOS_ROOT=${VARM}/dosroot
DOSROOTDOS=${DOS_ROOT}/dos
DOSI_TMP=${DOS_ROOT}/dosi_tmp
DOSI_DIR=$VARMERGE/dosimenu
KOPT="+kmerge-internal-config:snap"

MERGE_FORCEOKTORUN=y
export MERGE_FORCEOKTORUN
MINIMAL_INSTALL=

if [ "$SYSTEMTYPE" = "linux" ]
then
	EOPT="-e"
else
	EOPT=
fi

Echo()
{
	echo $EOPT $*
}
TRC=Echo

HAVE_FUNC=no
EXIT_NOW()
{
	rm -f ${VARM}/doing_dosinst ${VARM}/auto_dosinst
	[ "$HAVE_FUNC" = "yes" ] && Func_Clean_Up
	rm -rf $DOSI_DIR $DOSI_TMP
	[ $DOSINSTALLTRACE -eq 2 ] && Trace_df end
	$TRC "EXIT_NOW $1" >> $TRACE
	if [ "x$GUI" = "xgui" ]
	then
		if [ $1 -ne 0 ]
		then
			Echo "DOS installation failed."
		fi
		Echo "Press return to continue..."
		read XXX
	fi
	exit $1
}

Exit_Clean()
{
	usrMsg ECHO EXITING "Exiting...\n"
	[ $DOSINSTALLTRACE -eq 2 ] && Trace_df before_clean
	if [ "x$CLEAN_UP_OK" = "xclean_up_ok" ]
	then
		cd ${DOS_ROOT}
		[ -n "$TMP_LOC" -a -d "$TMP_LOC" ] && rm -rf $TMP_LOC
		for i in command.com io.sys winboot.sys msdos.sys country.sys \
			ibmbio.com ibmdos.com
		do
			rm -f ${DOS_ROOT}/$i
		done
		rm -f ${VARM}/dosneedspace
		rm -f ${VARM}/jdos.dsk
		rm -rf ${VARM}/jdosdisk.dir
		# Remove everything from DOSROOTDOS.
		# (Removing the directory and then recreating it is
		# the easiest way to do that.)
		rm -rf     ${DOSROOTDOS}
		mkdir      ${DOSROOTDOS}
		chown  bin ${DOSROOTDOS}
		chgrp  bin ${DOSROOTDOS}
		chmod  775 ${DOSROOTDOS}
		# Delete the temporary directories.
		rm -rf ${DOSI_TMP}
		rm -rf ${DOSI_DIR}
	fi

	EXIT_NOW $1
}

interruptProc()
{
	usrMsg LOG INST_CANCEL "Installation cancelled by the user.\n"
	Exit_Clean 2
}

Retry_Abort()
{
	usrMsg STRING DOSINST_DW_P \
"What do you want to do now:\n\
      0: Abort the installation of DOS.\n\
      1: Retry.\n\
Type 0 or 1 and then press Enter: "
	RA_PROMPT="$USRMSG_STRING\c"
	while true
	do
    		Echo "$RA_PROMPT"
		read ANS XXX
		[ "x$ANS" = "x1" ] && break
		[ "x$ANS" = "x0" ] && Exit_Clean 2
		[ "x$ANS" = "x$ANS_Q" ] && Exit_Clean 2
		usrMsg ECHO DOSINST_DW_R "Please enter 0 or 1\n"
	done
}

Get_Disk1_Dir()
{
	while true
	do
		if [ "$HAVE_VDISKS" != "have_vdisks" ]
		then
			usrMsg ECHO CHECK_DISK  "Checking the disk."
		fi
		echo "dir" | $DOSDISK -s -r $1 > disk1.dir 2>>$TRACE
		if [ $? -eq 0 ]
		then
			break
		fi
		if [ "$HAVE_VDISKS" = "have_vdisks" ]
		then
			usrMsg ECHO VDISK_ERR \
			    "Error with virtual disk.  Cannot install DOS.\n"
			Exit_Clean 2
		fi
		Echo
		Echo 
		usrMsg ECHO BAD_DISK \
"      Had trouble reading the disk.\n\
      Check that the disk is inserted in the correct drive.\n"
		sleep 2
		Echo
		Retry_Abort
		Echo
    		Echo "$GFD_PROMPT"
		read ANS
		[ "x$ANS" = "x0" ] && Exit_Clean 2
		[ "x$ANS" = "x$ANS_Q" ] && Exit_Clean 2
	done
	if [ "$NOPROMPT" != "noprompt" ]
	then
		Echo
	fi

	# Must have command.com, io.sys (or winboot.sys) and msdos.sys.
	# (For DR-DOS ibmbio.com and ibmdos.com are used instead of
	# io.sys and msdos.sys)
	# Note: grep returns 0 when a match.
	COMMAND_FILE=
	IO_FILE=
	DOS_FILE=
	grep -i command.com disk1.dir >> $TRACE 2>&1
	[ $? -eq 0 ] && COMMAND_FILE=command.com
	grep -i io.sys      disk1.dir >> $TRACE 2>&1
	[ $? -eq 0 ] && IO_FILE=io.sys
	grep -i msdos.sys   disk1.dir >> $TRACE 2>&1
	[ $? -eq 0 ] && DOS_FILE=msdos.sys
	grep -i ibmbio.com      disk1.dir >> $TRACE 2>&1
	[ $? -eq 0 ] && IO_FILE=ibmbio.com
	grep -i ibmdos.com   disk1.dir >> $TRACE 2>&1
	[ $? -eq 0 ] && DOS_FILE=ibmdos.com

	# With DOS 7.x, the IO_FILE can be io.sys or winboot.sys
	# and the msdos.sys file is optional.
	grep -i winboot.sys disk1.dir >> $TRACE 2>&1
	[ $? -eq 0 ] && IO_FILE=winboot.sys
}

First_Disk_Sys_Inst()
{
	# The first disk is "$DISK1".  This may be a floppy device or
	# a virtual floppy file.
	# Install the following system files from the first disk:
	#	/command.com
	#	${DOSROOTDOS}/command.com
	#	${DOSROOTDOS}/io.sys or winboot.sys
	#	${DOSROOTDOS}/msdos.sys
	# (For DR-DOS ibmbio.com and ibmdos.com are used instead of
	# io.sys and msdos.sys)
	# Create the this bootable disk image from the first disk:
	#	${DOSROOTDOS}/boot.dsk
	#
	rm -rf fdm.$$
	mkdir  fdm.$$
	cd     fdm.$$

	# Create the boot.dsk file that is used when making images.
	BOOTDSK=${DOSROOTDOS}/boot.dsk
	touch $BOOTDSK
	COPYFROM=tmpfile1
	COPYTO=tmpfile2
	echo "saveboot $BOOTDSK" > $COPYFROM
	> $COPYTO
	# Note: IO_FILE, DOS_FILE, and COMMAND_FILE are set in
	#       the function "Get_Disk1_Dir".
	for i in $IO_FILE $DOS_FILE $COMMAND_FILE
	do
		echo "copyfrom $i" >> $COPYFROM
		echo "copyto $i $i" >> $COPYTO
	done

	cat $COPYFROM | $DOSDISK -s -e -r $DISK1 >>$TRACE 2>&1
	ls -lt >> $TRACE
	if [ -z "$COMMAND_FILE" -o ! -f $COMMAND_FILE ]
	then
		usrMsg ECHO MISSING_FILE \
			"Error: Failed to find $COMMAND_FILE\n" $COMMAND_FILE
		Exit_Clean 2
	fi
	if [ -z "$IO_FILE" -o ! -f $IO_FILE ]
	then
		usrMsg ECHO MISSING_FILE \
			"Error: Failed to find $IO_FILE\n" $IO_FILE
		Exit_Clean 2
	fi
	if [ -z "$DOS_FILE" ]
	then
		# With MSDOS 7, the msdos.sys file is optional,
		# so only log the fact that is is missing.
		$TRC "Warning, no msdos.sys file" >> $TRACE
	else
	    if [ ! -f $DOS_FILE ]
	    then
		usrMsg ECHO MISSING_FILE \
			"Error: Failed to find $DOS_FILE\n" $DOS_FILE
		Exit_Clean 2
	    fi
	fi
	if [ -z "$BOOTDSK" -o ! -f $BOOTDSK ]
	then
		usrMsg ECHO CANNOT_CREATE \
			"Error: Could not create $BOOTDSK" $BOOTDSK
		Exit_Clean 2
	fi
	cat $COPYTO | $DOSDISK -s -e $BOOTDSK >>$TRACE 2>&1

	$TRC "chmod,chgrp,chown $COMMAND_FILE $IO_FILE $DOS_FILE" >>$TRACE
	chmod 444 $COMMAND_FILE $IO_FILE $DOS_FILE $BOOTDSK >> $TRACE 2>&1
	chgrp bin $COMMAND_FILE $IO_FILE $DOS_FILE $BOOTDSK >> $TRACE 2>&1
	chown bin $COMMAND_FILE $IO_FILE $DOS_FILE $BOOTDSK >> $TRACE 2>&1
	mv $COMMAND_FILE $IO_FILE $DOS_FILE	${DOSROOTDOS}

	# Link command.com and the system files into DOS_ROOT.
	ln ${DOSROOTDOS}/$COMMAND_FILE ${DOS_ROOT}/$COMMAND_FILE >> $TRACE 2>&1
	ln ${DOSROOTDOS}/$IO_FILE      ${DOS_ROOT}/$IO_FILE      >> $TRACE 2>&1
	[ ! -z "$DOS_FILE" ] && \
	    ln ${DOSROOTDOS}/$DOS_FILE ${DOS_ROOT}/$DOS_FILE     >> $TRACE 2>&1

	cd ..
	rm -rf fdm.$$
}

First_Disk_Mkimg()
{
	# Assume that "First_Disk_Sys_Inst" has already installed the
	# minumum set of system files so that "mkimg" can make images.
	# Do this so later we can run DOS to use the "expand" command to
	# uncompress  the rest of the DOS files.
	#
	# Note: When installing into a special heirarchy, don't need
	# or want to to make images.

	if [ "z$INST_ROOT" != "z" ]
	then
		# Installing into a special hierarchy.
		# Don't make images; assuming already made.
		return
	fi

	$TRC "\tFirst_Disk_Mkimg" >> $TRACE

	rm -f ${VARM}/image/config.mki
	echo "DOSVER=\"$DOSVER\""     >  ${DOSROOTDOS}/version.dos
	echo "DOSBRAND=\"$DOSBRAND\"" >> ${DOSROOTDOS}/version.dos
	echo "DOSNUM=\"$DOSNUM\""     >> ${DOSROOTDOS}/version.dos
	echo "MKIFILE=\"$MKIFILE\""   >> ${DOSROOTDOS}/version.dos
	echo "LANGUAGE=\"$LANGUAGE\"" >> ${DOSROOTDOS}/version.dos
	echo "SPECIAL=\"$SPECIAL\""   >> ${DOSROOTDOS}/version.dos
	mkimg mono >> $TRACE
	rm -f ${VARM}/image/config.mki

	if [ ! -f ${VARM}/image/std/mono/mono.img ]
	then
		usrMsg ERROR DOSINST_MKIMG_MONO_FAILED \
"Cannot make mono DOS image files.\n\
     Aborting installation of DOS.\n"
		Exit_Clean 1
	fi

	return
}

Do_copies()
{
	$TRC "\tDo_copies."    >> $TRACE
	# Put a copy of "country.sys" in root of the J drive.

	rm -f ${DOS_ROOT}/country.sys
	cp country.sys ${DOS_ROOT} >> $TRACE 2>&1
	chmod 444 ${DOS_ROOT}/country.sys >>$TRACE 2>&1
	chgrp bin ${DOS_ROOT}/country.sys >>$TRACE 2>&1
	chown bin ${DOS_ROOT}/country.sys >>$TRACE 2>&1

	return 0
}

# Prompt for one of two answers - returns 1 for the first answer.
FIRST_ANSWER=1
SECOND_ANSWER=2
QUIT_ANSWER=0
Get_Answer()
{
	while	Echo "$3 \c"
	do	read ANS XXX
		[ "x$ANS" = "x$1" ] && return $FIRST_ANSWER
		[ "x$ANS" = "x$2" ] && return $SECOND_ANSWER
		[ "x$ANS" = "x0" ]  && return $QUIT_ANSWER
		[ "x$ANS" = "x$ANS_Q" ] && return $QUIT_ANSWER
		Echo "$4"
	done
}

Set_drive_dev()
{
	DRIVE_DEV=$1
	DISK1=$DRIVE_DEV
	DISK2=$DRIVE_DEV
	DISK3=$DRIVE_DEV
	DISK4=$DRIVE_DEV
	DISK5=$DRIVE_DEV
	DISK6=$DRIVE_DEV
	DISK7=$DRIVE_DEV
	DISK8=$DRIVE_DEV
	DISK9=$DRIVE_DEV
}

Drive_Name_Density()
{
	if [ -z "$FLOPDENSITY" ]
	then
		return;
	fi
	if [ "x$FLOPDENSITY" != "xlow" -a "x$FLOPDENSITY" != "xhigh" ]
	then
		# Just a guess.
		FLOPDENSITY=high
	fi
	FLD=$FLOPDENSITY
	if [ "X$1" = "Xreverse" ]
	then
		if [ "$FLOPDENSITY" = "high" ]
		then
			FLD=low
		else
			FLD=high
		fi
	fi

	if [ "$DISKTYPE" = "3.5" ]
	then
		if [ "$FLD" = "high" ]
		then
			# high density 3.5 disk (1.44M)
			FLOPNAMEEND=3ht
		else
			# low density 3.5 disk (720K)
			FLOPNAMEEND=3dt
		fi
	else
		if [ "$FLD" = "high" ]
		then
			# high density 5.25 disk (1.2M)
			FLOPNAMEEND=q15dt
		else
			# low density 5.25 disk (360K)
			FLOPNAMEEND=d9dt
		fi
	fi
	Set_drive_dev "${FLOPNAMEFRONT}${FLOPDEV}${FLOPNAMEEND}"
}


# -----------------------------------------------------------------------
#
# -----------------------------------------------------------------------
Which_Drive()
{
	usrMsg STRING DRIVEA_NAME "A"
	DRIVEA_NAME="$USRMSG_STRING"
	usrMsg STRING DRIVEB_NAME "B"
	DRIVEB_NAME="$USRMSG_STRING"

	#### See if a drive B is available
	if [ -x "$FLOPINFO" ]
	then
		$FLOPINFO b >> $TRACE
		RETVAL=$?
		$TRC "flopinfo ret $RETVAL" >> $TRACE
	else
		# Assume two drives because we cannot tell how many.
		RETVAL=1
	fi
	if [ $RETVAL = 0 ]
	then
		# No second drive.
		HAVE_BDRIVE=no_bdrive
	else
		# Have a second drive.
		HAVE_BDRIVE=have_bdrive
	fi

	if [ "$HAVE_DRIVE" = "yes" ]
	then
		if [ "$DRIVE_NAME" = "$DRIVEA_NAME" ]
		then
			FLOPDEV=0
		elif [ "$DRIVE_NAME" = "$DRIVEB_NAME" ]
		then
			FLOPDEV=1
		else
			Echo "Error: Unknown drive $DRIVE_NAME"
			Exit_Clean 1
		fi
	fi

	if [ "$HAVE_DRIVE" = "no" ]
	then
		DRIVE_NAME="$DRIVEA_NAME"
		FLOPDEV=0

		### If a second drive and the drive override has NOT been set,
		### then ask user which drive to use.
		if [ "$HAVE_BDRIVE" = "have_bdrive" ]
		then
			while true
			do
Echo
usrMsg ECHO DOSINST_FLOP_P "\
Which floppy drive are you installing from?\n\
\n\
      1: The first drive.  (drive '$DRIVEA_NAME')\n\
      2: The second drive. (drive '$DRIVEB_NAME')\n\
      0: Stop.  Abort installation of DOS.\n\
\n\
Type the item number and then press Enter: " "$DRIVEA_NAME" "$DRIVEB_NAME"
				read ANS XXX
				[ "x$ANS" = "x1" ] && break
				[ "x$ANS" = "x2" ] && break
				[ "x$ANS" = "x0" ] && Exit_Clean 2
				[ "x$ANS" = "x$ANS_Q" ] && Exit_Clean 2
			usrMsg ECHO DOSINST_012 "Please enter 0, 1, or 2\n"
			done
			if [ $ANS -eq 2 ]
			then
				DRIVE_NAME="$DRIVEB_NAME"
				FLOPDEV=1
			fi
		fi
	fi

	# The User can define DRIVE_0_DEV and DRIVE_1_DEV in the
	# environment, to provide the floppy device names (and thus to
	# bypass the automatic determination of the floppy device name).
	if [ $FLOPDEV -eq 0 -a -n "$DRIVE_0_DEV" ]
	then
		Set_drive_dev "$DRIVE_0_DEV"
	elif [ $FLOPDEV -eq 1 -a -n "$DRIVE_1_DEV" ]
	then
		Set_drive_dev "$DRIVE_1_DEV"
	else
		# No override.  Construct the unix device name for the floppy.
		if [ "$SYSTEMTYPE" = "sco" -o "$SYSTEMTYPE" = "sco32" ]
		then
			if [ "z$ASK_DENSITY" = "zask_density" ]
			then
				# Must determine density type.
				FLOPNAMEFRONT=/dev/dsk/f
				# Call this function which sets DRIVE_DEV.
				Drive_Name_Density normal
			else
				XXX=/dev/install
				[ $FLOPDEV -ne 0 ] && XXX=/dev/install${FLOPDEV}
				Set_drive_dev $XXX
			fi
		elif [ "$SYSTEMTYPE" = "linux" ]
		then
			# The LINUX floppy device "fd0" automatically senses
			# the density of the floppy in the drive.
			Set_drive_dev "/dev/fd${FLOPDEV}"
		elif [ "$SYSTEMTYPE" = "uw7" ]
		then
			# The UnixWare floppy device "f0t" automatically senses
			# the density of the floppy in the drive.
			Set_drive_dev "/dev/dsk/f${FLOPDEV}t"
		else
			Echo "Unknown systemtype $SYSTEMTYPE"
			exit 1
		fi
	fi

	if [ -n "$DRIVE_DEV" -a ! -c "$DRIVE_DEV" -a ! -b "$DRIVE_DEV" ]
	then
		# Invalid filename
		usrMsg ERROR BAD_FLOP_NAME \
		    "Invalid floppy drive device name '$DRIVE_DEV'\n" $DRIVE_DEV
		usrMsg ECHO CANNOT_CONTINUE "Cannot continue.\n"
		Exit_Clean 1
	fi

	# The above sets DRIVE_NAME, HAVE_BDRIVE, and DRIVE_DEV.  Log it.
	$TRC "DRIVE_NAME=$DRIVE_NAME" >> $TRACE
	$TRC "HAVE_BDRIVE=$HAVE_BDRIVE" >> $TRACE
	$TRC "DRIVE_DEV=$DRIVE_DEV" >> $TRACE

	Echo
	return
}

# -----------------------------------------------------------------------
#
# -----------------------------------------------------------------------
Get_Disk_Count()
{
	while	true
	do
		usrMsg ECHO DOSINST_NDISKS_Q \
			"Number of $1 diskettes in your set: " "$1"
		read DISKCOUNT XXX
		[ "x$DISKCOUNT" = "x1" ] && break
		[ "x$DISKCOUNT" = "x2" ] && break
		[ "x$DISKCOUNT" = "x3" ] && break
		[ "x$DISKCOUNT" = "x4" ] && break
		[ "x$DISKCOUNT" = "x5" ] && break
		[ "x$DISKCOUNT" = "x6" ] && break
		[ "x$DISKCOUNT" = "x7" ] && break
		[ "x$DISKCOUNT" = "x8" ] && break
		[ "x$DISKCOUNT" = "x9" ] && break
		[ "x$DISKCOUNT" = "x0" ] && Exit_Clean 2
		[ "x$DISKCOUNT" = "x$ANS_Q" ] && Exit_Clean 2
		usrMsg ECHO DOSINST_0_9 \
			"Please enter a number 0 through 9\n"
		usrMsg ECHO DOSINST_0_ABORT \
			"Entering 0 will abort the installation of DOS.\n"
	done
	return
}

# -----------------------------------------------------------------------
# "Get_Flop_Info" asks the user how many floppies, (and the size of the
#                 disks with the SCO version.)
#
#  Sets DISKTYPE, and DISKCOUNT.
#      (Note: DISKCOUNT is set calling Get_Disk_Count)
#      (Note: DISKTYPE is only set for non-svr4 versions)
#  Clears DRIVE_NAME and DRIVE_DEV.
#  Note: DOSVER must already be set.
#------------------------------------------------------------------------
Get_Flop_Info()
{
	DRIVE_DEV=""

	# The SVR4 floppy device f0t (and f1t) automatically
	# works for both 3.5 and 5.25 inch drives.
	# Same for Linux's /dev/fd0 device.
	# SCO's /dev/install (and /dev/install1) work the same way.
	# Older SCO versions might not have /dev/install, so check for it.

	ASK_DENSITY=donot_ask
	if [ "$SYSTEMTYPE" = "sco" ]
	then
		if [ ! -b /dev/install -o ! -b /dev/install1 ]
		then
			# The automatic floppy devices do not exist, so must
			# ask user about the size and density of the disk.
			ASK_DENSITY=ask_density
		fi
	fi
	if [ "$ASK_DENSITY" = "ask_density" ]
	then
		# If we are running as a backend for the GUI then we
		# should not have to prompt the user for any information.
		if [ "x$GUI" = "xgui" ]
		then
			Echo "Error: Can't determine floppy density."
			Exit_Clean 1
		fi
		while	true
		do
			Echo
			usrMsg ECHO DOSINST_SCO_DISKSIZE "\
Please enter the size of DOS disks you have.\n\
\n\
      1: 3.5\" low density disks.\n\
      2: 3.5\" high density disks.\n\
      3: 3.5\" unknown density disks.\n\
      4: 5.25\" low density disks.\n\
      5: 5.25\" high density disks.\n\
      6: 5.25\" unknown density disks.\n\
      0: None of the above.  Abort installation of DOS.\n\
\n\
Type the item number and then press Enter: "
			read ANS XXX
			[ "x$ANS" = "x1" ] && break
			[ "x$ANS" = "x2" ] && break
			[ "x$ANS" = "x3" ] && break
			[ "x$ANS" = "x4" ] && break
			[ "x$ANS" = "x5" ] && break
			[ "x$ANS" = "x6" ] && break
			[ "x$ANS" = "x0" ] && Exit_Clean 2
			[ "x$ANS" = "x$ANS_Q" ] && Exit_Clean 2
			usrMsg ECHO DOSINST_0123456 "Please enter 0, 1, 2, 3, 4, 5, or 6\n"
		done
		if [ $ANS -eq 1 ]
		then
			DISKTYPE=3.5
			FLOPDENSITY=low
		elif [ $ANS -eq 2 ]
		then
			DISKTYPE=3.5
			FLOPDENSITY=high
		elif [ $ANS -eq 3 ]
		then
			DISKTYPE=3.5
			FLOPDENSITY=unknown
		elif [ $ANS -eq 4 ]
		then
			DISKTYPE=5.25
			FLOPDENSITY=low
		elif [ $ANS -eq 5 ]
		then
			DISKTYPE=5.25
			FLOPDENSITY=high
		elif [ $ANS -eq 6 ]
		then
			DISKTYPE=5.25
			FLOPDENSITY=unknown
		fi
	fi
	if [ "$HAVE_DISKCOUNT" != "yes" ]
	then
		Get_Disk_Count "$DOSVER"
	fi
	return
}

Get_First_Disk()
{
	if [ "$HAVE_BDRIVE" = "no_bdrive" ]
	then
		# Single drive system
		usrMsg STRING INSERT_S \
"Insert DOS disk #1 in the drive and press ENTER. " 1
	else
		# Dual drive system
		usrMsg STRING INSERT_D \
"Insert DOS disk #1 in drive $DRIVE_NAME and press ENTER. " \
			1 "$DRIVE_NAME"
	fi
	GFD_PROMPT="$USRMSG_STRING\c"
	Drive_Name_Density reverse
	REV_DEV=$DRIVE_DEV
	Drive_Name_Density normal
	NRM_DEV=$DRIVE_DEV
	while true
	do
    		Echo "$GFD_PROMPT"
		read ANS
		[ "x$ANS" = "x0" ] && Exit_Clean 2
		[ "x$ANS" = "x$ANS_Q" ] && Exit_Clean 2
		if [ "$NRM_DEV" != "$REV_DEV" ]
		then
			# We guessed at the floppy density.  Now see
			# if we guessed right.
			dd if=$NRM_DEV of=/dev/null count=1 > /dev/null 2>&1
			if [ $? -ne 0 ]
			then
				# Read failed, so try other density.
				dd if=$REV_DEV of=/dev/null count=1 \
							> /dev/null 2>&1
				if [ $? -ne 0 ]
				then
					# Read failed.
					Echo
					Echo 
					usrMsg ECHO BAD_DISK \
"      Had trouble reading the disk.\n\
      Check that the disk is inserted in the correct drive.\n"
					sleep 2
					Echo
					Retry_Abort
					Echo
					continue
				fi
				# Read succeeded.  Use this device.
				Set_drive_dev $REV_DEV
			fi
		fi
		rm -f disk1.dir
		# Make sure it is the first disk.
		Get_Disk1_Dir $DRIVE_DEV
		# Note: IO_FILE, DOS_FILE, and COMMAND_FILE are set in
		#       the function "Get_Disk1_Dir".
		if [ -n "$COMMAND_FILE" -a -n "$IO_FILE" -a -n "$DOS_FILE" ]
		then
			break
		fi
		Echo 
		usrMsg ECHO WRONG_DISK_1 \
"      This disk does not appear to be the correct disk, or the correct\n\
      type of disk, or there was a problem reading the disk.\n\
      Please check that you have the correct disk in the proper drive.\n\
      (The first disk must a bootable disk.  Some DOS upgrades do not\n\
      have a bootable first disk.  In this case, follow the instructions\n\
      that came with the DOS upgrade disks to make a bootable set.)\n"
		sleep 2
		Echo
		Retry_Abort
		Echo
	done
	return
}

Get_Next_Disk()
{
	$TRC "Get_Next_Disk $1 $2" >> $TRACE
	THIS=$1
	PREV=`expr $THIS - 1`
	usrMsg ECHO INSERT_NEXT \
"Replace disk #$PREV with disk #$THIS and press ENTER. " $PREV $THIS
	read ANS
	[ "x$ANS" = "x0" ] && Exit_Clean 2
	[ "x$ANS" = "x$ANS_Q" ] && Exit_Clean 2
	FIRST_TIME=first_time
	while true
	do
		if [ "$FIRST_TIME" != "first_time" ]
		then
			if [ "$HAVE_BDRIVE" = "no_bdrive" ]
			then
				# Single drive system
				usrMsg ECHO INSERT_S \
	"Insert DOS disk #$THIS in the drive and press ENTER. " $THIS
			else
				# Dual drive system
				usrMsg ECHO INSERT_D \
	"Insert DOS disk #$THIS in drive $DRIVE_NAME and press ENTER. " \
					$THIS "$DRIVE_NAME"
			fi
			read ANS
			[ "x$ANS" = "x0" ] && Exit_Clean 2
			[ "x$ANS" = "x$ANS_Q" ] && Exit_Clean 2
		fi
		FIRST_TIME=negative
		usrMsg ECHO CHECK_DISK  "Checking the disk."
		echo "dir" | $DOSDISK -s -r $DRIVE_DEV > disk$THIS.dir 2>>$TRACE
		if [ $? -ne 0 ]
		then
			Echo
			Echo 
			usrMsg ECHO BAD_DISK \
"      Had trouble reading the disk.\n\
      Check that the disk is inserted in the correct drive.\n"
			sleep 2
			Echo
			Retry_Abort
			Echo
			continue
		fi
		Echo
		NUM=0
		# Check against previous disks.
		while true
		do
			NUM=`expr $NUM + 1`
			if [ $NUM -eq $THIS ]
			then
				# Did not match any of the previous
				# disks, so assume it is the right one.
				return
			fi
			# Note: cmp returns 0 when identical files.
			cmp -s disk$THIS.dir disk$NUM.dir >> $TRACE 2>&1
			RETVAL=$?
			$TRC "cmp of disk $THIS to $NUM ret $RETVAL" >> $TRACE
			if [ $RETVAL -eq 0 ]
			then
				# Is identical, which means this disk
				# was already read in.  Go to recovery code.
				break
			fi
			# Not identical.  This is correct.
			# Passed test. Test the next.
		done
		# File is identical, which means the user
		# inserted a disk twice.
		Echo 
		usrMsg ECHO WRONG_DISK_N \
"      This disk was already read in as disk #$NUM.\n\
      Please check that you have the correct disk in the proper drive.\n" $NUM
		sleep 2
		Echo
		Retry_Abort
		Echo
	done
}

Check_Room()
{
	# Check that there is enough disk space to install DOS.
	# Note: DOSVER must already be set appropriately.

	HAVE_FREE=`${STATICMERGE}/dfmerge -b ${VARM}`

	# Call the function set the variable:
	# 	NEED_FREE
	# ("Size_Need_Set" is in the ".func" file)
	Size_Need_Set

	# Adjust the current available disk space value to reflect what
	# we will have after the currently installed DOS is removed.
	if [ -f ${VARM}/dosneedspace ]
	then
		. ${VARM}/dosneedspace
		[ -n "$OLD_NEED_FREE" ] && \
		    [ $OLD_NEED_FREE -gt 0 ] && \
			HAVE_FREE=`expr $HAVE_FREE + $OLD_NEED_FREE`
	fi

	# Now check for the needed space.
	if [ $HAVE_FREE -ge $NEED_FREE ]
	then
		return
	fi
	usrMsg ERROR ERR_CANNOT_INST "Cannot install DOS.\n"
	usrMsg ECHO NO_SPACE "     Not enough space.\n"
	usrMsg ECHO NEED_SPACE \
		"     Need: $NEED_FREE blocks, Have: $HAVE_FREE.\n" \
		$NEED_FREE $HAVE_FREE
	usrMsg ECHO CLEAN_UP \
"To complete installation of DOS, make more disk space available, and reboot.\n"
	Exit_Clean 1
}

Check_Installed()
{
	if [ ! -f ${DOSROOTDOS}/command.com -a \
	     ! -f ${DOSROOTDOS}/io.sys      -a \
	     ! -f ${DOSROOTDOS}/winboot.sys -a \
	     ! -f ${DOSROOTDOS}/msdos.sys   -a \
	     ! -f ${DOSROOTDOS}/ibmbio.com  -a \
	     ! -f ${DOSROOTDOS}/ibmdos.com   ]
	then
		# None of the DOS system files exist, which we take to
		# mean that DOS is not installed, so just return.
		$TRC "Check_Installed:No DOS system files exist." >> $TRACE
		return;
	fi
	# At least one of the DOS system files exist, so need to do a remove.
	Echo
	usrMsg ECHO ERR_ALREADY_INST \
"DOS is already installed.  The currently installed DOS\n\
must be removed before re-installation can be done.\n"
	Echo
	if [ "$NOPROMPT" = "noprompt" ]
	then
		usrMsg ECHO DOSINST_NOTINST "Not installing DOS.\n"
		EXIT_NOW 1
	fi

	usrMsg STRING Q_REMOVE \
	    "Do you want to remove the currently installed DOS now (y/n/q) ? "
	Q_REMOVE="$USRMSG_STRING"
	Get_Answer "$ANS_Y" "$ANS_N" "$Q_REMOVE" "$Q_PROMPT"
	if [ $? -ne $FIRST_ANSWER ]
	then
		usrMsg ECHO CANCEL_MSG "Cancelling DOS re-installation.\n"
		EXIT_NOW 0
	fi
	Echo
	usrMsg ECHO RM_MSG "Removing DOS\n"
	${STATICMERGE}/dosremove from_dosinstall
        RETVAL=$?
        [ $DOSINSTALLTRACE -eq 2 ] && Trace_df after_removal
	if [ $RETVAL -ne 0 ]
	then
		usrMsg ECHO ERR_RM "Had problems removing DOS.\n"
		usrMsg STRING Q_CONTINUE \
			"Do you want to continue DOS installation (y/n/q) ? "
		Q_CONTINUE="$USRMSG_STRING"
		Get_Answer "$ANS_Y" "$ANS_N" "$Q_CONTINUE" "$Q_PROMPT"
		if [ $? -ne $FIRST_ANSWER ]
		then
			Echo
			usrMsg ECHO CANCEL_MSG \
				"Cancelling DOS re-installation.\n"
			EXIT_NOW 0
		fi
	fi
	Echo
	usrMsg ECHO RE_INST "Re-Installing DOS\n"
	Echo
	# Make sure needed directories exist.
	[ ! -d ${DOSROOTDOS}/.other ] && mkdir ${DOSROOTDOS}/.other
	chgrp bin ${DOSROOTDOS}/.other
	chown bin ${DOSROOTDOS}/.other
	chmod 775 ${DOSROOTDOS}/.other
}

Trace_df()
{
	$TRC "df at $1" >> $TRACE
	$TRC "Free blocks in ${INST_ROOT}/usr: \c" >> $TRACE
	${STATICMERGE}/dfmerge -b ${INST_ROOT}/usr >> $TRACE
}

Version_Setup()
{
	FUNC_FILE=$1
	VDL_FILE=$2
	EMSG_NAME="$3"
	$TRC "Version_Setup($FUNC_FILE,$VDL_FILE,$EMSG_NAME)" >> $TRACE
	if [ "$VDL_FILE" != "none" ]
	then
		VSF=$DOSI_DIR/$VDL_FILE
		if [ ! -f $VSF ]
		then
			usrMsg ECHO NO_FILE "Error: Missing $VSF\n" $VSF
			usrMsg ECHO DOSINST_CANT \
				"Cannot install $EMSG_NAME\n" $EMSG_NAME
			Exit_Clean 3
		fi
		UNIXCPIO=
		. $VSF
		# The vset file set DISKCOUNT and DISK1, DISK2, ...
		HAVE_VDISKS=have_vdisks
		DISK1=$DOSI_DIR/$DISK1
		# Uncompress the first virtual disk if need be.
		if [ -f ${DISK1}.Z ]
		then
			rm -f $TMP_SDSK
			cat ${DISK1}.Z | uncompress > $TMP_SDSK
			DISK1=$TMP_SDSK
		elif [ -f ${DISK1}.gz ]
		then
			rm -f $TMP_SDSK
			cat ${DISK1}.gz | gunzip > $TMP_SDSK
			DISK1=$TMP_SDSK
		fi	
		DISK2=$DOSI_DIR/$DISK2
		DISK3=$DOSI_DIR/$DISK3
		DISK4=$DOSI_DIR/$DISK4
		DISK5=$DOSI_DIR/$DISK5
		DISK6=$DOSI_DIR/$DISK6
		DISK7=$DOSI_DIR/$DISK7
		DISK8=$DOSI_DIR/$DISK8
		DISK9=$DOSI_DIR/$DISK9
		$TRC "Installing from $DISKCOUNT virtual disks." >> $TRACE
		$TRC "  DISK1=$DISK1" >> $TRACE
		if [ "z$UNIXCPIO" != "z" ]
		then
			HAVE_FILES=have_files
			$TRC "Installing from $UNIXCPIO" >> $TRACE
			UNIXCPIO=$DOSI_DIR/$UNIXCPIO
		fi
	else
		$TRC "Installing from floppy disks" >> $TRACE
	fi
	# The ".func" file sets needed variables:
	#	DOSVER
	#	DOSBRAND
	#	DOSNUM
	# and any other variables needed (such as ones needed when
	# installing from virtual floppies).
	# The ".func" file provides these functions:
	#	Set_DOS_Lists
	#	Size_Need_Set
	#	Version_Specific_Install
	#	Make_DOS_Specific
	#	Func_Clean_Up
	#
	FNF=$DOSI_DIR/${FUNC_FILE}
	if [ ! -f $FNF ]
	then
		usrMsg ECHO NO_FILE "Error: Missing $FNF\n" $FNF
		usrMsg ECHO DOSINST_CANT "Cannot install $EMSG_NAME\n" $EMSG_NAME
		Exit_Clean 3
	fi
	. $FNF
	HAVE_FUNC=yes
	$TRC " DOSVER=$DOSVER, DOSBRAND=$DOSBRAND, DOSNUM=$DOSNUM" >> $TRACE
}

#----------------------------------------------------------
#
Setup_DOS_Ver_Menu()
{
	ASK_USER=ask_user
	SAVELOC=`pwd`
	cd $DOSI_DIR
	SELECT_COUNT=0
	SELECTIONS=0
	# Set variaibles that Get_DOS_Ver uses to create the menu.
	for ff in [123456789]*.set
	do
		[ ! -s $ff ] && continue
		SELECT_COUNT=`expr $SELECT_COUNT + 1`
		# Get the values from the ".set" files.
		unset MENULINE
		unset FUNCFILE
		unset EMSGNAME
		VDLFILE=none
		unset LANGUAGE
		unset SPECIAL
		unset FROMDOSC
		unset FROMCD
		. ./$ff
		# MENULINE is the string to put in the selection menu.
		# FUNCFILE is the base filename for the ".func" file.
		#	e.g. "msdos50" or "drdos60"
		# EMSGNAME is used in an error message.
		eval MENULINE$SELECT_COUNT=\"$MENULINE\"
		eval FUNCFILE$SELECT_COUNT=\"$FUNCFILE\"
		eval EMSGNAME$SELECT_COUNT=\"$EMSGNAME\"
		eval VDLFILE$SELECT_COUNT=\"$VDLFILE\"
		eval LANGUAGE$SELECT_COUNT=\"$LANGUAGE\"
		eval SPECIAL$SELECT_COUNT=\"$SPECIAL\"
		eval FROMDOSC$SELECT_COUNT=\"$FROMDOSC\"
		eval FROMCD$SELECT_COUNT=\"$FROMCD\"
		eval ANS$SELECT_COUNT=$SELECT_COUNT
		SELECTIONS="$SELECTIONS, $SELECT_COUNT"
	done
	# Now add a selection for installing DOS 7 from CD.
	SELECT_COUNT=`expr $SELECT_COUNT + 1`
	usrMsg STRING DOSINST_DOS7X "MS-DOS 7.x"
	eval MENULINE$SELECT_COUNT=\"$USRMSG_STRING\"
	eval FUNCFILE$SELECT_COUNT=\"x\"
	eval EMSGNAME$SELECT_COUNT=\"x\"
	eval VDLFILE$SELECT_COUNT=\"cd\"
	eval LANGUAGE$SELECT_COUNT=\"\"
	eval SPECIAL$SELECT_COUNT=\"\"
	eval FROMCD$SELECT_COUNT=\"win9xcd\"
	eval ANS$SELECT_COUNT=$SELECT_COUNT
	
	cd $SAVELOC
	if [ $SELECT_COUNT -eq 0 ]
		then
		usrMsg ECHO MISSING_SET "Missing the 'set' files\n"
		usrMsg ECHO CANNOT_CONTINUE "Cannot continue.\n"
		Exit_Clean 3
	fi
	unset MENULINE
	unset FUNCFILE
	unset EMSGNAME
	unset VDLFILE
	unset LANGUAGE
	unset SPECIAL
	unset FROMDOSC
	unset FROMCD
}

#----------------------------------------------------------
#
Get_DOS_Ver()
{
	usrMsg STRING FROM_FLOP "(from floppies)"
	FROM_FLOP="$USRMSG_STRING"
	usrMsg STRING FROM_BUILTIN "(from built-in files)"
	FROM_BUILTIN="$USRMSG_STRING"
	usrMsg STRING FROM_DOSC_COPY_MSG "(from files copied from the native DOS C drive)"
	FROM_DOSC_COPY_MSG="$USRMSG_STRING"
	usrMsg STRING FROM_CD_COPY_MSG "(from files copied from the Windows CD)"
	FROM_CD_COPY_MSG="$USRMSG_STRING"
	usrMsg STRING FROM_CD_MSG "(from Windows CD)"
	FROM_CD_MSG="$USRMSG_STRING"
	usrMsg STRING MIN_SYSTEM "minimum system"
	MIN_SYSTEM="$USRMSG_STRING"
	while	true
	do
		Echo
		usrMsg ECHO DOSINST_DOSBRAND_MENU1 \
		     "Choose which DOS to install.\n"
		Echo
		CNT=0
		while	true
		do
			CNT=`expr $CNT + 1`
			X="MENULINE$CNT"
			eval MENULINE='$'$X
			X="LANGUAGE$CNT"
			eval LANGUAGE='$'$X
			X="SPECIAL$CNT"
			eval SPECIAL='$'$X
			X="VDLFILE$CNT"
			eval VDLFILE='$'$X
			X="FROMDOSC$CNT"
			eval FROMDOSC='$'$X
			X="FROMCD$CNT"
			eval FROMCD='$'$X
			Z=
			if [ "x$SPECIAL" = "xminimum" ]
			then
				Z="$MIN_SYSTEM "
			fi
			if [ "$VDLFILE" = "none" ]
			then
				Z="${Z}$FROM_FLOP"
			elif [ "x$FROMDOSC" = "xfromDOSC" ]
			then
				Z="${Z}$FROM_DOSC_COPY_MSG"
			elif [ "x$FROMCD" = "xfromCD" ]
			then
				# From files saved by instdos7cd.sh
				Z="${Z}$FROM_CD_COPY_MSG"
			elif [ "x$FROMCD" = "xwin9xcd" ]
			then
				# Need to use instdos7cd.sh to install.
				Z="${Z}$FROM_CD_MSG"
			else
				Z="${Z}$FROM_BUILTIN"
			fi
			Echo "      $CNT: $MENULINE $Z"
			[ $CNT -eq $SELECT_COUNT ] && break
		done
		usrMsg ECHO DOSINST_DOSBRAND_MENU2 \
		     "      0: None of the above.  Abort installation of DOS.\n\
\n\
Type the item number and then press Enter: "
		read ANS XXX
		[ "x$ANS" = "x0" ] && Exit_Clean 2
		[ "x$ANS" = "x$ANS_Q" ] && Exit_Clean 2
		if [ -n "$ANS" ]
		then
			X="ANS$ANS"
			eval XX='$'$X
			[ "z$ANS" = "z$XX" ] && break
		fi
		usrMsg ECHO DOSINST_PLS_ENTER "Please enter $SELECTIONS\n" \
			"$SELECTIONS"
	done
	unset MENULINE
	unset FUNCFILE
	unset EMSGNAME
	unset VDLFILE
	unset LANGUAGE
	unset SPECIAL
	X="EMSGNAME$ANS"
	eval EMSGNAME=\"'$'$X\"
	X="FUNCFILE$ANS"
	eval FUNCFILE='$'$X
	X="VDLFILE$ANS"
	eval VDLFILE='$'$X
	X="LANGUAGE$ANS"
	eval LANGUAGE='$'$X
	X="SPECIAL$ANS"
	eval SPECIAL='$'$X
	Version_Setup $FUNCFILE $VDLFILE "$EMSGNAME"
}


##--------------------------------------------------------------------------
## Start: The main part of the script starts here.
##--------------------------------------------------------------------------
TMP_SDSK=${DOSI_TMP}/tmpdosi.dsk

if [ "x$1" = "xnoprompt" ]
then
	NOPROMPT=noprompt
	shift
else
	NOPROMPT=interactive
fi
if [ "x$1" = "xmin" ]
then
	MINIMAL_INSTALL=minimal
	shift
fi
if [ "x$1" = "x-j" ]
then
	TESTJ=Japanese
	shift
else
	TESTJ=generic
fi
if [ "x$1" = "xgui" ]
then
	GUI="gui"
	shift
fi
HAVE_DRIVE=no
if [ "x$1" = "xdrive" ]
then
	shift
	if [ "x$1" = "x" ]
	then
		Echo "drive value incomplete"
		EXIT_NOW 1
	fi
	DRIVE_NAME=$1
	HAVE_DRIVE=yes
	shift
fi
DISKCOUNT=0
HAVE_DISKCOUNT=no
if [ "x$1" = "xdiskcount" ]
then
	shift
	if [ "x$1" = "x" ]
	then
		Echo "diskcount value incomplete"
		EXIT_NOW 1
	fi
	DISKCOUNT=$1
	HAVE_DISKCOUNT=yes
	shift
fi
ARG1=$1
ARG2=$2

NULL=/dev/null
TRACE=/dev/null
if [ "x$DOSINSTALLTRACE" = "x" ]
then
	DOSINSTALLTRACE=1
fi
if [ $DOSINSTALLTRACE -ne 0 ]
then
	if [ -d ${VARM}/log ]
	then
		NULL=${VARM}/log/null.dosinst
		TRACE=${VARM}/log/trace.dosinst
	else
		# No need to NLSize this message.
		Echo "Missing log directory ${VARM}/log"
		Echo "Not logging dosinstall"
		DOSINSTALLTRACE=0
	fi
fi
export NULL TRACE
LOG_FILE=$TRACE
>$NULL
>$TRACE

$TRC "Trace of dosinstall" >> $TRACE
[ $DOSINSTALLTRACE -eq 2 ] && Trace_df start

cd /

# Set version variables from the Version file.
. ${STATICMERGE}/Version

# Set up NLS variables and functions.
DM="LCC.MERGE.UNIX.DOSINSTALL"
. ${STATICMERGE}/set_nls.sh

# VARM must exist!
if [ ! -d ${VARM} ]
then
	usrMsg ERROR MISSING_DIR \
"Error: Missing directory ${VARM}\n" ${VARM}
	usrMsg ECHO CANNOT_CONTINUE "Cannot continue.\n"
	EXIT_NOW 1
fi
# If an out-of-date command.com is in the root of the "C" drive
# then things might not work correctly, so make sure it
# is not there in the C drive we are going to be using.
rm -f ${VARM}/rhome/*/command.com

touch ${VARM}/doing_dosinst  >> $NULL 2>&1
CLEAN_UP_OK=
if [ ! -r /dev/kmem ]
then
	usrMsg ERROR NO_PERM "Must be root or su to install DOS.\n"
	EXIT_NOW 1
fi
# In case this is being run by a normal user via a setuid utility,
# change HOME to root so that if this is the first time the user
# runs Merge, the user's configuration files will not be created
# as owned by root when dosexec is run as a part of installing DOS.
HOME=/
export HOME

if [ ! -d ${DOSROOTDOS} ]
then
	usrMsg ECHO CREATING_DIR \
"Warning: Missing directory ${DOSROOTDOS}\n\
Creating it.\n" ${DOSROOTDOS}
	mkdir     ${DOSROOTDOS}
	chown bin ${DOSROOTDOS}
	chgrp bin ${DOSROOTDOS}
	chmod 775 ${DOSROOTDOS}
fi
# Start out with a clean DOSI_TMP.
rm -rf    ${DOSI_TMP}
mkdir     ${DOSI_TMP}
chown bin ${DOSI_TMP}
chgrp bin ${DOSI_TMP}
chmod 755 ${DOSI_TMP}

if [ "z$INST_ROOT" != "z" ]
then
	# Installing into a special hierarchy.
	$TRC "Installing into a special hierarchy ${DOSROOTDOS}" >> $TRACE
	if [ ! -d /bin/dos -a ! -d /usr/bin/dos ]
	then
		usrMsg ECHO NO_FILE \
			"Error: Missing /bin/dos" /bin/dos
		usrMsg ECHO CANNOT_CONTINUE "Cannot continue.\n"
		EXIT_NOW 1
	fi
	if [ ! -f ${VARM}/image/std/mono/mono.img ]
	then
		usrMsg ECHO NO_FILE \
			"Error: Missing ${VARM}/image/std/mono/mono.img" \
			${VARM}/image/std/mono/mono.img
		usrMsg ECHO CANNOT_CONTINUE "Cannot continue.\n"
		EXIT_NOW 1
	fi
fi

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:$PATH ; export PATH
DOSDISK=$STATICMERGE/dosdisk
FLOPINFO=$STATICMERGE/flopinfo
TMP_LOC=${DOSI_TMP}/tmpdir.$$

trap interruptProc 1 2 3 15

$TRC INST_ROOT=${INST_ROOT} >> $TRACE
$TRC DOSROOTDOS=${DOSROOTDOS} >> $TRACE
$TRC STATICMERGE=${STATICMERGE} >> $TRACE
$TRC TRACE=$TRACE >> $TRACE
$TRC NULL=$NULL >> $TRACE

# Set the standard yes/no question variables.

usrMsg STRING ANS_Q "q"
ANS_Q="$USRMSG_STRING"
usrMsg STRING ANS_Y "y"
ANS_Y="$USRMSG_STRING"
usrMsg STRING ANS_N "n"
ANS_N="$USRMSG_STRING"
usrMsg STRING Q_PROMPT "Please answer y or n or q\n"
Q_PROMPT="$USRMSG_STRING"

DOSVER=unknown
DOSBRAND=unknown
DOSNUM=unknown
DISKTYPE=unknown
ASK_USER=unknown
HAVE_VDISKS=no_vdisks
HAVE_FILES=no_files

# See if the command line specifies a virtual installation disk set or a
# known type of DOS to install from disks (virtual or real).
# If so, then run Version_Setup.
unset MENULINE
unset FUNCFILE
unset EMSGNAME
unset VDLFILE
unset LANGUAGE
unset SPECIAL
# For Unixware, the when the directory /usr/lib/locale/japan" exists,
# then we are on a Japanese system, and we want to only display
# the Japanese menu items.
# For SCO check the LANG environment variable to determine if it is
# a Japanese system.  Note that on SCO, in some circumstances LANG
# is set as it is for US.
# So, the "-j" option can be used to force Japanese DOS installation.

if [ "$SYSTEMTYPE" = "sco" ]
then
    lang=$LANG

    if [ "x" = "x$lang" ]
    then
	lang=`grep '^LANG=' /etc/default/lang | head -1 | sed -e 's/LANG=//p'`
	if [ "x" = "x$lang" ]
	then
		lang=C
	fi
	LANG=$lang export LANG
    fi

    if [ "$LANG" = "ja_JP.EUC" ]
    then
	TESTJ=japanese
    fi
else
    if [ -d /usr/lib/locale/japan -a "x$NO_J_DOSINSTALL" != "xno_j_dosinstall" ]
    then
	TESTJ=japanese
   fi
fi
if [ $TESTJ = "Japanese" ]
then
	# We are running on a Japanese UNIX system, so only display
	# the Japanese DOS options (if they exist).
	STAT_DOSI=$STATICMERGE/jdosi
	[ ! -d $STAT_DOSI ] && STAT_DOSI=$STATICMERGE/dosi
else
	STAT_DOSI=$STATICMERGE/dosi
fi
VAR_DOSI=$VARMERGE/dosi

# Make symbolic links to the files in $STAT_DOSI and $VAR_DOSI
# in the temporary dosimenu directory.
rm -rf    ${DOSI_DIR}
mkdir     ${DOSI_DIR}
chown bin ${DOSI_DIR}
chgrp bin ${DOSI_DIR}
chmod 755 ${DOSI_DIR}

if [ -d $STAT_DOSI ]
then
	cd $STAT_DOSI
	for i in *
	do
		[ "$i" = "*" ] && continue
		ln -s ${STAT_DOSI}/$i ${DOSI_DIR}/$i
	done
fi
if [ -d $VAR_DOSI ]
then
	cd $VAR_DOSI
	for i in *
	do
		[ "$i" = "*" ] && continue
		# The files in VAR_DOSI have precedence.
		[ -h ${DOSI_DIR}/$i -o -f ${DOSI_DIR}/$i ] \
			&& rm -f ${DOSI_DIR}/$i
		ln -s ${VAR_DOSI}/$i ${DOSI_DIR}/$i
	done
fi

DOS_SETFILE=$DOSI_DIR/$ARG1.set
if [ -f $DOS_SETFILE ]
then
	# DOS_SETFILE sets MENULINE, FUNCFILE and EMSGNAME; and might
	# set VDLFILE, LANGUAGE and SPECIAL.
	VDLFILE=none
	. $DOS_SETFILE
	$TRC "${ARG1}.set:FUNCFILE=$FUNCFILE EMSGNAME=$EMSGNAME MENULINE=$MENULINE VDLFILE=$VDLFILE" >> $TRACE
	Version_Setup $FUNCFILE $VDLFILE "$EMSGNAME"
	# Version_Setup just set DOSVER, DOSBRAND, DOSNUM.
	# When virtual disks, also sets HAVE_VDISKS, DISKCOUNT, DISK1, DISK2...
	#
	# If UNIXCPIO is also set, that means we are to install all the
	# DOS files from the cpio file tha UNIXCPIO is set to instead of
	# installing files from virtual disks.
	#
else
	if [ "$NOPROMPT" = "noprompt" ]
	then
		[ "x$ARG1" = "xdefault" ] && touch ${VARM}/nodefaultdos
		Echo
		usrMsg ECHO DOSINST_AUTO_NA "\
Unable to automatically install DOS.\n\
To install DOS from your DOS floppy disks\n\
run the 'dosinstall' program.\n"
		Echo
		Exit_Clean 1
	fi
	# Setup_DOS_Ver_Menu sets ASK_USER to ask_user, and set up
	# everything needed for the Get_DOS_Ver function.
	Setup_DOS_Ver_Menu
fi


# Install DOS into the DOSROOTDOS directory.
cd ${DOSROOTDOS}

[ ! -d ${DOSROOTDOS}/.other ] && mkdir ${DOSROOTDOS}/.other
chgrp bin ${DOSROOTDOS}/.other
chown bin ${DOSROOTDOS}/.other
chmod 775 ${DOSROOTDOS}/.other
# Make the temporary directory, where the files are initialled read into.
mkdir $TMP_LOC
cd $TMP_LOC

if [ "$HAVE_VDISKS" != "have_vdisks" ]
then
	Echo
	usrMsg ECHO INSTALLING_DOS "Installing DOS\n"
	Echo
	usrMsg ECHO DOSINST_0Q_MSG \
	 "Entering 0 or q at any prompt will abort the installation of DOS.\n"
fi

if [ "$ASK_USER" = "ask_user" ]
then
	# Ask the user what kind of DOS is being installed, and
	# calls"Version_Setup" for the selected DOS version.
	Get_DOS_Ver
fi
if [ "$DOSVER" = "unknown" ]
then
	usrMsg ECHO INTERNAL_ERR "Dosinstall internal error 1\n" 1
	usrMsg ECHO CANNOT_CONTINUE "Cannot continue.\n"
	Exit_Clean 4
fi
if [ "$HAVE_VDISKS" != "have_vdisks" ]
then
	# Call "Get_Flop_Info" to set DISKCOUNT and DISKTYPE.
	Get_Flop_Info

	# "Which_Drive" sets DRIVE_NAME, DRIVE_DEV and HAVE_BDRIVE.
	Which_Drive
fi


# Make sure enough space exists to install.
Check_Room

# Make sure any previous installation of DOS is removed before
# continuing.
Check_Installed

# At this point any previous installed DOS is removed, so
# enable the CLEAN_UP_OK feature of the "Exit_Clean" function.
CLEAN_UP_OK=clean_up_ok

if [ "z$INST_ROOT" = "z" ]
then
	# Perform any steps needed when NOT doing a special install.

	# Remove any existing oemsetup.inf file.  (Later this script
	# re-creates it.)
	rm -f ${DOS_ROOT}/mwindows/oemsetup.inf

	# Also remove any language dependent grabber files.
	rm -f ${DOS_ROOT}/mwindows/vgadib.3g_
	rm -f ${DOS_ROOT}/mwindows/vgadibj.3g_
fi


if [ "$HAVE_VDISKS" != "have_vdisks" ]
then
	usrMsg ECHO DOSINST_MSG1 \
	 "Installing $DOSVER from $DISKCOUNT disks.\n" \
	 "$DOSVER" $DISKCOUNT
	if [ "$HAVE_BDRIVE" = "have_bdrive" ]
	then
		usrMsg ECHO DOSINST_FROM "Installing from drive $DRIVE_NAME.\n"\
			$DRIVE_NAME
	fi
	Echo
else
	# Installing from virtual disks.
	if [ "x$MINIMAL_INSTALL" = "x" ]
	then
		usrMsg ECHO INSTALLING_DOSVER "Installing $DOSVER\n" "$DOSVER"
	fi
fi

if [ "$HAVE_VDISKS" != "have_vdisks" ]
then
	# Prompt for the first disk, and verify it.
	# (Verifies it by calling "Get_Disk1_Dir", and
	# checking IO_FILE, DOS_FILE and COMMAND_FILE.)
	Get_First_Disk
else
	# Verify the first virtual disk.
	Get_Disk1_Dir $DISK1
	# Note: IO_FILE, DOS_FILE, and COMMAND_FILE are set in
	#       the function "Get_Disk1_Dir".
	if [ -z "$IO_FILE" -o -z "$COMMAND_FILE" ]
	then
		usrMsg ECHO VDISK_ERR \
			"Error with virtual disk.  Cannot install DOS.\n"
		$TRC "$IO_FILE $DOS_FILE $COMMAND_FILE" >> $TRACE
		Exit_Clean 2
	fi
fi
$TRC "HAVE_VDISKS= $HAVE_VDISKS" >> $TRACE
$TRC "DOSVER= $DOSVER" >> $TRACE
$TRC "DISKTYPE= $DISKTYPE" >> $TRACE
$TRC "DISKCOUNT= $DISKCOUNT" >> $TRACE

usrMsg ECHO INST_SYS "Installing DOS system files.\n"

# Initialize the file lists. ("Set_DOS_Lists" is in the ".func" file)
Set_DOS_Lists

# Install the minimal DOS system files from the first disk.
First_Disk_Sys_Inst

if [ "x$EARLY_MKIMG" = "xearly_mkimg" ]
then
	# Make an initial mono image so can use Merge to
	# help install the DOS files from the disks.
	First_Disk_Mkimg
fi


# Copy all the files from the disks into the current directory.
CNTR=1
for i in $DISK1 $DISK2 $DISK3 $DISK4 $DISK5 $DISK6 $DISK7 $DISK8 $DISK9
do
	if [ "$HAVE_VDISKS" = "no_vdisks" ]
	then
		usrMsg ECHO READING_MESSAGE "Reading the floppy disk."
	else
		# Uncompress the virtual disk if need be.
		if [ -f ${i}.Z ]
		then
			$TRC "Uncompressing $i to $TMP_SDSK." >> $TRACE
			rm -f $TMP_SDSK
			cat ${i}.Z | uncompress > $TMP_SDSK
			i=$TMP_SDSK
		elif [ -f ${i}.gz ]
		then
			$TRC "Uncompressing $i to $TMP_SDSK." >> $TRACE
			rm -f $TMP_SDSK
			cat ${i}.gz | gunzip > $TMP_SDSK
			i=$TMP_SDSK
		fi	
	fi
	$TRC "About to copyfrom $i." >> $TRACE
	[ $DOSINSTALLTRACE -eq 2 ] && Trace_df 1
	echo "copyfrom" | $DOSDISK -s -e -r $i >>$TRACE 2>&1
	$TRC "copyfrom done." >> $TRACE
	[ $DOSINSTALLTRACE -eq 2 ] && Trace_df 2

	CNTR=`expr $CNTR + 1`
	[ $CNTR -gt $DISKCOUNT ] && break
	$TRC "CNTR=$CNTR DISKCOUNT=$DISKCOUNT" >> $TRACE
	if [ "$HAVE_VDISKS" = "no_vdisks" ]
	then
		Echo
		Get_Next_Disk $CNTR $i
	fi
done

if [ "$HAVE_FILES" = "have_files" ]
then
	$TRC "Copying file from $UNIXCPIO" >> $TRACE
	if [ "$SYSTEMTYPE" = "linux" ]
	then
		CPIO_TYPE=
	else
		CPIO_TYPE=c
	fi
	if [ -f ${UNIXCPIO}.Z ]
	then
		$TRC "doing: zcat ${UNIXCPIO}.Z | cpio -iv$CPIO_TYPE" >> $TRACE
		zcat ${UNIXCPIO}.Z | cpio -iv$CPIO_TYPE >> $TRACE 2>&1
	elif [ -f ${UNIXCPIO}.gz ]
	then
		$TRC "doing: gunzip -c ${UNIXCPIO}.gz | cpio -iv$CPIO_TYPE" >> $TRACE
		gunzip -c ${UNIXCPIO}.gz | cpio -iv$CPIO_TYPE >> $TRACE 2>&1
	else	
		$TRC "doing: cpio -iv$CPIO_TYPE < $UNIXCPIO " >> $TRACE
		cpio -iv$CPIO_TYPE < $UNIXCPIO >> $TRACE 2>&1
	fi
fi

$TRC "All done reading in DOS files." >> $TRACE
[ $DOSINSTALLTRACE -eq 2 ] && Trace_df read_done
if [ "$HAVE_VDISKS" = "no_vdisks" ]
then
	Echo
	usrMsg ECHO DSK_DONE "You may remove the disk now.\n"
	Echo
fi
$TRC "Deleting unneeded files." >> $TRACE
for i in $Delete_List
do
	rm -f $i
done
[ $DOSINSTALLTRACE -eq 2 ] && Trace_df delete_done
# Call the function to do DOS version specific install stuff.
# ("Version_Specific_Install" is in the ".func" file)
Version_Specific_Install

# At this point all the files are read in.
# Now configure the DOS files.
if [ "x$MINIMAL_INSTALL" = "x" ]
then
	usrMsg ECHO CONFIGURING "Configuring DOS files.\n"
fi
[ $DOSINSTALLTRACE -eq 2 ] && Trace_df before_config

# First make all the files read only.
ls | xargs chmod 444

NEWFILES=${DOSI_TMP}/nf$$
> $NEWFILES
Do_copies

# Call the function that creates DOS version specific in the current
# directory (and adds to NEWFILES as appropriate).
# ("Make_DOS_Specific" is in the ".func" file)
Make_DOS_Specific

# Now just set the file ownerships, and configuration is done.
ls | xargs chgrp bin
ls | xargs chown bin

# These variables are set in the ".func" file.
echo "DOSVER=\"$DOSVER\""     >  version.dos
echo "DOSBRAND=\"$DOSBRAND\"" >> version.dos
echo "DOSNUM=\"$DOSNUM\""     >> version.dos
echo "MKIFILE=\"$MKIFILE\""   >> version.dos
echo "LANGUAGE=\"$LANGUAGE\"" >> version.dos
echo "SPECIAL=\"$SPECIAL\""   >> version.dos
# Note: LANGUAGE and SPECIAL might not be set.

chgrp bin version.dos
chown bin version.dos
chmod 444 version.dos
echo version.dos >> $NEWFILES

$TRC "Hiding unsupported files." >> $TRACE
for i in $Hide_List
do
	[ ! -f $i ] && continue
	# Hide the file.
	mv $i .$i
	echo .$i >> $NEWFILES
done

# Everything is configured correctly now.
[ $DOSINSTALLTRACE -eq 2 ] && Trace_df after_config
$TRC "Move files into place." >> $TRACE

# Move the files from the temporary directory to the real one.

rm -f disk?.dir

if [ -n "$LIST_FILE" -a -f "$LIST_FILE" ]
then
	$TRC "Move files listed in $LIST_FILE from `pwd` to ${DOSROOTDOS}" \
		>> $TRACE
	mv `cat ${LIST_FILE}` ${DOSROOTDOS} 2>> $TRACE
else
	$TRC "Move all files from `pwd` to ${DOSROOTDOS}" >> $TRACE
	for i in *
	do
		[ ! -f $i ] && continue
		mv $i ${DOSROOTDOS} 2>> $TRACE
	done
fi

if [ -s $NEWFILES ]
then
	mv `cat $NEWFILES` ${DOSROOTDOS} 2>> $TRACE
	rm -f $NEWFILES
fi

for i in *
do
	[ ! -d $i ] && continue
	[ ! -d ${DOSROOTDOS}/$i ] && mkdir ${DOSROOTDOS}/$i
	mv $i/*  ${DOSROOTDOS}/$i	2>> $NULL
	chgrp bin     ${DOSROOTDOS}/$i
	chown bin     ${DOSROOTDOS}/$i
	chmod 775     ${DOSROOTDOS}/$i
	rmdir $i
done

if [ -n "`ls`" ]
then
	for i in *
	do
		[ ! -f $i ] && continue
		mv $i ${DOSROOTDOS}/.other
	done
fi
cd ${DOSROOTDOS}
[ $DOSINSTALLTRACE -eq 2 ] && Trace_df after_moving
rm -f $TMP_SDSK
rm -rf $TMP_LOC

Get_Capacity()
{
	$TRC "Get_Capacity: $1" >> $TRACE
	# Check the capacity of the floppy disk in arg #1.
	# This is done by making a "saveboot" file from it,
	# and checking the size of this file.
	#	Disk	-- saveboot --
	#     Capacity	bytes	blocks
	#     --------	-----	------
	#	 360K	 6144	12
	#	 720K	 7168	14
	#	1200K	14848	29
	#	1440K	16896	33
	#	2880K	    ?	 ?
	CCTMP=${DOSI_TMP}/cc$$.dsk
	echo saveboot $CCTMP | $DOSDISK -s -e -r $1 >> $TRACE 2>&1
	CCSIZE=`du -a $CCTMP | cut -f1`
	$TRC "sb blocks=$CCSIZE" >> $TRACE
	CAPACITY=360
	[ $CCSIZE -ge 14 ] && CAPACITY=720
	[ $CCSIZE -ge 29 ] && CAPACITY=1200
	[ $CCSIZE -ge 33 ] && CAPACITY=1440
	$TRC "CAPACITY=$CAPACITY" >> $TRACE
	rm -f $CCTMP
}

[ $DOSINSTALLTRACE -eq 2 ] && Trace_df before_bootdsk
BOOTDSK=${DOSROOTDOS}/boot.dsk
# Get capacity of boot.dsk. ("Get_Capacity" sets CAPACITY).
Get_Capacity $BOOTDSK
BD_CAP=$CAPACITY
$TRC "Capacity of boot.dsk = $BD_CAP" >> $TRACE

# Make a new boot.dsk file to see if it is higher density
# than the original one.  The more room the better on the
# boot.dsk file, so will use the largest capacity one.

$TRC "Make new boot.dsk" >> $TRACE
D1=${DOSI_TMP}/d1.$$
NEWDSK=${DOSI_TMP}/$$.dsk
if [ ! -f ${VARM}/image/std/mono/mono.img ]
then
	$TRC "first make a mono image" >> $TRACE
	[ $DOSINSTALLTRACE -eq 2 ] && Trace_df before_mkimgmono
	DOS_NO_NLS_IMAGE=on mkimg mono >> $TRACE 2>&1
	[ $DOSINSTALLTRACE -eq 2 ] && Trace_df after_mkimgmono
fi
$TRC "Running mkvfloppy" >> $TRACE
${STATICMERGE}/mkvfloppy $NEWDSK -s >> $TRACE 2>&1

# Check the virtual disk just created.  To check that it was
# properly created, and is bootable, check that it has command.com.
$TRC "Checking the vdisk" >> $TRACE
echo dir -sDV | $DOSDISK -s -r $NEWDSK  2>> $NULL > $D1
cat $D1 >> $TRACE
grep -i command.com $D1 >> $TRACE 2>&1
if [ $? -ne 0 ]
then
	$TRC "Failed to create new boot.dsk file" >> $TRACE
	cat $D1 >> $TRACE
	$TRC "Using existing boot.dsk file." >> $TRACE
##########	usrMsg ECHO CREATE_BOOT_FAIL "\
##########Warning: Failed to create new boot.dsk file.\n\
##########         Using existing boot.dsk file.\n"
else
	# Replace the old boot.dsk with the new file if the new file
	# has greater capacity.
	Get_Capacity $NEWDSK
	NEW_CAP=$CAPACITY
	$TRC "Capacity new boot.dsk = $NEW_CAP" >> $TRACE
	if [ $NEW_CAP -gt $BD_CAP ]
	then
		$TRC "Using new boot.dsk" >> $TRACE
		BD_CAP=$NEW_CAP
		chmod 666 $BOOTDSK
		cp $NEWDSK $BOOTDSK
		chmod 444 $BOOTDSK
	else
		$TRC "Using old boot.dsk" >> $TRACE
	fi
fi
[ $DOSINSTALLTRACE -eq 2 ] && Trace_df after_newbootdsk
rm -f  $NEWDSK $D1
[ $DOSINSTALLTRACE -eq 2 ] && Trace_df after_newbootdskclean

if [ -s /etc/default/merge ]
then
	TMPFILE=${DOSI_TMP}/edm.$$
	grep -v "^DOS_NO_NLS_IMAGE=" /etc/default/merge > $TMPFILE
	cmp -s /etc/default/merge $TMPFILE >> $TRACE 2>&1
	[ $? -ne 0 ] && cp $TMPFILE /etc/default/merge
	rm -f $TMPFILE
fi

# Check capacity of boot.dsk.  It must be at least a 720K type so that
# all the NLS files will fit on the snap disk that mkimg creates.
if [ $BD_CAP -lt 720 ]
then
	$TRC "Unable to create a large enough virtual disk" >> $TRACE
	$TRC "    to initialize all DOS NLS features, so disabling" >> $TRACE
	$TRC "    automatic DOS NLS features." >> $TRACE
	usrMsg ECHO  BOOT_TOOSMALL "\
Warning: Unable to create a large enough virtual disk\n\
         to initialize all DOS NLS features, so disabling\n\
         automatic DOS NLS features.\n"
	echo "DOS_NO_NLS_IMAGE=on" >> /etc/default/merge
fi

# Save info for next time dosinstall is run.
echo "OLD_NEED_FREE=$NEED_FREE"  > ${VARM}/dosneedspace
sync

$TRC "Now DOS is fully installed." >> $TRACE
# At this point DOS is fully installed.
if [ "z$INST_ROOT" = "z" ]
then
	# At this point DOS is completely installed.
	# Run any needed installation scripts that require DOS to be
	# installed first.

	# Call the version specific install function that needs to be
	# run after everything is installed, but before the images
	# are created.
	# ("Version_Specific_Post_Install" is in the ".func" file)
	Version_Specific_Post_Install

	if [ ! -f ${DOS_ROOT}/mwindows/oemsetup.inf ]
	then
		# Because Version_Specific_Post_Install did not
		# create the oemsetup.inf file, copy in the standard one.
		# (Note: in the future we could use this copy step
		# to NLSized the file.)
		cp ${STATICMERGE}/windrv/oemsetup.std \
			   ${DOS_ROOT}/mwindows/oemsetup.inf
		chown  bin ${DOS_ROOT}/mwindows/oemsetup.inf
		chgrp  bin ${DOS_ROOT}/mwindows/oemsetup.inf
		chmod  664 ${DOS_ROOT}/mwindows/oemsetup.inf
	fi

	if [ \( ! -f ${DOS_ROOT}/mwindows/vgadib.3g_ \) -a \
	     \( ! -f ${DOS_ROOT}/mwindows/vgadibj.3g_ \) ]
	then
		# Because Version_Specific_Post_Install did not
		# create the vgadib.3g_ file, copy in the standard one.
		cp ${STATICMERGE}/windrv/vgadib.3g_.std \
			   ${DOS_ROOT}/mwindows/vgadib.3g_
		chown  bin ${DOS_ROOT}/mwindows/vgadib.3g_
		chgrp  bin ${DOS_ROOT}/mwindows/vgadib.3g_
		chmod  664 ${DOS_ROOT}/mwindows/vgadib.3g_
	fi

	# At this point "dosinstall" is done (just need to have
	# the images made).  So tell the world we that dosinstall
	# is done, by removing the special files in ${VARM}
	rm -f ${VARM}/doing_dosinst ${VARM}/auto_dosinst

	#  Make all the images
	$TRC "About to make images." >> $TRACE
	[ $DOSINSTALLTRACE -eq 2 ] && Trace_df before_mkimg
	if [ "x$MINIMAL_INSTALL" = "x" ]
	then
		mkimg
	else
		mkimg mono
	fi
	[ $DOSINSTALLTRACE -eq 2 ] && Trace_df after_mkimg
	if [ "x$MINIMAL_INSTALL" != "x" ]
	then
		if [ -f ${VARM}/image/std/mono/mono.img ]
		then
			# Done with minimal install, so just finish now.
			EXIT_NOW 0
		fi
		# DOS is installed, but image file did not get made.
		usrMsg ERROR DOSINST_MKIMG_FAILED \
"Failed to make all DOS image files.\n\
     Installation of DOS partialy failed.\n"
		EXIT_NOW 1
	fi
	if [ -f ${VARM}/image/std/mono/mono.img  -a \
	     -f ${VARM}/image/std/cga/cga.img ]
	then
		# Determine and print out the version of DOS we just installed.
		DVER=`dos $KOPT +b -e -p -r ver \
			| $STATICMERGE/charconv -d -x -z \
			| sed -e'/^$/d'`
		Echo $DVER
		case "$DVER" in
		*4.90.3*)
			# This is winME 1st Edition dos 8.0
			WDOS_VER=MEDOS80
			;;
		*4.10.2*)
			# This is win98 2nd Edition dos 7.1
			WDOS_VER=98DOS71
			;;
		*4.10.1998*)
			# This is win98 dos 7.1
			WDOS_VER=98DOS71
			;;
		*4.00.111*)
			# This is dos 7.1
			WDOS_VER=DOS71
			;;
		*4.00.950*)
			# This is dos 7.0
			WDOS_VER=DOS70
			;;
		*Windows*)
			# Some unknown version of DOS for Win95 or later.
			# We don't know how well this version will work
			# with windows with Merge.  So we warn the user
			# and mark it as a Non-win95 compatible DOS.
			usrMsg ERROR DOSINST_DOS_UNKNOWN \
"Unrecognized version of DOS.\n\
DOS or Windows may not work entirely properly\n"
			WDOS_VER=OLDDOS
			;;
		*)
			WDOS_VER=OLDDOS
			;;
		esac
		echo "WDOS_VER=\"$WDOS_VER\"" >> ${DOSROOTDOS}/version.dos
	else
		# DOS is installed, but image file(s) did not get made.
		usrMsg ERROR DOSINST_MKIMG_FAILED \
"Failed to make all DOS image files.\n\
     Installation of DOS partialy failed.\n"
		EXIT_NOW 0
	fi
fi

usrMsg ECHO DOS_INST_DONE "DOS installation completed.\n"
EXIT_NOW 0
