#!/bin/sh

# This script represents the top-level of the installation assurance option to
# cdsLoad.  It's algorithm is fairly simple:
# * Determine appropriate products to assure:
#   This is done by calling chk_attr with the TEST_INSTALL argument.  This
#   script in turn lists all of the products that are appropriate for
#   installation assurance, in the file .../install/tmp/product.list.
# * Display all products to assure.
# * Let user select desired product(s) to assure.
# * Assure selected product(s):
#   This is done by calling test_inst, with the selected products now contained
#   in file .../install/tmp/testProd.list.
#############################################################################
#
#	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/openwin/bin
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=''
Exit() {

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

}

NL="
"

if [ -z "$Proot" ]; then
  echo "$0 environment not initialized.
$0 Can only be used when called from SoftLoad."                               1>&2
  exit 1
fi

inFile=$Proot/install/tmp/product.list
outFile=$Proot/install/tmp/testProd.list
GUIexe="$BOURNE $bin_dir/toplevel.sh 13"
choiceStat=0

$BOURNE chk_attr TEST_INSTALL
if [ ! -s $inFile ]; then
  echo "$No products available for testing."
  Exit 0 $inFile
fi

sort -u +0 -1 $inFile > $inFile.tmp
mv $inFile.tmp $inFile

if $useGUI; then
  $GUIexe $inFile $outFile
  choiceStat=$?
else
  $BOURNE choice_fltr \
      -M "${NL}Select the products to test:" \
      -T "product" -c 1 $inFile $outFile 
fi
if [ $choiceStat = 0 ]; then
  if [ -s $outFile ]; then
    $BOURNE test_inst $useGUI
  fi
fi
Exit $choiceStat $inFile $outFile
