#!/bin/sh

#								RogerBrobst
#    status_fltr [-pkg] [-v] suffix
#
#	if -pkg flag turn on:
#	 This program copies package lines from stdin to stdout that correspond
#	 to packages that have a file ending in <suffix>.
#	otherwise
#	 This program copies product lines from stdin to stdout that correspond
#	 to products that have a file ending in <suffix>.
#
#	if <-v>, copy those packages NOT having a file ending in <suffix>.
#		      or copy those packages having a file ending in <suffix>.
#	    	
#
# input
# 	Proot (env variable)
#
#############################################################################
#
#	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
#
#############################################################################

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

check=test
action=check

Root="$Proot/install/pdts"
if [ "X$1" = "X-pkg" ]; then
   Root="$Proot/install/pkgs"      
   pkgflag=$1
   shift
fi

if [ "X$1" = "X-v" ]; then
    check="$check ! ";	shift
fi

test -z "$1" && exit 1
suffix=$1

if [ -z "$pkgflag" ]; then
  while read pdtdesc pkgname pdtname pdtsize platform FMrelease; do
    pdtRoot="$Root/${pdtname}_${platform}_${FMrelease}"
    $check -f $pdtRoot.$suffix &&
		echo "$pdtdesc $pkgname $pdtname $pdtsize $platform $FMrelease"
  done 
else
  while read pkgdesc pkgname remainder; do
    $check -f $Root/$pkgname.$suffix && 
		echo "$pkgdesc $pkgname $remainder"
  done
fi
exit 0
