#!/bin/csh

set fpFile=$1
set installed="YES"
set patchName=$fpFile:t
set patchName=$patchName:r
foreach x (`cat $fpFile | sed 's^ ^\$^g'`)
  set x=(`echo $x | sed 's^\$^ ^g'`)
#echo "x: $x"  
  set file=$NEXT_ROOT/$x[1]
  set fpFileSum="$x[2] $x[3]"
  if ( ! -e $file ) then
	echo "WARNING file does not exist: $file"
	set isntalled="NO"
	continue
  else
  	set fileSum=`sum $file | awk '{print $1," ",$2}'`
  	if ( "$fpFileSum" != "$fileSum" ) then
		#echo "fpsum: $fpFileSum"
		#echo "sum:   $fileSum"
		echo "WARNING sum does not match: $file"
		set installed="NO"
		continue
  	endif
  endif

end

echo -n "$patchName is ... "
if ( "$installed" == "NO" ) then
	echo "not installed."
	exit 1
else
	echo "installed."
	exit 0
endif
  
