#!/bin/sh

#								RogerBrobst
#    inv_pkgs
#
#	read pkginfo lines from stdin and display an inventory of 
#	packages installed, corrupted, 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/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() {
    MORE=""  more
}

EchoN() {
    echo -n "$*"
}

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


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

NL="
"

awk '{print $1, $2, $3}' | sort -u |
{
    echo "Package Description${NL}Package Name${NL}status${NL}size"
    echo "-------------------${NL}------------${NL}------${NL}----"
    while read pkgdesc pkgname pkgsize; do
	if [ -f $Proot/install/pkgs/${pkgname}.ok ]; then
	    type="installed"
	elif [ -f $Proot/install/pkgs/${pkgname}.nok ]; then
	    type="failed   "
	else
	    type="available"
	fi

	pkgdesc=`echo $pkgdesc | tr '~' ' ' `
	echo "$pkgdesc${NL}$pkgname${NL}$type${NL}$pkgsize"
    done  
} | ./columnize 3 30 25 9 -6 | $jsr Page

