PWD=`pwd`; export $PWD
TREE=`basename ${PWD}`; export $TREE
ROOT=r; export $ROOT
IFS="
"
#
if [ "$1" = "" ]; then
	echo $CLEAR
	echo "\n\nThe current working tree is ${REVERSE} ${PWD} ${UNBOLD} "
	echo "Enter <RETURN> if okay.  Otherwise, enter new tree name > \c"
	while :; do
		read ANS
		case $ANS in
			"")
				PWD=${PWD}
				break 2;;
			*)
				if [ ! -d $ANS ]; then
					echo "\n${REVERSE} ${ANS} ${UNBOLD}  is not a valid tree name.  Please re-enter tree name."
					echo "\nEnter <RETURN> to continue.\c"; line
					echo $CLEAR
					echo "\n\nThe current working tree is ${REVERSE} ${PWD} ${UNBOLD} "
					echo "Enter <RETURN> if okay.  Otherwise, re-enter new tree name > \c"
					continue
				fi
				PWD=${ANS}
				cd $PWD
				TREE=`basename ${PWD}`
				break 2;;
		esac
	done
else
	PWD=${1}
	cd $PWD
	TREE=`basename ${PWD}`
	echo $CLEAR
fi
#
> /log/${ROOT}${TREE}.tmp
> /log/${TREE}.tmp
> /log/${ROOT}${TREE}.diff
#> /log/${ROOT}${TREE}.ctime
echo "\n\nTwo log files will be created as /log/${TREE}.tree and /log/${ROOT}${TREE}.tree"
echo "\nCreating the log files for release ${REVERSE} `echo ${TREE} | tr '[a-z]' '[A-Z]'` ${UNBOLD} ...\c"
for file in `find . -print`; do
	ls -ld $file >> /log/${TREE}.tmp 2>&1
	ls -ld /$file >> /log/${ROOT}${TREE}.tmp 2>&1
done
#
sed '1d' /log/${TREE}.tmp > /log/${TREE}.tree 2>&1
sed '1d' /log/${ROOT}${TREE}.tmp > /log/${ROOT}${TREE}.tree 2>&1
rm /log/*${TREE}.tmp
echo "\n\nThe number of files found in ${PWD}"
echo "and in the root file system, respectively:"
echo "\n	`wc -l /log/${TREE}.tree | awk '{ print $1 }' | tee /tmp/${TREE}.wc`	${PWD}"
echo "	`wc -l /log/${ROOT}${TREE}.tree | awk '{ print $1 }' | tee /tmp/${ROOT}${TREE}.wc`	/log/${ROOT}${TREE}.tree"
cmp -s /tmp/${TREE}.wc /tmp/${ROOT}${TREE}.wc
if [ $? != 0 ]; then
	echo "\n${BELL}The number of files in and the root file system differ."
	exit 1
fi
rm /tmp/${TREE}.wc /tmp/${ROOT}${TREE}.wc
#
# 	This section compares the release tree and the root tree for 
#	differences in permissions, number of links to a file, and owners.
#
for file in `cat /log/${TREE}.tree | awk '{ print $1 "	" $2 "	" $3 "	" $4 "	" $9 }`; do
	FILENAME=`echo $file | awk '{ print $5 }'`
	MODIFIED=`grep "$FILENAME$" /log/${ROOT}${TREE}.tree | awk '{ print $1 "	" $2 "	" $3 "	" $4 "	" $9 }' | sed 's/[ 	]*\/\./\ ./'`
	if [ $file != "$MODIFIED" ]; then
		echo $FILENAME >> /log/${ROOT}${TREE}.diff
		echo $file >> /log/${ROOT}${TREE}.diff
		echo "$MODIFIED\n" >> /log/${ROOT}${TREE}.diff
	fi
done
