#!/usr/bin/sh

compare_cksum() {
	destfile=$1
	cksumfile=$2

	installed_cksum=`/usr/bin/tail -1 $cksumfile | /usr/bin/awk '{print $1}'`
	current_cksum=`/usr/bin/cksum $destfile | /usr/bin/awk '{print $1}'`
	test $installed_cksum = $current_cksum
}

while read path ; do
	destpath=`echo $path | /usr/bin/sed -e 's/\/[^/]*$//'`
	destbase=`/usr/bin/basename $path`
	cksumfile="${destpath}/.${destbase}.cksum"
	if [ -f $path ] ; then
		if [ -f $cksumfile ] ; then
			compare_cksum $path $cksumfile
			if [ $? -eq 0 ] ; then
				/usr/bin/rm -f $path $cksumfile
			else
				echo "$path has been modified since it was installed -- "
				echo "    leaving it in place."
			fi
		else
			echo "$path may have been modified since it was installed -- "
			echo "    leaving it in place."
		fi
	fi
done
if [ "$1" = "ENDOFCLASS" ] ; then
	exit 0
fi
