trap 'exit 3' 15

# January 1997 eks : a request script supporting 
# NIL_HEAVY interactive install option for AB2 packages

## Finding the data on the CD:
#  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}/${PKG} ]
do
	Distrib=`ckpath -Qaroy -p "Enter the mount point of the ${PKG} AnswerBook cdrom:"`
	if [ ! -d ${Distrib}/${PKG} ]
	then
		echo "Can't find the ${PKG} AnswerBook package under $Distrib !"
	else
		break
	fi
done

#
# 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}/${PKG}/reloc ]
    then
        RELOC_COMPRESSED="false"
    fi
    export RELOC_COMPRESSED


if [ "$RELOC_COMPRESSED" = "false" ]
then
	echo ""
	echo "The installation options are as follows: "
	
	echo "Option:\tDescription:"
	echo "--------------------------------------------"
	echo "1. nil:    leave data on cdrom, but update AB2 Catalog for cdrom access."
	echo "2. heavy:  add the complete package to the system and update the AB2 Catalog."
	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
	echo ""
	echo "The data for this AnswerBook2 Collection are compressed on the CD"
	echo "Therefore you cannot do a NIL install on this AB2 package."
	echo "Setting AB2 Collection Installation option to HEAVY ."

	opt="heavy"
fi


#sollicit the install path if it is a a heavy install:

COLL_PARENTDIR=""

echo ""
echo "The following request for input asks you to specify"
echo "the parent directory of this AnswerBook2 Collection."
echo ""

COLL_PARENTDIR=`ckpath -d /opt -Qaoyw \
-p "Specify the parent path of this AnswerBook2 Collection directory:"`

if [ "${COLL_PARENTDIR}" != "/" ]
then
        AB2INSTALLDIR=${COLL_PARENTDIR}/${ABHOME}
else
        AB2INSTALLDIR=/${ABHOME}
fi

if [ "$opt" = "heavy" ]
then
	AB2DATADIR=$AB2INSTALLDIR
	CLASSES="none Main CONFIG"
else
	CLASSES="none CONFIG"
	AB2DATADIR=${Distrib}/${PKG}/reloc/AB2INSTALLDIR
fi

# 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 "CLASSES=${CLASSES}" >> $1
echo "Distrib=${Distrib}" >> $1
echo "ABHOME=${ABHOME}" >> $1
echo "COLL_PARENTDIR=${COLL_PARENTDIR}" >> $1
echo "AB2INSTALLDIR=${AB2INSTALLDIR}" >> $1
echo "AB2DATADIR=${AB2DATADIR}" >> $1
echo "RELOC_COMPRESSED=${RELOC_COMPRESSED}" >> $1
 
# write the rest of the assignments:

exit 0
