#!/bin/sh
#############################################################################
#
#	Copyright (C) Cadence Design Systems, Inc. All rights
#	reserved.  Unpublished -- rights reserved under the
#	copyright laws of the United States of America.
#
#			RESTRICTED RIGHTS LEGEND
#	Use, duplication, or disclosure by the Government is subject
#	to restrictions as set forth in subparagraph (c)(l)(ii) of 
#	the Rights in Technical Data and Computer Software clause 
#	at DFARS 52.227-7013.
#
#			Cadence Design Systems, Inc.
#			555 River Oaks Parkway
#			San Jose, CA 95134	USA
#
#############################################################################
BOURNE=/bin/sh
XTERMPATH=/usr/bin/X11
XTERMBIN=xterm
XTERMOPTS="-T 'SoftLoad 6.0 Console' -fn 9x15  -sl 200 -g 80x40+0+0 -bg \#e0e0e0 -fg \#800000 -sb -e ${BOURNE} softload_GUI"
sysPATH=/bin:/usr/bin:/usr/ucb:$XTERMPATH

jsr=''

Clear() {
    clear		2>/dev/null	#beware of bad termcap entry
}

Page() {
    TERM=vt100 MORE=""  more		#make sure we don't clear screen
}

EchoN() {
    echo  "$*\c"
}

Beep() {
    tput bel		2>/dev/null
}


LoginName() {	# who'd you log in as
    who am i | sed -e 's/[ 	].*//' -e 's/.*\!//'
}

UserName() {
    whoami
}





Affirmative() {
    while : ; do
	read Affirm
	case $Affirm in
	    [yY]*) return 0 ;;
	    [nN]*) return 1 ;;
	    *)     $jsr EchoN "Please press y (yes) or n (no) : " ;;
	esac
    done
}

Proceed() {
    test "X$1" = 'X-q' || $jsr EchoN "Press [Return] to proceed, q to quit : "
    while : ; do
	read proc < /dev/tty
	case $proc in
	    "")    return 0 ;;
	    [qQ]*) return 1 ;;
	    *) 	   $jsr EchoN "Press [Return] to proceed, q to quit : " ;;
	esac
    done
}


Dirname() {					#print argument minus leaf, or .
    case $1 in
	*/* )	echo $1 | sed 's@/[^/]*$@/@' ;;
	*)	echo "." ;;
    esac
}

Leafname() {					#print leaf
    case $1 in
	*/* )	echo $1 | sed 's@.*/@@' ;;
	*)	echo $1 ;;
    esac
}

Fullpath() {					#print rooted path to arg dir
    ( cd $1 && /bin/pwd |
	sed 's@^/tmp_mnt/@/@' )			#print automount access dir
}

Dirpath() {					#print rooted path to arg - leaf
    $jsr Fullpath `$jsr Dirname $1`
}

Suffix() {
    echo $1 | sed -n 's@.*\.@@p'
}

Prefix() {
    echo $1 | sed 's@\.[^.]*$@@'
}


FlInfo() {
    /bin/ls -ldL $*  |
	sed -e 's@^\(..........\)\([^ 	]\)@\1 \2@'	\
	    -e 's@^L@l@' -e 's@^D@d@' -e 's@^F@-@'
}
	
FlOwner() {
    $jsr FlInfo $* | awk '{print $3}'
}

FlGroup() {
    $jsr FlInfo $* | awk '{print $4}'
}

FlSize() {
    $jsr FlInfo $* | awk '{print $5}'
}

LinkName() {
    $jsr FlInfo $* | awk '{print $11}'
}

IsSymLink() {
    $jsr FlInfo $1  2>/dev/null | grep '^l' 1>/dev/null
    return $?
}


DirentExists() {		#non-referencing symLinks included
    test -d $1 -o -f $1 || $jsr IsSymLink $1
    return $?
}
	
FlsNewer() {
    than=`echo $1 | sed 's@[/.]@\\\\&@g'`	#stick in backslashes to escape
    {
	echo ""					#in case none newer
	/bin/ls -Ldtr $* 
    } | sed -e '1,/^'$than'$/d' -e '/^'$than'$/d'
}

FlsOlder() {
    than=`echo $1 | sed 's@[/.]@\\\\&@g'`	#stick in backslashes to escape
    {
	echo ""					#in case none older
	/bin/ls -Ldt $* 
    } | sed -e '1,/^'$than'$/d' -e '/^'$than'$/d'
}

OSvendor=ibmrs
OSarchs=$OSvendor

LegalVendor() {
    test "`uname`" = AIX
    return $?
}


CheckPerms() {

    Proot=$1

    #
    # Verify that installer isn't root and owns the pseudo-root
    #
    me=`$jsr UserName`
    if [ "$me" = "root" ]; then
	echo "
Warning: Software administration should not be done as root
because it could cause file permissions problems while
extracting software"	1>&2
        $jsr Proceed || return 1
    fi

    owner=`$jsr FlOwner $Proot`
    if [ "$me" != "$owner" ]; then
        
	echo "
Warning: $me is not the owner of 
$Proot
$me may not have the required write permissions.
" 1>&2

        $jsr Proceed || return 1

        dirs="$Proot${NL}$Proot/install${NL}$Proot/install/tmp${NL}$Proot/install/pkgs${NL}$Proot/install/pdts"

        for i in `echo $dirs`; do
          touch $i/checkfile 2> /dev/null
          if [ $? -ne 0 ]; then
           echo "
Error: $me needs to have write permissions for these directories
$dirs
"    1>&2
           return 1
          fi  
          rm -f $i/checkfile
        done
          
    fi

    return 0
}



tapeDev=/dev/rmt0


MAXTARBSZ=20

HostAddress() {			# if error, no address printed
    /etc/arp $1 |\
        sed -n 's#.*(\(.*\)).*#\1#p'
}

HostAlive() {			# successful if supplied host responds to ping
    /etc/ping      $1 64 2	2>/dev/null \
       | sed -n '$p' | grep '^round-trip ' 1>/dev/null
    return $?
}

Rsh() {
    read=false
    write=false
    hostPlat=false
    case $1 in
	-r) read=true
	    shift;;
	-w) write=true
	    shift;;
	-rw|-wr)
	    read=true
	    write=true
	    shift;;
        -p)
	    hostPlat=true
            shift
            ;;
    esac
    rshHost=$1;	shift

    rsh=rsh

    if $hostPlat ; then
      host_plat=`eval $rsh $rshHost uname -s`
      case $host_plat in
        SunOS ) echo sun    #Do not bother about sun4v or sun4
            return 0;;
        AIX) echo ibmrs
            return 0;;
        HP-UX) echo hppa
            return 0;;
        IRIX) echo sgi
            return 0 ;;
        *) echo UNKNOWN
           return 1;;
      esac
    fi
    
    if $read ; then
	stdin=""
    else
	stdin="</dev/null"
    fi

    if $write ; then
	cmnd="$BOURNE -c '$*; echo \$? > /tmp/rsh$$'"
	eval $rsh $rshHost '$cmnd' $stdin
	rshStatus=\
`$rsh $rshHost "$BOURNE -c 'cat /tmp/rsh$$; rm -f /tmp/rsh$$'" </dev/null` 
    else
	cmnd="$BOURNE -c '$* >/dev/null; echo \$?'"
	rshStatus=`eval $rsh $rshHost '$cmnd' $stdin`
    fi
    test "X$rshStatus" = 'X' && rshStatus=1	#return failure
    return $rshStatus
}


IsRTapeDev() {		#return success if arg 'could be' a rewind tape dev
    case $1 in
        /dev/rmt/0?*bn) return 1;;
        /dev/rmt/0?*b)  return 0;;
	/dev/rmt/?*n) 	return 1;;
	/dev/rmt/?*) 	return 0;;
        /dev/nrtape)    return 1;;
        /dev/rmt[0123456789])      return 0;;
        /dev/?*.[246])  return 0;;
        /dev/?*.?)      return 1;;
        /dev/r[sm]t?*)  return 0;;
        /dev/n?*)       return 1;;
        /dev/?*)        return 0;;
	*)		return 1;;
    esac
}

IsNTapeDev() {		#return success if arg 'could be' a Nrewind tape dev
    case $1 in
        /dev/rmt/0?*bn) return 0;;
	/dev/rmt/?*n) 	return 0;;
	/dev/nrtape)	return 0;;
        /dev/?*.[1357]) return 0;;
        /dev/nr?*)      return 0;;
        /dev/n?*)       return 0;;
	*)		return 1;;
    esac
}


IsTapeDev() {		#return success if arg 'could be' local/remote tape dev
    devName=`echo $1 | sed 's@.*:@@'`
    $jsr IsRTapeDev "$devName" || $jsr IsNTapeDev "$devName"
    return $?
}


NTapeDevName() {	#print name of Nrewind tapedev corresponding to argument
       case $1 in
          /dev/rmt/0?*bn) echo $1 
                          return 0;;  #Can get rid of first 2 lines
          /dev/rmt/0?*b)  echo $1 | sed 's@b@bn@'
                          return 0 ;;
	  /dev/rmt/?*) 	  echo $1 | sed 's@[^n]$@&n@'
                          return 0 ;;
          /dev/*.2)       echo $1 | sed 's@2$@3@' 
                          return 0 ;;
          /dev/*.4)       echo $1 | sed 's@4$@5@' 
                          return 0 ;;
          /dev/*.6)       echo $1 | sed 's@6$@7@' 
                          return 0 ;;
          /dev/*.[1357])  echo $1
                          return 0 ;;
          /dev/rmt[0123456789]*)      echo "$1.1"
                          return 0 ;;
          /dev/n?*)       echo $1 
                          return 0;;
          /dev/r[sm]t?*)  echo $1 | sed 's@^/dev/@/dev/n@'
                          return 0 ;;
          * )             echo $1
                          return 1;;
       esac

}

RTapeDevName() {	#print name of rewind tapedev corresponding to argument
    case $1 in
       /dev/rmt/0?*b)  echo $1
                          return 0 ;;
       /dev/rmt/0?*bn) echo $1 | sed 's@bn@b@'
                          return 0 ;;
       /dev/rmt/*)     echo $1 | sed 's@n@@'
                          return 0 ;;
       /dev/*.1)       echo $1 | sed 's@.1$@@'
                          return 0 ;;
       /dev/*.3)       echo $1 | sed 's@3$@2@'
                          return 0  ;;
       /dev/*.5)       echo $1 | sed 's@5$@4@'
                          return 0  ;;
       /dev/*.7)       echo $1 | sed 's@7$@6@' 
                          return 0 ;;
       /dev/*.[246])   echo $1
                          return 0 ;;
       /dev/rmt[0123456789]*)      echo $1
                          return 0 ;;
       /dev/r[sm]t?*)  echo $1
                          return 0 ;;
       /dev/n?*)       echo $1 | sed 's@^/dev/n@/dev/@'
                          return 0 ;;
       * )              echo $1 
                          return 1 ;;
   esac

}

#This did not work for the -v flag. Fixed it so that it works fine
#now



Fgrepf() {		# fgrep -v filename
    vset=false
    Util="fgrep"
    opts=
    while test $# -gt 0 ; do
       case $1 in
          -egrep)
               Util="egrep"
               shift;;
          -v)
               opts="$opts `expr X$1 : '.\(.*\)'`"
               shift
               vset=true;;
          -*)
               opts="$opts `expr X$1 : '.\(.*\)'`"
               shift;;
           *)  break;;
       esac
    done

    patFl=$1
    srcFl=$2

    split -25 $patFl /tmp/split$$_

    for pat in /tmp/split$$_* ; do
      if $vset; then
       count=0
       $Util $opts -f $pat $srcFl > /tmp/srcTFL$$
       srcTFL="/tmp/srcTFL$$"
       for pat1 in /tmp/split$$_* ; do
        count=`expr $count + 1`
        $Util $opts -f $pat1 $srcTFL > /tmp/srcFL${count}$$
        srcTFL="/tmp/srcFL${count}$$"
        echo $count > /tmp/count$$
       done
       if [ -s /tmp/count$$ ]; then
        read count < /tmp/count$$
       fi  
       cat /tmp/srcFL${count}$$ | sort -n | uniq >> /tmp/resFL$$
       while [ "$count" -gt 0 ]; do
         rm -f /tmp/srcFL${count}$$
         count=`expr $count - 1`
       done
       rm -f /tmp/srcTFL$$
      else
        $Util $opts -f $pat $srcFl
      fi
    done | sort -n | uniq
    if $vset; then
      cat /tmp/resFL$$ | sort -u | sort -n | uniq
    fi
    rm -f /tmp/resFL$$ /tmp/count$$ /tmp/split$$_* 
    
}


mediaBlocking=$MAXTARBSZ
NL="
"
test -z "$Rm" && Rm="/bin/rm -f";       export Rm

CALLCRC="${NL}Call the Cadence Customer Response Center (CRC) at 1-800-Cadenc2 ${NL} (1-800-223-3622) for assistance."


Exit()
{
   status=$1; shift
   files="$*"
   for file in $files; do
      test -f $file && rm $file
   done
   exit $status
}

saveWO()
{
  wo=`cat ${tmpdir}/workorder.${InstPlat}`
  tarFName="${tmpdir}/cdsWO#${wo}#${InstPlat}#tar"
  mv $tmpdir/$cdsWorkOrder $tarFName

 }

checkPlat()
{
  if [ -s ${tmpdir}/platforms ]; then
  if  grep "${InstPlat} " ${tmpdir}/platforms 2>/dev/null 1>&2;  then
    :
  else
    $jsr EchoN "${NL}Unsupported platform: ${InstPlat} ${NL}"
    $jsr EchoN "${NL}Platforms currently supported are: ${NL}"
    awk '{print $1 }' ${tmpdir}/platforms 
    exit 1
  fi
  fi
}

Intr_Clean () {
   echo "${NL}Cleaning up...${NL}"
   rm -f ${tmpdir}/ctl_files_xtract*
   rm -f ${tmpdir}/tmpfl*
   rm -f ${tmpdir}/awk* ${tmpdir}/dels* ${tmpdir}/load* ${tmpdir}/pkginfo.ld*
   rm -f ${tmpdir}/totalSize* ${tmpdir}/mediaLoc*
   rm -f /tmp/df*
}

softload_trap()  {

    echo ""
    echo "${NL}Current operation interrupted."
    echo "${NL}Type 'exit' to quit, anything else to proceed."
    echo "(Not all operations will continue from the point of interruption)"
    read byebye
    if [ "X$byebye" = "Xexit" ]; then
      $jsr Intr_Clean
      Exit 0 
    fi
}


  

trap softload_trap 2

legalNotice="
                               WELCOME TO THE

                        CADENCE INSTALLATION UTILITY,

                                SOFTLOAD 6.0

Copyright (c) 1996-1998 Cadence Design Systems, Inc.  All Rights 
Reserved. Unpublished -- rights reserved under the copyright laws 
of the United States.
Copyright (c) 1996-1998 UNIX Systems Laboratories, Inc.  Reproduced 
with Permission.

THIS SOFTWARE AND ON-LINE DOCUMENTATION CONTAIN CONFIDENTIAL INFORMATION
AND TRADE SECRETS OF CADENCE DESIGN SYSTEMS, INC.  USE, DISCLOSURE, OR
REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF
CADENCE DESIGN SYSTEMS, INC.

RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to
restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
Technical Data and Computer Software clause at DFARS 252.227-7013 or
subparagraphs (c)(1) and (2) of Commercial Computer Software -- Restricted
Rights at 48 CFR 52.227-19, as applicable.

"

export legalNotice
useGUI=true  export useGUI
softloadVersion=0 export softloadVersion
test "X$XTERM" = "X" && {
  test "X$PATH" != "X" && {
    pathParts=`echo $PATH | sed -e 's?:? ?g'`
    for part in $pathParts; do
      if test -x $part/$XTERMBIN; then
        XTERM=$part/$XTERMBIN; export XTERM
        break
      fi
    done
  }	
}



CDS_USR_PATH="$PATH"    export CDS_USR_PATH
PATH=$sysPATH;    	export PATH
sselection=1;            export sselection


# Why do this twice?  Glad you asked - it's because the first time we did it,
# it was before we explicitely set the PATH, giving the opportunity for finding
# the xterm binary in the user's path.  *Now* we're trying to find it in the
# path that we just set in the instruction above, if we didn't find it before.
test "X$XTERM" = "X" && {
  test "X$PATH" != "X" && {
    pathParts=`echo $PATH | sed -e 's?:? ?g'`
    for part in $pathParts; do
      if test -x $part/$XTERMBIN; then
        XTERM=$part/$XTERMBIN; export XTERM
        break
      fi
    done
  }	
}
umask 000



usagestr="usage:
    softload [-ascii]
    softload [-pkg]
    softload -i <platform> [-pkg][pkgstr ...]
    softload -d <platform> [-pkg][pkgstr ...]
    softload -l <platform> [-pkg][-f] [-a] [-r] [host:]tapeDev[,[host:]dir ...] [pkgstr ...]
    softload -c <platform> [-pkg][-f] [-a] [-r] [host:]tapeDev[,[host:]dir ...] [pkgstr ...]
    softload -cd <platform> [-pkg][-f] [-a] [-r] [host:]tapeDev[,[host:]dir ...] [pkgstr ...]

    -ascii      : Use ASCII menuing rather than default GUI
    -pkg        : Specify installation down to package level, rather than at
                  the default product level
    -i          : List products
        <plat>  : The platform for which products are to be installed
                  sun4  for SUN OS 4.1.3
                  sun4v for Solaris
                  hppa  for HP-UX
                  ibmrs for AIX
        -pkg    : List packages
    -d          : Delete products
        <plat>  : The platform for which products are to be installed
                  sun4  for SUN OS 4.1.3
                  sun4v for Solaris
                  hppa  for HP-UX
                  ibmrs for AIX
        -pkg    : Delete packages
    -l          : Load products
        <plat>  : The platform for which products are to be installed
                  sun4  for SUN OS 4.1.3
                  sun4v for Solaris
                  hppa  for HP-UX
                  ibmrs for AIX
        -pkg    : Load packages
        -f      : Override disk space checking
        -a      : Load all packages/products (even if they are already loaded)
        -r      : Re-install failed products/packages only
    -c          : Load products form Cadence catalog
    -cd         : Load documents from documentation catalog
    -u          : Update hierarchy interactively
       <mnt pt> : Mount point of update CDROM #1
    -h          : This message"

export usagestr


pkgflag=
majOpt=$1
object=product
if [ "X$majOpt" = "X-ascii" ]; then
    useGUI=false
    shift
    export useGUI
    if [ $# -gt 0 ]; then
      $jsr EchoN "${NL}${usagestr}${NL}" | $jsr Page
      exit 1
    fi
elif [ "X$majOpt" = "X-pkg" ]; then
    useGUI=false
    export useGUI
    pkgflag="-pkg"; shift
    object=package
    if [ $# -gt 0 ]; then
      $jsr EchoN "${NL}${usagestr}${NL}" | $jsr Page
      exit 1
    fi
elif [ "X$majOpt" = "X-u" ]; then
    useGUI=false
    export useGUI
    if [ $# -ne 2 ]; then
      $jsr EchoN "${NL}${usagestr}${NL}" | $jsr Page
      exit 1
    fi
fi

export useGUI

cd `$jsr Dirname $0`		|| Exit 1
Proot=`$jsr Fullpath ../..` ; export Proot	# the pseudo-root 
tmpdir=$Proot/install/tmp
bin_dir=$Proot/install/bin.$OSvendor; export bin_dir 
device=$Proot/install/tmp/.device.log
process_file=$bin_dir/process_file
recordFile=$Proot/install/.cdsloadrc.$OSvendor
InstPlatFile=$tmpdir/cdsInstPlat


selprodfile=$tmpdir/selprodfile
$Rm $selprodfile

if [ $# -gt 0 ]; then  #{save command line arguments
  majOpt=$1
  case "$majOpt" in #{
    -l)  #-l option can be used only if control information has been 
         #merged with the all* files.
      if [ $# -lt 3 ]; then
        $jsr EchoN "${NL}${usagestr}${NL}" | $jsr Page
        exit 1
      fi
      Args=$*
      InstPlat=$2 
      $jsr checkPlat
      export InstPlat
      Plat=
      tempDev=
      tempPkg=
      for arg in $Args; do
        case "$arg" in
         -l | -[far] | -pkg )  ;;
         -* ) $jsr EchoN "${NL}Unrecognized option $arg ${NL}${usagestr}${NL}" | $jsr Page
           exit 1 ;;
         $arg$Plat)
            Plat=$arg ;;
         $arg$tempDev)
            case $arg in
              /* ) ;;
              *:/* ) ;;
              *) echo "${NL}Error: Media specification ($arg) must be fully rooted. ${NL} $usagestr ${NL}" | $jsr Page
                exit 1 ;;
            esac
            tempDev=$arg ;;
        * ) tempPkg="$tempPkg $arg" ;;
       esac
      done
    

      if [ -f $tmpdir/bundles.$InstPlat -a -f $tmpdir/pkginfo.$InstPlat \
         -a -f $tmpdir/mapinfo.$InstPlat -a -f $tmpdir/softloadVersion.$InstPlat \
         -a -f $tmpdir/mediaMap.$InstPlat ]; then  #{
                   checkControl=no; export checkControl
         Release=`head -1 $tmpdir/bundles.$InstPlat | awk '{ print $6 }'`
         export Release
      else
        echo "Use softload -ascii to extract installation information and then use this option"                      1>&2
        exit 1
      fi  #}

      mediaNum=1
      if $BOURNE $bin_dir/read_label $tempDev $mediaNum  > /tmp/label$$; then #{
        . /tmp/label$$
          if [ "X$updateUniq"  = "X" ]; then #{
            updateMedia=false
          else
            updateMedia=true
          fi #}
          mountedCD=$dataTapeset
          export mountedCD
          $Rm  /tmp/label$$
      fi #}

      ;;
    -c ) 
      if [ $# -lt 3 ]; then
        $jsr EchoN "${NL}${usagestr}${NL}" | $jsr Page
        exit 1
      fi
      Args=$*
      InstPlat=$2
      $jsr checkPlat
      export InstPlat
      catalog_flag="yes"
      export catalog_flag
      Plat=
      tempDev=
      tempPkg=
      for arg in $Args; do  #{
        case "$arg" in  #{
         -c | -[far] | -pkg )  ;;
         -* ) $jsr EchoN "${NL}Unrecognized option $arg ${NL}${usagestr}${NL}" | $jsr Page
           exit 1 ;;
         $arg$Plat)
            Plat=$arg ;;
         $arg$tempDev)
            case $arg in  #{
              /* ) ;;
              *:/* ) ;;
              *) echo "${NL}Error: Media specification ($arg) must be fully rooted. ${NL} $usagestr ${NL}" | $jsr Page
                exit 1 ;;
            esac  #}
            tempDev=$arg ;;
        * ) tempPkg="$tempPkg $arg" ;;
       esac  #}
      done  #}

        mediaSet="CDROM#1"
        mediaTxt="CD#1"
        mediaType="CDROM"
        mediaNum=1
        skipcheck_flag="skipcheck"
        tapedev=$tempDev
        if $BOURNE  $bin_dir/media_iface $$ open $tapedev $mediaSet $mediaNum $mediaType $skipcheck_flag ; then  #{
          #We read FS.0
          workDir=`pwd`
          mkdir /tmp/sl$$
          cd /tmp/sl$$
          if $BOURNE  $bin_dir/media_iface $$ xtract 0 ./install/tmp ; then #{
            allbundlesF=`/bin/ls /tmp/sl$$/install/tmp/allbundles.* 2>/dev/null`
            ctlbundlesF=`/bin/ls /tmp/sl$$/install/tmp/ctl_bundles.* 2>/dev/null`
            #Sample line out of the allbundles or ctl_bundles file
            #972:~SDLIN iccommonDoc95.04-p008 972 92808 sun4 9504

            if [ "X$allbundlesF" != "X" ]; then #{
              PlatF=`head -1 $allbundlesF | awk '{print $5}' | tr -d ' '`
              rel=`head -1 $allbundlesF | awk '{print $6}' | tr -d ' '`
            elif [ "X$ctlbundlesF" != "X" ]; then
              #ctl_bundles file can have lines
              PlatF=`cat $ctlbundlesF | awk ' { if (NF > 1) print $5 }' | sort -u`
              rel=`cat $ctlbundlesF | awk ' { if (NF > 1) print $6 }' | sort -u`
            elif [ -s ${tmpdir}/mksoftload.run ]; then
              PlatF=`cat ${tmpdir}/mksoftload.run`
              rel=`head -1 ${tmpdir}/allbundles.${PlatF} | awk '{print $6}'`
            else
              $jsr EchoN "${NL}Could not determine the platform or release${NL}from the files on CD#1."
              exit 1
            fi #}

            if [ "X$PlatF" = "X" -o "X$rel" = "X" ]; then #{
              $jsr EchoN "${NL}Could not determine the platform or release${NL}from the files on CD#1."
              exit 1
            else
              if [ -s $Proot/.FMrelease ]; then  #{
                CDS_Release=`head -1 $Proot/.FMrelease`
                if [ "X$CDS_Release" = "X$rel" ]; then #{
                  InstPlat=$PlatF ; export InstPlat
                  Release=$rel ; export Release
                else
                  $jsr EchoN "${NL}Error:The current installation hierarchy is for $CDS_Release release.${NL}CD#1 is for $rel release. ${NL}Cannot install $rel release in this hierarchy.${NL}"
                  exit 1
                fi #}
              else #If the .FMrelease file does not exist dont bother
                InstPlat=$PlatF ; export InstPlat
                Release=$rel ; export Release
              fi #}
            fi #}
              
          else #If extract fails
            $jsr $EchoN "${NL}Could not extract information from FS.0 of CD#1.${NL}Could not get platform or release information"
            exit 1
          fi #}

          cd $workDir
          $Rm -r /tmp/sl$$

          #If everything is OK here we show the README
          #and extract FS.0 into the installation hierarchy.

          cd $Proot
          $jsr EchoN "${NL}${NL}Extracting installation information from CD#1.${NL}"
          $BOURNE  $bin_dir/media_iface $$ xtract 0 ./install/tmp 
          cd $workDir

          $BOURNE $bin_dir/media_iface $$ close

        else  #If open media fails
          $jsr EchoN "${NL}Could not access CD#1 at $tapedev.${NL}"
          exit 1
        fi #}

      if [ -f $tmpdir/allbundles.$InstPlat -a -f $tmpdir/allpkginfo.$InstPlat \
         -a -f $tmpdir/allmapinfo.$InstPlat -a -f $tmpdir/allsoftloadVersion.$InstPlat \
         -a -f $tmpdir/allmediaMap.$InstPlat -a -f $tmpdir/allsourceMedia.$InstPlat ]; then  #{
                   checkControl=yes; export checkControl
                   sselection=4; export sselection
         Release=`head -1 $tmpdir/allbundles.$InstPlat | awk '{ print $6 }'`
         export Release
      else
        echo "Installation information for the catalog absent."                      1>&2
        exit 1
      fi  #}

      if $BOURNE $bin_dir/read_label $tempDev $mediaNum  > /tmp/label$$; then #{
           . /tmp/label$$
           if [ "X$updateUniq"  = "X" ]; then #{
             updateMedia=false
           else
             updateMedia=true
           fi #}
           mountedCD=$dataTapeset
           export mountedCD
           $Rm  /tmp/label$$
         if $updateMedia; then #{
           sselection=1; export sselection
         fi #}
      fi #}
      ;;
    -cd ) 
      if [ $# -lt 3 ]; then
        $jsr EchoN "${NL}${usagestr}${NL}" | $jsr Page
        exit 1
      fi
      Args=$*
      InstPlat=$2
      $jsr checkPlat
      export InstPlat
      catalog_flag="yes"
      export catalog_flag
      Plat=
      tempDev=
      tempPkg=
      for arg in $Args; do #{
        case "$arg" in  #{
         -cd | -[far] | -pkg )  ;;
         -* ) $jsr EchoN "${NL}Unrecognized option $arg ${NL}${usagestr}${NL}" | $jsr Page
           exit 1 ;;
         $arg$Plat)
            Plat=$arg ;;
         $arg$tempDev)
            case $arg in  #{
              /* ) ;;
              *:/* ) ;;
              *) echo "${NL}Error: Media specification ($arg) must be fully rooted. ${NL} $usagestr ${NL}" | $jsr Page
                exit 1 ;;
            esac #}
            tempDev=$arg ;;
         * ) tempPkg="$tempPkg $arg" ;;
        esac #}
      done  #}


        mediaSet="CDROM#1"
        mediaTxt="CD#1"
        mediaType="CDROM"
        mediaNum=1
        skipcheck_flag="skipcheck"
        tapedev=$tempDev
        if $BOURNE  $bin_dir/media_iface $$ open $tapedev $mediaSet $mediaNum $mediaType $skipcheck_flag ; then  #{
          #We read FS.0
          workDir=`pwd`
          mkdir /tmp/sl$$
          cd /tmp/sl$$
          if $BOURNE  $bin_dir/media_iface $$ xtract 0 ./install/tmp ; then #{
            allbundlesF=`/bin/ls /tmp/sl$$/install/tmp/allbundles.* 2>/dev/null`
            ctlbundlesF=`/bin/ls /tmp/sl$$/install/tmp/ctl_bundles.* 2>/dev/null`
            #Sample line out of the allbundles or ctl_bundles file
            #972:~SDLIN iccommonDoc95.04-p008 972 92808 sun4 9504

            if [ "X$allbundlesF" != "X" ]; then #{
              PlatF=`head -1 $allbundlesF | awk '{print $5}' | tr -d ' '`
              rel=`head -1 $allbundlesF | awk '{print $6}' | tr -d ' '`
            elif [ "X$ctlbundlesF" != "X" ]; then
              #ctl_bundles file can have lines
              PlatF=`cat $ctlbundlesF | awk ' { if (NF > 1) print $5 }' | sort -u`
              rel=`cat $ctlbundlesF | awk ' { if (NF > 1) print $6 }' | sort -u`
            elif [ -s ${tmpdir}/mksoftload.run ]; then
              PlatF=`cat ${tmpdir}/mksoftload.run`
              rel=`head -1 ${tmpdir}/allbundles.${PlatF} | awk '{print $6}'`
            else
              $jsr EchoN "${NL}Could not determine the platform or release${NL}from the files on CD#1."
              exit 1
            fi #}

            if [ "X$PlatF" = "X" -o "X$rel" = "X" ]; then #{
              $jsr EchoN "${NL}Could not determine the platform or release${NL}from the files on CD#1."
              exit 1
            else
              if [ -s $Proot/.FMrelease ]; then  #{
                CDS_Release=`head -1 $Proot/.FMrelease`
                if [ "X$CDS_Release" = "X$rel" ]; then #{
                  InstPlat=$PlatF ; export InstPlat
                  Release=$rel ; export Release
                else
                  $jsr EchoN "${NL}Error:The current installation hierarchy is for $CDS_Release release.${NL}CD#1 is for $rel release. ${NL}Cannot install $rel release in this hierarchy.${NL}"
                  exit 1
                fi #}
              else #If the .FMrelease file does not exist dont bother
                InstPlat=$PlatF ; export InstPlat
                Release=$rel ; export Release
              fi #}
            fi #}
              
          else #If extract fails
            $jsr $EchoN "${NL}Could not extract information from FS.0 of CD#1.${NL}Could not get platform or release information"
            exit 1
          fi #}

          cd $workDir
          $Rm -r /tmp/sl$$

          #If everything is OK here we show the README
          #and extract FS.0 into the installation hierarchy.

          cd $Proot
          $jsr EchoN "${NL}${NL}Extracting installation information from CD#1.${NL}"
          $BOURNE  $bin_dir/media_iface $$ xtract 0 ./install/tmp 
          cd $workDir

          $BOURNE $bin_dir/media_iface $$ close

        else  #If open media fails
          $jsr EchoN "${NL}Could not access CD#1 at $tapedev.${NL}"
          exit 1
        fi #}

      if [ -f $tmpdir/allbundles.$InstPlat -a -f $tmpdir/allpkginfo.$InstPlat \
         -a -f $tmpdir/allmapinfo.$InstPlat -a -f $tmpdir/allsoftloadVersion.$InstPlat \
         -a -f $tmpdir/allmediaMap.$InstPlat -a -f $tmpdir/allsourceMedia.$InstPlat ]; then  #{
          checkControl=yes; export checkControl
          sselection=5; export sselection
          Release=`head -1 $tmpdir/allbundles.$InstPlat | awk '{ print $6 }'`
          export Release
      else
        echo "Installation information for the catalog absent."                      1>&2
        exit 1
      fi  #}
      mediaNum=1
      if $BOURNE $bin_dir/read_label $tempDev $mediaNum  > /tmp/label$$; then #{
        . /tmp/label$$
          if [ "X$updateUniq"  = "X" ]; then #{
            updateMedia=false
          else
            updateMedia=true
          fi #}

          #We rely on this value
          #To determine how we are going to merge ctl_files.

          if $updateMedia; then
            sselection=7; export sselection
          fi 
          mountedCD=$dataTapeset
          export mountedCD
          $Rm  /tmp/label$$
      fi #}
      ;;
     -d | -i )
      if [ $# -lt 2 ]; then
        $jsr EchoN "${NL}${usagestr}${NL}" | $jsr Page
        exit 1
      fi
      Args=$*
      InstPlat=$2 
      $jsr checkPlat
      export InstPlat
      Plat=
      tempPkg=
      for arg in $Args; do  #{
        case "$arg" in  #{
         -d | -i | -pkg )  ;;
         -* ) $jsr EchoN "${NL}Unrecognized option $arg ${NL}${usagestr}${NL}" | $jsr Page
           exit 1 ;;
         $arg$Plat)
            Plat=$arg ;;
         * ) tempPkg="$tempPkg $arg" ;;
        esac  #}
      done  #}
      ;;
     -u ) #Now we extract FS.0 and move on to vld 
       #Set InstPlat, Release and move onto vld
       Args=$*
       tapedev=
       for arg in $Args; do  #{
         case "$arg" in  #{
           -u )  ;;
           -* ) $jsr EchoN "${NL}Unrecognized option $arg ${NL}${usagestr}${NL}" | $jsr Page
            exit 1 ;;
           $arg$tapedev)
             case $arg in  #{
               /* ) ;;
               *:/* ) ;;
               *) echo "${NL}Error: Media specification ($arg) must be fully rooted. ${NL} $usagestr ${NL}" | $jsr Page
                exit 1 ;;
             esac #}
             tapedev=$arg ;;
           * ) tempPkg="$tempPkg $arg" ;;
         esac  #}
       done  #}

       mediaSet="CDROM#1"
       mediaTxt="CD#1"
       mediaType="CDROM"
       mediaNum=1
       skipcheck_flag="skipcheck"
       if $BOURNE  $bin_dir/media_iface $$ open $tapedev $mediaSet $mediaNum $mediaType $skipcheck_flag ; then  #{
         #We read FS.0
         workDir=`pwd`
         mkdir /tmp/sl$$
         cd /tmp/sl$$
         if $BOURNE  $bin_dir/media_iface $$ xtract 0 ./install/tmp ; then #{
           allbundlesF=`/bin/ls /tmp/sl$$/install/tmp/allbundles.* 2>/dev/null`
           ctlbundlesF=`/bin/ls /tmp/sl$$/install/tmp/ctl_bundles.* 2>/dev/null`
           #Sample line out of the allbundles or ctl_bundles file
           #972:~SDLIN iccommonDoc95.04-p008 972 92808 sun4 9504

           if [ "X$allbundlesF" != "X" ]; then #{
             PlatF=`head -1 $allbundlesF | awk '{print $5}' | tr -d ' '`
             rel=`head -1 $allbundlesF | awk '{print $6}' | tr -d ' '`
           elif [ "X$ctlbundlesF" != "X" ]; then
             #ctl_bundles file can have lines
             PlatF=`cat $ctlbundlesF | awk ' { if (NF > 1) print $5 }' | sort -u`
             rel=`cat $ctlbundlesF | awk ' { if (NF > 1) print $6 }' | sort -u`
            elif [ -s ${tmpdir}/mksoftload.run ]; then
              PlatF=`cat ${tmpdir}/mksoftload.run`
              rel=`head -1 ${tmpdir}/allbundles.${PlatF} | awk '{print $6}'`
           else
             $jsr EchoN "${NL}Could not determine the platform or release${NL}from the files on CD#1."
             $jsr Exit 1
           fi #}

           if [ "X$PlatF" = "X" -o "X$rel" = "X" ]; then #{
             $jsr EchoN "${NL}Could not determine the platform or release${NL}from the files on CD#1."
             $jsr Exit 1
           else
             InstPlat=$PlatF ; export InstPlat
             Release=$rel ; export Release
           fi #}
             
         else #If extract fails
           $jsr $EchoN "${NL}Could not extract information from FS.0 of CD#1.${NL}Could not get platform or release information"
           $jsr Exit 1
         fi #}

         cd $workDir
         $Rm -r /tmp/sl$$

         #and extract FS.0 into the installation hierarchy.

         cd $Proot
         $jsr EchoN "${NL}${NL}Extracting installation information from CD#1.${NL}"
         $BOURNE  $bin_dir/media_iface $$ xtract 0 ./install/tmp 
         cd $workDir

         $BOURNE $bin_dir/media_iface $$ close

         if $BOURNE $bin_dir/read_label $tapedev $mediaNum  > /tmp/label$$; then #{
           . /tmp/label$$
           if [ "X$updateUniq"  = "X" ]; then #{
             updateMedia=false
           else
             updateMedia=true
           fi #}
           mountedCD=$dataTapeset
           export mountedCD
           $Rm  /tmp/label$$
         fi #}

       else  #If open media fails
         $jsr EchoN "${NL}Could not access CD#1 at $tapedev.${NL}"
         $jsr Exit 1
       fi #}


       checkControl=yes; export checkControl

       #If we are using a production CD to update an hierarchy
       #we use the cadence catalog option

       if $updateMedia; then #{
         sselection=6; export sselection
       else
         sselection=4; export sselection
       fi #}

       #We reset the Args to include the InstPlat so that the -u
       #option is the same as the rest of the options. Why we did
       #not change the softload -u <tapedev> option to 
       #softload -u <platform> <tapedev> as this meant changing
       #The SETUP_UPDT script.
       Args="-u $InstPlat $tapedev"
       ;;
     -h ) $jsr EchoN "${NL}${usagestr}${NL}"| $jsr Page
          exit 0
      ;;
      * ) $jsr EchoN "${NL}${usagestr}${NL}" | $jsr Page
          exit 1
      ;;
    esac  #}
   

  vldArgs="$Args"  #Pass the rest of arguments to vld as is

else
    majOpt=
fi  #}

$jsr LegalVendor || {
  $jsr EchoN "${NL}Error: executing $OSvendor version on unexpected architecture" 1>&2
  Exit 1
}


pdts=$Proot/install/pdts

#IF ownership not correct just exit

$jsr CheckPerms $Proot || exit 1 


vld="$BOURNE vld"

#Now we exec off vld for -pkg, -l, -c, -cd, -i, -d -u options

if [ "X$majOpt" != "X" ]; then  #{
  set -f  #disable filename generation
  useGUI=false
  export useGUI
  exec $vld $pkgflag $vldArgs
fi  #}

if $useGUI; then   #{
  if [ "X$XTERM" = "X" ]; then  #{
    useGUI=false; export useGUI
    $jsr EchoN "${NL}WARNING:  Could not find the '$XTERMBIN' executable in your path or the ${NL}          default path for this platform ($XTERMPATH) ${NL}          Reverting to ASCII mode."
  fi  #}
fi  #}


if $useGUI; then  #{
  XNLSPATH=$bin_dir/nls; export XNLSPATH
  XKEYSYMDB=$bin_dir/XKeysymDB; export XKEYSYMDB
  $BOURNE $bin_dir/toplevel.sh  -1 
  case $? in  #{
    249) 
      useGUI=false; export useGUI
      $jsr EchoN "${NL}Warning: Could not start SoftLoad in GUI mode.${NL}Reverting to ASCII mode."
      ;;
    0) 
      ;;
    *) 
      useGUI=false; export useGUI
      $jsr EchoN "${NL}Warning: Could not start SoftLoad in GUI mode.${NL}Reverting to ASCII mode."
      ;;
  esac  #}
fi  #}

if [ "X$useGUI" = "Xtrue" ]; then  #{The GUI Executables need them
  export BOURNE
  SoftStartDir=`pwd`; export SoftStartDir #For the E-mail file browser
fi  #}

if $useGUI; then  #{
  if [ "X$XTERM" = "X" ]; then  #{Use current xterm as status window
    $BOURNE softload_GUI
  else
    eval $XTERM $XTERMOPTS
  fi  #}
  Exit $?
fi  #}

# ASCII interface
echo "$legalNotice"
UNAVAILABLE="(unavailable option) "
info_menu=
emailFile=
level=1
default=2

DeviceTAPE=$tapeDev; export DeviceTAPE
  DeviceCD="/cdrom"; export DeviceCD

while [ ! -z "$level" ]; do  #{Keep on popping menu after menu
  options=
  choice=
  input=
  # Handle menu options ("grayed out" stuff)
  CONFIG_OPT=""; export CONFIG_OPT
  TEST_OPT=""; export TEST_OPT    
  LOAD_OPT=""; export LOAD_OPT  #Not reset later
  LIST_OPT=""; export LIST_OPT  #Not reset later
  REMOVE_OPT=""; export REMOVE_OPT  #Not reset later
  TAPE_LABEL=""; export TAPE_LABEL
  SYSCONF_OPT=""; export SYSCONF_OPT
  USERCONF_OPT=""; export USERCONF_OPT
  WORK_OPT=""; export WORK_OPT
  CADENCE_OPT=""; export CADENCE_OPT
  DOC_OPT=""; export DOC_OPT

  default=2    # e-mail is the default option.

  WorkOrder=


  #We just have to worry about the CONFIG and the TEST options. 
  #The other options are all available. Since they are now
  #dependent on the PLATFORM of the Installation Media
  #We only need the configure part when level is 1 or 1.4
  #We need the test part only when the level is 1.5
  
  if [ "X$level" = "X1" -o "X$level" = "X1.4" ]; then #{
    if $BOURNE chk_attr SYS_CONFIG ; then  #{
      : ; 
    else
      SYSCONF_OPT="$UNAVAILABLE"; export SYSCONF_OPT
      if $BOURNE chk_attr USER_CONFIG ; then  #{
        : ; 
      else
        USERCONF_OPT="$UNAVAILABLE"; export USERCONF_OPT
        CONFIG_OPT="$UNAVAILABLE"; export CONFIG_OPT
        default=1
      fi  #}
    fi  #}

    if $BOURNE chk_attr TEST_INSTALL ; then  #{
      : ; 
    else
      TEST_OPT="$UNAVAILABLE"; export TEST_OPT
    fi  #}

    rm -f $tmpdir/product.list      # clean up after chk_attr
  fi  #}



  rm -f $tmpdir/workorders
  ls $tmpdir/cdsWO*#tar 2> /dev/null > $tmpdir/workorders
  if [ -s $tmpdir/workorders ]; then  #{
    default=1  #Workorder the default 
  else
    WORK_OPT="$UNAVAILABLE"; export WORK_OPT
  fi  #}
           

  #display text between "LEVEL${level}" and nearest "LEVEL_END"
  echo "cat << EOMENU" > $tmpdir/menu$$
  sed -n -e '/^LEVEL'$level'$/,/^LEVEL_END$/!b' \
      -e '/^LEVEL/!p' menu_dat >> $tmpdir/menu$$
  echo "EOMENU" >> $tmpdir/menu$$
  echo ""
  echo ""
 
  . $tmpdir/menu$$ | $jsr Page
 
  rm -f $tmpdir/menu$$

  case $level in  #{Different Menu's pop up depending on level
    0)
      level=1
      ;;
    1) ;;
    1.6 | 1.1 )  #If we are updating or loading products

      #We get the mount point of CD#1
      #In case recordfile has been generated by mksoftload.


      MediaType=CDROM
      test -s $recordFile && . $recordFile
      case $MediaType in  #{
        CDROM)   tapedev=$DeviceCD;;
        TAPE)    tapedev=$DeviceTAPE;;
      esac  #}
        

      $jsr EchoN "${NL}${NL}        CD#1 of the media set being used is required.${NL}"
      while : ; do #{
        $BOURNE $bin_dir/getInstMedia $MediaType $DeviceCD 
        case $? in  #{
          0) break ;;   #success
          1)
            echo "${NL}The specified $mediaType device cannot be used."
            $jsr EchoN "Re-specify the device? [y/n]"
            $jsr Affirmative || level=1 ;; # try again, or fail
          255) level=1 
               break;; # quit and go back to installation menu
          *) level=1 
             break;; # quit and go back to main menu
        esac  #}
      done  #}
 
  
      if [ "X$level" != "X1" ]; then #{If we are backing off to main
        #We open the mounted media. Read its FS.0 and get the release
        #and platforms
        #Run recordfile this is created by getInstMedia

        test -s $recordFile && . $recordFile
        case $MediaType in  #{
          CDROM)   tapedev=$DeviceCD;;
          TAPE)    tapedev=$DeviceTAPE;;
        esac  #}
        

        mediaSet="CDROM#1"
        mediaTxt="CD#1"
        mediaType="CDROM"
        mediaNum=1
        skipcheck_flag="skipcheck"
        if $BOURNE  $bin_dir/media_iface $$ open $tapedev $mediaSet $mediaNum $mediaType $skipcheck_flag ; then  #{
          #We read FS.0
          workDir=`pwd`
          mkdir /tmp/sl$$
          cd /tmp/sl$$
          if $BOURNE  $bin_dir/media_iface $$ xtract 0 ./install/tmp ; then #{
            allbundlesF=`/bin/ls /tmp/sl$$/install/tmp/allbundles.* 2>/dev/null`
            ctlbundlesF=`/bin/ls /tmp/sl$$/install/tmp/ctl_bundles.* 2>/dev/null`
            #Sample line out of the allbundles or ctl_bundles file
            #972:~SDLIN iccommonDoc95.04-p008 972 92808 sun4 9504

            if [ "X$allbundlesF" != "X" ]; then #{
              PlatF=`head -1 $allbundlesF | awk '{print $5}' | tr -d ' '`
              rel=`head -1 $allbundlesF | awk '{print $6}' | tr -d ' '`
            elif [ "X$ctlbundlesF" != "X" ]; then
              #ctl_bundles file can have lines
              PlatF=`cat $ctlbundlesF | awk ' { if (NF > 1) print $5 }' | sort -u`
              rel=`cat $ctlbundlesF | awk ' { if (NF > 1) print $6 }' | sort -u`
            elif [ -s ${tmpdir}/mksoftload.run ]; then
              PlatF=`cat ${tmpdir}/mksoftload.run`
              rel=`head -1 ${tmpdir}/allbundles.${PlatF} | awk '{print $6}'`
            else
              $jsr EchoN "${NL}Could not determine the platform or release${NL}from the files on CD#1."
              level=1
            fi #}

            if [ "X$PlatF" = "X" -o "X$rel" = "X" ]; then #{
              $jsr EchoN "${NL}Could not determine the platform or release${NL}from the files on CD#1."
              level=1
            else
              if [ -s $Proot/.FMrelease ]; then  #{
                CDS_Release=`head -1 $Proot/.FMrelease`
                if [ "X$CDS_Release" = "X$rel" ]; then #{
                  InstPlat=$PlatF ; export InstPlat
                  Release=$rel ; export Release
                else
                  $jsr EchoN "${NL}Error:The current installation hierarchy is for $CDS_Release release.${NL}CD#1 is for $rel release. ${NL}Cannot install $rel release in this hierarchy.${NL}"
                  level=1
                fi #}
              else #If the .FMrelease file does not exist dont bother
                InstPlat=$PlatF ; export InstPlat
                Release=$rel ; export Release
              fi #}
            fi #}
              
          else #If extract fails
            $jsr $EchoN "${NL}Could not extract information from FS.0 of CD#1.${NL}Could not get platform or release information"
            level=1
          fi #}

          cd $workDir
          $Rm -r /tmp/sl$$

          #If everything is OK here we show the README
          #and extract FS.0 into the installation hierarchy.

          if [ "X$level" != "X1" ]; then #{
            cd $Proot
            $jsr EchoN "${NL}${NL}Extracting installation information from CD#1.${NL}"
            $BOURNE  $bin_dir/media_iface $$ xtract 0 ./install/tmp 
            cd $workDir
            if [ -s ${tapedev}/README ]; then #{
              $jsr EchoN "${NL}Do you want to view the README file?${NL}"
              $jsr EchoN "${NL}Please press y (yes) or n (no) : "
              if $jsr Affirmative; then  #{Show the README
                
                $jsr EchoN "${NL}${NL}#################################################${NL}This is the  readme file on CD#1.${NL}You can look this over or print it out for reference.${NL}${NL}Type [q] to quit reading or press the space bar ${NL}to read the next page.${NL}#################################################${NL}${NL}" > /tmp/read$$
   
                /bin/cat "${tapedev}/README"  >> /tmp/read$$
                /bin/cat /tmp/read$$ | $jsr Page
                if $jsr Proceed; then #{ 
                  :
                else
                  level=1
                fi #}
                $Rm /tmp/read$$

              fi #}#If the user wants to see the README
            fi #}If there is a README file
          fi #}If level=1

          $BOURNE $bin_dir/media_iface $$ close

        else  #If open media fails
          $jsr EchoN "${NL}Could not access CD#1 at $tapedev.${NL}"
          level=1
        fi #}

        if $BOURNE $bin_dir/read_label $tapedev $mediaNum  > /tmp/label$$; then #{
          . /tmp/label$$
          if [ "X$updateUniq"  = "X" ]; then #{
            updateMedia=false
          else
            updateMedia=true
          fi #}
          mountedCD=$dataTapeset
          export mountedCD
          $Rm  /tmp/label$$
        fi #}
      fi #}


      #If at this point still level is not 1

      if [ "X$level" != "X1" ]; then #{
        if [ "X$level" = "X1.1" ]; then #{
          level=1.1.1
          input="no"
        else
          level=1.6.1
          input="no"
        fi #}
      else
        input="no"
      fi #}
    ;;

    1.6.1) 
       checkControl=yes; 
       export checkControl # Check control info. for load option  only

       #If we are using production media to update an hierarhcy
       #then we use the cadence catalog option

       if $updateMedia; then #{
         sselection=6; export sselection
       else
         sselection=4; export sselection
       fi #}

       if [ ! -z "$InstPlat" ]; then  #{
         export InstPlat
         $vld -u 
         # return 255 means select previous menu 
         case $? in  #{
           255) 
             level="1.1.1" 
             input="no"
             ;;
           *) 
             level="1"
             input="no"
             ;;
         esac  #}
       else
         level="1"
       fi  #}
     ;;
    1.1.1)  #Pop Up the Where is the installation information MENU
      #default_install will be set to yes later by user for
      #email workorder or tape
      default_install="no"; export default_install 
      inchoice=
      input="no"
      getControlInfo="no"  #It will be set to yes if everything is OK
                           #If control information is good.

      #Get the installation information

      if [ -z "$inchoice" ]; then  #{No selection has been made
        if [ -z "$default" ]; then  #{
          $jsr EchoN "${NL}    Type your choice: "
        else
          $jsr EchoN "${NL}   Type your choice: [ $default ] "
        fi  #}
        read inchoice
      fi  #}

      #To take care of the default value i.e if the enter key is pressed

      if [ -z "$inchoice" ]; then  #{
        inchoice="$default"
      fi  #}

      case $inchoice in   #{ 
        2) #If the Installation Information is in an email 
          sselection=2; export sselection
          cdsWorkOrder=
          while : ; do  #{
            if [ "X$emailFile" != "X" ]; then  #{
              emailFile_def="$emailFile"
              $jsr EchoN "${NL}    Type the path to the e-mail file [$emailFile] : "
              read emailFile 
              if [ "X$emailFile" = "X" ]; then  #{
                emailFile="$emailFile_def"
              fi #}
            else
              $jsr EchoN "${NL}    Type the path to the e-mail file: "
              read emailFile 
            fi  #}

            tmpWorkOrder=
            default=2
                                 
            if [ ! -z "$emailFile" ]; then  #{
              $jsr EchoN "${NL}    Extracting installation information from $emailFile .....${NL}"
              tmpWorkOrder=`$bin_dir/cdsudp $emailFile`
              mystatus=$?

              case $mystatus in  #{Return Statuses from cdsudp
                0) #succeed
                  WorkOrder=`echo $tmpWorkOrder | sed 's@\.[^.]*\.[^.]*$@@'`
                  export WorkOrder
                  cdsWorkOrder="cds.$WorkOrder"; 
                  mv $tmpWorkOrder $tmpdir/$cdsWorkOrder
                  # uncompress, untar cds.workOrder file
                  cd $Proot
                  cat $tmpdir/$cdsWorkOrder | $bin_dir/io_fltr x | $bin_dir/vtar xpfB - ./install 
                  cd $bin_dir 
                  #Now we need to get the platform for which this
                  #control information is for. We rely on the
                  #presence of the file "cdsInstPlat" in ~/install/tmp
                  #That file must have the platform in it.

                  $jsr EchoN "${NL}    Extraction of installation information from $emailFile complete ${NL}"

                  if [ -s ${InstPlatFile} ]; then  #{
                    PlatF=`head -1 $InstPlatFile | awk '{ print $1}'`
                    if [ ! -z "$PlatF"  -a "X$InstPlat" = "X$PlatF" ]; then #{
                      if [ -f $tmpdir/ctl_bundles.${PlatF} -a \
                           -f $tmpdir/ctl_pkginfo.${PlatF} -a \
                           -f $tmpdir/ctl_mediaMap.${PlatF} ]; then #{
                        getControlInfo="yes"
                        cd $Proot
                        $jsr saveWO 
                        cd $bin_dir 
                      else
                       $jsr EchoN "${NL}Corrupted or incompatible installation information in $emailFile (ctl files) ${NL} ${CALLCRC}"
                       #getControlInfo is still "no" here
                      fi  #}
                    else
                      $jsr EchoN "${NL}Installation  platform not specified. ${NL}Wrong format of cdsInstPlat file in $emailFile ${NL}OR Installation information is for $PlatF platform. CD#1 is for $InstPlat platform. ${NL} ${CALLCRC}"
                    fi  #}
                  else
                    $jsr EchoN "${NL}    Corrupted or incompatible installation information in $emailFile (cdsInstPlat) ${NL} ${CALLCRC}"
                    #getControlInfo is still "no" here
                  fi  #}
                  break 
                  ;;   
                2 | 14 | 16) 
                  $jsr EchoN "${NL}    Type the path to the e-mail file again? [y/n] "

		  getControlInfo="no"
                  $jsr Affirmative || break 
                  ;;
                4 | 6 | 12)
                  $jsr EchoN "${NL}SL-3:Failed to decode e-mail file $emailFile ${NL}(Error:$mystatus)"
                  $jsr EchoN "${NL}    Unable to extract installation information from $emailFile  ${NL}    Verify that this file contains the mail message from Cadence ${NL}    and check whether you  have the necessary write permissions ${NL}    to install_dir ${NL}"
                  getControlInfo="no"
                  break 
                  ;;
                8 | 10 | 18 | 20 | 22 | 24)  #corrupted email file
                  getControlInfo="no"
                  $jsr EchoN "${NL}SL-4:Corrupted e-mail file $emailFile(Error:$mystatus)"
                  $jsr EchoN "${NL}    Unable to extract installation information from $emailFile  ${NL}    Verify that this file contains the mail message from Cadence ${NL}    and if this is the correct file, call the Cadence Customer ${NL}    Response Center (CRC) at 1-800-Cadenc2 (1-800-223-3622) ${NL}    for assistance. ${NL}"
                  break
                  ;; 
                *) 
                  getControlInfo="no"
                  $jsr EchoN "${NL}SL-5:Unable to extract installation information from $emailFile  $CALLCRC"
                  break ;;
              esac  #}End of Processing Status form cdsudp
	    else
              $jsr EchoN "${NL}    You have not typed the path to the e-mail file ${NL}"
            fi  #}Empty Email file name check
          done #}While loop to get the name of the Email file.
          ;;
        1) #Work order
          sselection=1; export sselection

          if [ "X$WORK_OPT" != "X" ]; then  #{
            #no workorder number available in tmp directory 
            getControlInfo="no"
            $jsr EchoN "${NL}    Unavailable option, reselect ...${NL}"
          else
            #If the workorders file is present 
            if [ -s $tmpdir/workorders ]; then  #{
              #The following awk lines will display a list of the 
              #available workorders

               awk -F# '{ print $2 " " $3 }' $tmpdir/workorders > $tmpdir/wo_$$
               file1="${tmpdir}/wo_$$"
               file2="${tmpdir}/platforms"

               awk '
                 FILENAME == "'$file1'" {
                   wo [ $1 " " $2 ] = $2
                 }
             
                 FILENAME == "'$file2'" {
                   for ( i=2; i<=NF; i++)
                     plat[$1]=plat[$1]" "$i;
                 }
                 END {
                   for ( item in wo ) 
                   {
                     a=split(item,entry, " ");
                     printf("%-20s%-26s\n", entry[1] ,plat[wo[ item ]]);
                   }
               }' $file1 $file2 > $tmpdir/wo1_$$

               rm -f $tmpdir/wo_$$
               echo " "
               echo "No.  Workorder #         Platform " 
               awk '{ printf ( "%2d) ",NR); print }
                END { printf("Select the workorder [ 1 - %d ]:",NR);
                }' $tmpdir/wo1_$$
              read lineNo
              lines=`wc -l < $tmpdir/wo1_$$`
              while : ; do  #{
                if [ "$lineNo" -ge 1 -a "$lineNo" -le "$lines" ]; then #{
                  break
                else
                  $jsr EchoN "${NL}        Type a number between 1 and ${lines}:"
                  read lineNo
                fi #}
              done  #} 

              wofile=`sed -n "${lineNo},${lineNo}p" $tmpdir/wo1_$$ | awk '{print $1}'` 
              Plat=`sed -n "${lineNo},${lineNo}p" $tmpdir/wo1_$$ | awk '{print $2}'`
              Plat1=`awk '{ if ($2 == "'$Plat'" ) print $1 }' $tmpdir/platforms`
              wofile="cdsWO#${wofile}#${Plat1}#tar"
              rm -f $tmpdir/wo1_$$

              if [ ! -z "$wofile" ]; then  #{
                wofile="${tmpdir}/${wofile}"
              fi  #}

              if [ -s $wofile ]; then #{
                cd $Proot
                cat $wofile |  $bin_dir/io_fltr x | $bin_dir/vtar xpfB - ./install
                cd $bin_dir
                if [ -s ${InstPlatFile} ]; then  #{
                  PlatF=`head -1 $InstPlatFile | awk '{ print $1}'`
                  if [ ! -z "$PlatF"  -a "X$InstPlat" = "X$PlatF" ]; then #{
                    if [ -f $tmpdir/ctl_bundles.${PlatF} -a \
                         -f $tmpdir/ctl_pkginfo.${PlatF} -a \
                         -f $tmpdir/ctl_mediaMap.${PlatF} ]; then #{
                      getControlInfo="yes"
                    else
                     $jsr EchoN "${NL}Corrupted or incompatible installation information in workorder file (ctl files) ${NL} ${CALLCRC}"
                     #getControlInfo is still "no" here
                    fi  #}
                  else
                    $jsr EchoN "${NL}Installation  platform not specified. ${NL}Wrong format of cdsInstPlat file in workorder file ${NL}OR Installation information is for $PlatF platform. CD#1 is for $InstPlat platform. ${NL} ${CALLCRC}"
                  fi  #}
                else
                  $jsr EchoN "${NL}    Corrupted or incompatible installation information in workorder file (cdsInstPlat) ${NL} ${CALLCRC}"
                  #getControlInfo is still "no" here
                fi  #}
              else
                $jsr EchoN "${NL}Error: Work Order file not found.${NL}"  1>&2
              fi  #}
                  
              rm -f $tmpdir/wo1_$$ 
            fi  #}
          fi  #}
          ;;
        3) #tape
          sselection=3; export sselection
          default=3
          mediaType=TAPE
          echo "[installation information]" > $device
          $BOURNE $bin_dir/getEmailMedia $mediaType $DeviceTAPE 
          case $? in  #{Return Values from getEmailMedia
            255) #previous menu
              level="1.1.1"
              getControlInfo="no"
              ;;
            250) #main menu
              level="1"
              getControlInfo="no"
              ;;
            0)  #success from getEmailMedia
              test -s $recordFile && . $recordFile
              mediaNum=0
              mediaSet="Installation_Information_Tape"
              mediaTxt="TAPE ${mediaSet}:$mediaNum"
              media_type="TAPE"
              skipcheck_flag="skipcheck"
              if $BOURNE  $bin_dir/media_iface $$ open $DeviceTAPE $mediaSet $mediaNum $media_type $skipcheck_flag ; then  #{
                cd $Proot
                $jsr EchoN "${NL} Reading installation information from $DeviceTAPE .....${NL}" 
                if $BOURNE $bin_dir/media_iface $$ xtract 0 ./install/tmp ./install/pdts ./install/pkgs ./install/IMAGES.DIR ; then  #{
                  if [ -s ${InstPlatFile} ]; then  #{
                    PlatF=`head -1 $InstPlatFile | awk '{ print $1}'`
                    if [ ! -z "$PlatF" -a "X$InstPlat" = "X$PlatF" ]; then #{
                      if [ -f $tmpdir/ctl_bundles.${PlatF} -a \
                           -f $tmpdir/ctl_pkginfo.${PlatF} -a \
                           -f $tmpdir/ctl_mediaMap.${PlatF} ]; then #{
                        getControlInfo="yes"
                      else
                        $jsr EchoN "${NL}    Corrupted or incompatible installation information (ctl files) on inserted tape in $DeviceTAPE ${NL} ${CALLCRC}"
                        #getControlInfo is still "no" here
                      fi  #}
                    else
                      msg="${NL}    Installation  platform not specified. ${NL}    Wrong format of cdsInstPlat file on inserted tape in $DeviceTAPE ${NL} OR Installation information is for $PlatF platform. CD#1 is for $InstPlat platform. ${NL} ${CALLCRC}"
                    fi  #}
                  else
                    $jsr EchoN "${NL}    Corrupted or incompatible installation information (cdsInstPlat) on inserted tape in $DeviceTAPE ${NL} ${CALLCRC}"
                    #getControlInfo is still "no" here
                  fi  #}
                else
                  getControlInfo="no"
                $jsr EchoN "${NL}   Error extracting installation information from tape $DeviceTAPE. ${NL}    Specify the source of installation information again  ${NL}"
                fi  #}
                $BOURNE $bin_dir/media_iface $$ close
              else
                getControlInfo="no"
                $jsr EchoN "${NL}   Error accessing the tape in $DeviceTAPE. ${NL}    Specify the source of installation information again  ${NL}"
             fi  #}
             cd $bin_dir
             ;;
           *) $jsr EchoN "${NL}    Specify the source of installation information again.${NL}"
             getControlInfo="no"
             ;;
         esac   #}End of return Status from getEmailMedia
         ;;
       4 | 5 ) #cadence catalog or Documentation Catalog

         if [ "$inchoice" -eq 4 ]; then  #{
           sselection=4; export sselection
         else
           if $updateMedia; then
             sselection=7; export sselection
           else
             sselection=5; export sselection
           fi
         fi  #}


         #Now we no longer need to ask the customer for the 
         #installation platform.

         if [ ! -z "$InstPlat" ]; then #{ 
           getControlInfo="yes"
         else  #If no platform file
           $jsr EchoN "${NL}Installation platform not available.${NL}"
           $jsr EchoN "${NL}Setting it to $OSvendor.${NL}"
           InstPlat="$OSvendor"
           getControlInfo="yes"
         fi  #}
         ;;
       h) 
         install_help="1.1h"
         sed -n -e '/^LEVEL'$install_help'$/,/^LEVEL_END$/!b' \
                        -e '/^LEVEL/!p' menu_dat | $jsr Page
         $jsr EchoN "${NL}Press [RETURN] to continue: "
         read junkVal
         level="1.1.1"
         getControlInfo="no"
         default=h
         ;;
       m)  #Main Menu 
         level="1"
         default=m
         getControlInfo="no"
         ;;
       p)  #Previous Menu (which is the same as the main menu)
         level="1"
         default=p
         getControlInfo="no"
         ;;
       q)  #Quit Softload 
         test "$level" = "1.1.1" && Exit 0
         ;;
       *) 
         level="1.1.1"
         getControlInfo="no"
         ;;
     esac    #}Possible statuses from "Where is Installation Info." FORM

     if [ "X$sselection" != "X4" -a "X$sselection" != "X5"  -a "X$sselection" != "X7" -a "X$getControlInfo" = "Xyes" ]; then #{

       #First we check whether this control information is
       #for use with a production media or update media
       #Algorithm: If there are more than 1 tapeset ID in
       #ctl_pkgingo file or ctl_mediaMap file then the control
       #information is probably for updateMedia. In case
       #such a workorder is being used with a production CD
       #warn the user.

       prodPat="_64bit"
       defPrompt="Default Installation (install licensed 32-bit products automatically)"

       cusPrompt="Custom Installation (select licensed 32-bit and 64-bit products to install)"

       allbundles="$tmpdir/allbundles.${InstPlat}"
       ctlbundles="$tmpdir/ctl_bundles.${InstPlat}"

       #complain if any file is missing
       stopUser="no"
       if [ ! -s $allbundles -o ! -s $ctlbundles ]; then #{
          msg="${NL}Error: Could not locate files:${NL}${allbundles}${NL}${ctlbundles}"
          stopUser="yes"
          AnotherForm=0
       fi #}

       # Now we check for QSR/Production Infor mismatch
       if [ "X$stopUser" != "Xyes" ]; then #{
         numTSets=`awk '{ if ( $2 == "CDROM" ) print $1}' $tmpdir/ctl_mediaMap.${InstPlat} | awk -F: '{print $1}' | sort -u | wc -l`

         if [ "X$sselection" = "X1" ]; then #{
           w1="in"
           word="workorder"
         elif [ "X$sselection" = "X2" ]; then 
           w1="in"
           word="email"
         else
           w1="on"
           word="tape"
         fi #}

         if $updateMedia; then #{
           if [ $numTSets -eq 1 ]; then #{
             stopUser="yes"
             msg="${NL}It seems that the control information ${w1} this $word ${NL}can only be used with a production media. You cannot ${NL}continue the installation using the update (QSR/ISR) media.${NL}Install products ${w1} this ${word} using the appropriate ${NL}production media.${NL}${NL}"
           else #If -gt than 1 then check
             grep "${mountedCD}:1" $tmpdir/ctl_mediaMap.${InstPlat} 1>&2 > /dev/null
             if [ $? -ne 0 ]; then #{
               stopUser="yes"
               med=`cat $tmpdir/ctl_mediaMap.${InstPlat} | grep "_CD:1" | tail -1 | awk '{print $3 }' | tr '~' ' '`
               msg="${NL}It seems that the control information ${w1} this ${word} is for ${NL}${med}${NL}You are currently using ${mountedCD}${NL}Use the correct media to install products ${w1} this ${word}${NL}${NL}"
             fi #}
           fi #}
         else
           if [ $numTSets -gt 1 ]; then #{
             stopUser="yes"
             msg="${NL}It seems that the control information ${w1} this $word ${NL}can only be used with an update (QSR/ISR) media. You cannot ${NL}continue the installation using the production media.${NL}Install products ${w1} this ${word} using appropriate ${NL}update (QSR/ISR) media. ${NL}${NL}"
           else #If -eq 1 then check
             grep "${mountedCD}:1" $tmpdir/ctl_mediaMap.${InstPlat} 1>&2 > /dev/null
             if [ $? -ne 0 ]; then #{
               stopUser="yes"
               med=`cat $tmpdir/ctl_mediaMap.${InstPlat} | grep "CDROM" | head -1 | awk '{print $3 }' | tr '~' ' ' | awk '{print $1 " " $2 " " $3 " " $4 " " $5 " 1" }'`
               msg="${NL}It seems that the control information ${w1} this ${word} is for ${NL}${med}${NL}You are currently using ${mountedCD}${NL}Use the correct media to install products ${w1} this ${word}${NL}${NL}"
             fi #}
           fi #}
         fi #}

       fi #}If  stopUser not yes

       if [ "X$stopUser" != "Xyes" ]; then #{
          awk '{print $3 }' $allbundles | sort -u > /tmp/allprds$$
          awk '{ if ( NF == 1 ) { print $1 "'$prodPat'" ; } 
                 else { print $3 "'$prodPat'" ; }
                }' $ctlbundles | sort -u > /tmp/ctlprds$$
   
          fgrep  -f /tmp/ctlprds$$ /tmp/allprds$$ 2>/dev/null 1>/tmp/availprds$$

          if [ $? -eq 0 ]; then #{Yes there are some 64 bit products
            def="$defPrompt" 
            cus="$cusPrompt"
          else
            def="Default Installation" 
            cus="Custom Installation"
          fi #}
          /bin/rm -f /tmp/allprds$$ /tmp/ctlprds$$


         $jsr EchoN "${NL}Specify the type of installation: ${NL}"
         $jsr EchoN "

1) $def 

2) $cus 

p) Previous.

m) Main Menu.

h) Help.

Type your choice [ 1 ]: "

         while : ; do   #{
           read dchoice  < /dev/tty
           if [ -z "$dchoice" ]; then  #{
              dchoice=1
           fi  #}
           case $dchoice in  #{
             1)
               default_install="yes" ; export default_install
               break;;
             2)
               default_install="no" ; export default_install
              /bin/cat /tmp/availprds$$ >> $ctlbundles
              /bin/rm -f /tmp/availprds$$
               break;;
             p | P )
               level="1.1.1"
               input="no"
               getControlInfo="no"
               break;;
             m | M )
               level="1"
               input="no"
               getControlInfo="no"
               break;;
             h | H )
                $jsr EchoN "${NL}Specify default installation to install all products in the control information. ${NL}Specify custom installation to select the products to install. ${NL}${NL}If you see something about 32-bit and 64-bit products in the prompts${NL}then you have ordered products that have 64-bit versions on the CD.${NL}${NL}To install 64-bit versions of licensed products, you must use ${NL}custom installation to select the 32-bit and 64-bit products to install.${NL}${NL}Custom installation will only install 32-bit versions of licensed products."
                $jsr EchoN "${NL}Type 1, 2, p, m or h [ 1 ]:"
                ;;
             * )
                $jsr EchoN "${NL}Type 1, 2, p, m or h [ 1 ]:"
                ;;
           esac  #}
         done #}
       fi #} If stopUser
     fi #}

     if [ "X$stopUser" = "Xyes" ]; then #{
       $jsr EchoN "$msg" | $jsr Page
       level="1"
       input="no"
       getControlInfo="no"
     fi #}

     if [ "X$inchoice" != "X" -a "X$getControlInfo" = "Xyes" ]; then #{
       checkControl=yes; 
       export checkControl # Check control info. for load option  only

       if [ ! -z "$InstPlat" ]; then  #{
         export InstPlat

         if $updateMedia; then #{
           if [ "X$sselection" = "X4" ]; then #{
             sselection=1; export sselection
           fi #}
         fi #}

         $vld -l $pkgflag 
         # return 255 means select previous menu 
         case $? in  #{
           255) 
             level="1.1.1" 
             input="no"
             ;;
           *) 
             level="1"
             input="no"
             ;;
         esac  #}
       else
         level="1"
       fi  #}
     fi  #}
     ;;
   1.2 | 1.3 )   #List products 
     checkControl=no; export checkControl 

     if [ -s $tmpdir/platforms ]; then   #{
       echo ""
       $jsr EchoN "${NL} Specify the operating system of the products: ${NL}"
       sed -e 's@^[a-z 0-9]*@@' $tmpdir/platforms | \
       awk '
         BEGIN { ORS= "   "; printf ("\nNo.   Operating system\n"); }
         {  print NR ")"; print ; printf("\n"); }  
         END { printf ("\nType your choice [ 1 - %d ]:",NR); }'
       read platNo  < /dev/tty
       plats=`wc -l < $tmpdir/platforms`
       while : ; do  #{
         if [ "$platNo" -ge 1 -a "$platNo" -le "$plats" ]; then  #{
           break
         else
           $jsr EchoN "${NL}        Type a number between 1 and ${plats}:"
           read platNo
         fi  #}
       done  #}
  
       InstPlat=`sed -n "${platNo},${platNo}p" $tmpdir/platforms | awk '{print $1}'`
       if [ ! -z "$InstPlat" ]; then #{ 
         getControlInfo="yes"
       fi  #}
     else  #If no platform file
       InstPlat="$OSvendor"
     fi  #}
     export InstPlat

     if [ "X$level" = "X1.2" ]; then  #{ 
       $vld -i $pkgflag | $jsr Page 
       $jsr EchoN "${NL}Press [RETURN] to continue: " 
       read junkVal 
     else 
       $vld -d $pkgflag 
     fi  #}
     
     input="no"
     level=1
     ;;	
   1.4.1)  #System-level configuration 
     $jsr $BOURNE sconf_fltr
     level=1
     input="no"
     ;;
   1.4.2)  #User-level configuration
     $jsr $BOURNE uconf_fltr
     level=1
     input="no"
     ;;
   1.5)    #test
     $jsr $BOURNE tstinst_fltr
     level=1
     input="no"
     ;;
   *)	;;
  esac  #}


  # To make configure products the default menu when a configurable 
  #product is installed. and to make load products the default
  #menu at the beginning of a session
  
  
  if [ "$CONFIG_OPT" = "$UNAVAILABLE" ]; then  #{
 	default=1;
  else
    if [ -f $tmpdir/defconfig.opt ]; then  #{
      if grep "1" $tmpdir/defconfig.opt > /dev/null; then  #{
        default=4;
      else
        default=1;
      fi  #}
    else
      default=1;
    fi  #}
  fi #}end of CONFIG_OPT if stmt


  #Remove the defconfig file generated in load_pkgs to indicate that
  #a configurable package has been installed

  rm -f $tmpdir/defconfig.opt

  if [ "X$input" != "Xno" ]; then  #{
    if [ -z "$choice" ]; then  #{
      if [ -z "$default" ]; then  #{
        $jsr EchoN "${NL}    Type your choice: "
      else
        $jsr EchoN "${NL}   Type your choice: [ $default ] "
      fi  #}
            read choice
    fi  #}
       
    if [ -z "$choice" ]; then #{
      choice="$default"
      default=2
    fi  #}
       
    case $choice in  #{
      h)  
        info_menu="$level.$choice"
        sed -n -e '/^LEVEL'$info_menu'$/,/^LEVEL_END$/!b' \
                       -e '/^LEVEL/!p' menu_dat | $jsr Page
        $jsr EchoN "${NL}Press [RETURN] to continue: "
        read junkVal
        ;;
      m)  
        level=1	
        ;;
      p)  
        if [ "$level" != "1" ]; then #{
          level=`echo $level | sed -n 's@\(.*\)\..@\1@p'`
          echo ""
        fi  #}
        ;;
      q)  
        test "$level" = "1" && Exit 0
        ;;
      1)
        level="$level.$choice"
        ;;
      2|3|5|6)
        level="$level.$choice"
        ;;
      #special case for handling the configure products option. 
      #If the configure option is unavailable do not 
      #put up the configuration menu but put up the main menu.
      4)  
        if [ "$CONFIG_OPT" = "$UNAVAILABLE" ]; then #{
          $jsr EchoN "${NL}    Unavailable option, reselect.... ${NL}"
          level=1;
        else
          level="$level.$choice"
        fi #}
        ;;
      *)  
        $jsr EchoN "${NL}    Unavailable option, reselect.... ${NL}"
        level="1"
        ;;
    esac  #}
  fi #}


done #}
