# request script for Wabi 2.1  AnswerBook.
# created by mkdv2pkg.ksh @prototype-build-time
ABrelease=49
AB_Home=SUNWaws
ABissue=3
AB_OS=5
AB_Type=UBAB
AB_Name="Wabi 2.1 AnswerBook"
AB_Pkg_Name=SUNWaws

export ABrelease ABissue AB_OS AB_Install_Type AB_Type AB_Pkg_Name AB_Name
SizeOfIndex=234496
SizeOfContentsDB=352256
SizeOfPostScript=2973696
# 
###
# 
# --- above this line is code generated at the end of MakeABPackage.ksh
# --- the fixed part of the request script:
#
trap 'exit 3' 15

# If the pkg*  supplied mount point is available, use it.

Distrib=""

export Distrib

if [ "$INST_DATADIR" != ""  -a "$INST_DATADIR" != "/" ]
then
	Distrib="$INST_DATADIR"

fi
while  [ ! -d ${Distrib}/${AB_Pkg_Name} ]
do
	Distrib=`ckpath -Qaroy -p "Enter the mount point of the ${AB_Pkg_Name} AnswerBook cdrom:"`
	if [ ! -d ${Distrib}/${AB_Pkg_Name} ]
	then
		echo "Can't find the ${AB_Pkg_Name} AnswerBook package under $Distrib !"
	else
		break
	fi
done

#
#+scope 11-93 find out whether the reloc tree is available or is in a compressed
#             archive

    # assume compressed:
    RELOC_COMPRESSED="true"
 
    # check for other case:
    if [ -d ${Distrib}/${AB_Pkg_Name}/reloc ]
    then
        RELOC_COMPRESSED="false"
    fi
    export RELOC_COMPRESSED
#-scope

SizeOfnil=10000
SizeOfmedium=`expr ${SizeOfIndex} + ${SizeOfContentsDB} `
SizeOfheavy=`expr ${SizeOfmedium} + ${SizeOfPostScript}`

if [ "$RELOC_COMPRESSED" = "false" ]
then
	echo ""
	echo "The installation options are as follows: "
	
	echo "Option:\tDescription:"
	echo "--------------------------------------------"
	echo "1. nil:    less than 1 Megabyte disk space required [slowest performance]."
	value=`echo ${SizeOfheavy} |nawk '{x=(0.0 + $0)/1048576.00;printf("%6.2f\n", x);exit}'`
	echo "2. heavy:  ${value} Megabytes disk space required [best performance]."
	echo ""
        echo "Note: If the install option which you choose below fails" 
        echo "      due to lack of space, try another location, or "
        echo "      choose a lower install option number." 
        echo "" 

	echo "Enter the number of an installation option from the list above (1 or 2)."
	echo ""
	
	optnum=`ckkeywd -Q -d 2 -p "Select an installation option:" 1 2 `
	
	case  "$optnum"
	in
		1) opt="nil"  ;;
		2) opt="heavy" ;;
	esac

	echo "Installation option: ${opt} selected."
else
    opt="heavy"
fi

#
#+scope 9-93 condition behavior on value of pkginfo var AB_INSTALL_MODE
#     If AB_INSTALL_MODE=1 , first member of install path must be BASEDIR value.#
 

# if this AnswerBook is to be installed in a fixed location,
# ABTOP will be set here:

ABTOP=""

if [ "$ABTOP" = "" -a ! "$AB_INSTALL_MODE" -eq 1 ]
then
	echo ""
	echo "The next request for input asks you to specify the parent directory of AnswerBook"
	echo "Make sure to choose a parent directory on a file system big enough to"
	echo "accommodate all the files to be moved for the INSTALL OPTION you selected."
	echo ""
	
	
	
	ABTOP=`ckpath -d /opt -Qaoyw \
	-p "Specify the parent of the AnswerBook home directory:"`

	# the default value is not validated by ckpath so:

	if [ ! -d "$ABTOP" ]
	then
		echo "\tERROR: Pathname does not exist."
		ABTOP=`ckpath -Qaoyw \
		-p "Specify the parent of the AnswerBook home directory:"`
	fi

else
	ABTOP=$BASEDIR
fi

#
#-scope


# N.B. either in the request script or preinstall or in pkginfo (WOS cases),
# ABHOME must be exported to the package environment so that the startup in
# /usr/openwin/bin can find the cardcatalog via the pkgparam command lookup of
# the final value of ABHOME.  This is always accomplished via a pkgadd protocol
# which writes env. varaviable names and values to the file whose name is the
# first argument with which pkgadd invokes preinstallation-time scripts.
# (see the end of the script for the 'export' of ABHOME.
# This is the value of ABHOME which will be exported:

ABHOME=${ABTOP}/${AB_Home}

# we don't need a fall through in the case stmt because ckkeywd forces the choice.

case "${opt}"
in
	nil)
		INSTALL_CASE=nil
		CLASSES="none"
		IndexDEST=${Distrib}/${AB_Pkg_Name}/reloc/IndexDEST
		ContentsDBDEST=${Distrib}/${AB_Pkg_Name}/reloc/ContentsDBDEST
		PostScriptDEST=${Distrib}/${AB_Pkg_Name}/reloc/PostScriptDEST;;
	heavy)
		INSTALL_CASE=heavy
		IndexDEST=${ABHOME}/index
		ContentsDBDEST=${ABHOME}/toc
		PostScriptDEST=${ABHOME}/ps
		CLASSES="none Index ContentsDB PostScript" 
		echo " For the heavy option all files will be placed under ${ABHOME}. "  ;;
esac


# here we write shell assignments to pkgadd/request's mysterious $1  
# in order that the encapsulating pkgadd code places them in the
# "packaging environment"

# Create the output file with the CLASSES assignment:

echo "CLASSES=${CLASSES}" > $1

# append until done:

# write the handles to the source and target dirs:

echo "Distrib=${Distrib}" >> $1
echo "ABHOME=${ABHOME}" >> $1
echo "ABTOP=${ABTOP}" >> $1
echo "INSTALL_CASE=${INSTALL_CASE}" >> $1
echo "ABrelease=${ABrelease}" >> $1
echo "ABissue=${ABissue}" >> $1
echo "AB_OS=${AB_OS}" >> $1
echo "AB_Type=${AB_Type}" >> $1
echo "AB_Install_Type=${AB_Type}" >> $1
echo "AB_Pkg_Name=${AB_Pkg_Name}" >> $1
echo "AB_Name=${AB_Pkg_Name}" >> $1

#9-93:
echo "RELOC_COMPRESSED=${RELOC_COMPRESSED}" >> $1
 
# write the rest of the assignments:

for class in $ALL_CLASSES
do
        echo "${class}DEST="`eval echo '$'${class}DEST`  >> $1
done



exit 0
