#!/bin/sh

#								
#    inv_pdts
#
#	-S: add status information into the output product 
#           inventory and dont print out the header
#	read product lines from stdin and display an inventory of 
#	products installed, failed, and available
#	
#
#############################################################################
#
#	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=''

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

Page() {
    MORE=""  more
}

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

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


if [ -z "$Proot" ]; then 
    echo "$0 environment not initialized" 				1>&2
    exit 1 
fi
export Proot

NL="
"
flag=false
action="./columnize 1 55 -6 9"
test "X$1" = "X-S" && {
    flag=true
    action="cat -"
}

awk '{print $1, $3, $4, $5, $6 }' | sort -n |
{
    if $flag; then : ; else
      echo "Product Description${NL}size${NL}status"
      echo "---------------------------------------${NL}------${NL}----"
    fi
    while read pdtdesc pdtname pdtsize platform FMrelease; do
	if [ -f $Proot/install/pdts/${pdtname}_${platform}_${FMrelease}.ok ]; then
	    type="installed"
	elif [ -f $Proot/install/pdts/${pdtname}_${platform}_${FMrelease}.nok ]; then
	    type="failed   "
	else
	    type="available"
	fi

	if $flag; then
           echo "$pdtdesc pkgname $pdtname $pdtsize $platform $FMrelease $type"
        else
           pdtdesc=`echo $pdtdesc | tr '~' ' ' `
           echo "$pdtdesc${NL}$pdtsize${NL}$type"
        fi
    done
} | $action

