DEFAULT=SL
echo `date` >> errata.log
echo `date` >> new.log
echo `date` >> i386.log
mv *debuginfo*.rpm ../../debuginfo/RPMS/
/bin/mv -f *src.rpm ../../../../SRPMS/vendor/errata/
for i in *.rpm
do
	if [ -f ../../../$DEFAULT/RPMS/$i ] ; then
		echo "Already have $i in SL/RPMS, so deleting it."
		rm $i
		continue
	fi
	if [ -f ../../obsolete/RPMS/$i ] ; then
		echo "Already have $i in obsolete/RPMS, so deleting it."
		rm $i
		continue
	fi
	NEWNAME=`rpm -qp $i --qf "%{name}"`
	NEWARCH=`rpm -qp $i --qf "%{arch}"`
	OLDRPM=""
	cd ../../../SL/RPMS/ > /dev/null
	LIST=`ls -1 ${NEWNAME}* 2> /dev/null`
	for line in $LIST
	do
		OLDNAME=`rpm -qp $line --qf "%{name}"`
		if [ "${OLDNAME}" == "${NEWNAME}" ] ; then
			OLDARCH=`rpm -qp $line --qf "%{arch}"`
			if [ "${OLDARCH}" == "${NEWARCH}" ] ; then
				OLDRPM="$line"
				#echo "Found a match: $line"
			fi
		fi
	done
	cd - > /dev/null
	if [ "$OLDRPM" == "" ] ; then
		echo ""	
		echo "new: $i"
		echo "I could not find a match for this.  Should I just move it in?"
		echo "Enter skip if I should skip this one"
		read new
		 if [ -n "$new" ] ; then
			if [ $new = "skip" ] ; then
				echo "... Skipping"
	        fi	
		 else
			echo "Moving it in"
			mv -v $i ../../../$DEFAULT/RPMS/
			echo -e "\t$i" >> new.log  
		 fi
	else
		echo ""
		echo "old: $OLDRPM"
		echo "new: $i"
		echo "Should I replace the old rpm with the new?"
		echo "Enter skip if I should skip this one"
		read new
		 if [ -n "$new" ] ; then
			if [ $new = "skip" ] ; then
				echo "... Skipping"
	        fi	
		 else
			echo "Replacing old with new"
			mv -v ../../../$DEFAULT/RPMS/$OLDRPM  ../../obsolete/RPMS/
			mv -v $i ../../../$DEFAULT/RPMS/
			echo -e "\t$i" >> errata.log
		 fi
	 fi
done
