DEFAULT=SL
i386=`ls ../../../$DEFAULT/RPMS/$1.i?86.rpm 2>/dev/null`
rpmarch=`rpm -qp --queryformat "%{arch}" $2`
ok=`ls ../../../$DEFAULT/RPMS/$1.$rpmarch.rpm`
if [ -z "$ok" ] ; then
      ok2=`ls ../../../notsupported/RPMS/$1`
      if [ ! -z "$ok2" ] ; then
	 echo "should go in ../../../notsupported/RPMS/ ,move it over there?"
	 echo "Or you can enter skip and I will skip it"
	 read new
	 if [ -n "$new" ] ; then
		if [ $new = "skip" ] ; then
			echo "Skipping  -->  $2 "
        	fi	
	 else
	   mv -v $2 ../../../notsupported/RPMS/
	   echo -e "\t$2" >> notsupported.log  
	 fi
	 exit	
      else
	 echo "This is a new one do you want me to copy it over to ../../../$DEFAULT/RPMS now"
	 echo "Or you can enter skip and I will skip it"
	 read new
	 if [ -n "$new" ] ; then
		if [ $new = "skip" ] ; then
			echo "Skipping  -->  $2 "
        	fi	
	 else
		mv -v $2 ../../../$DEFAULT/RPMS/
		echo -e "\t$2" >> new.log  
	 fi
	 exit	
      fi # -z $ok
fi
okbase=`basename $ok`
myarch=`uname -p`
if [ ! -z "$i386" ] ; then
   if [  "$rpmarch"  = "$myarch" ] ; then
      i386arch=`rpm -qp --queryformat "%{arch}" $i386 `
      newrpm=`rpm -qp --queryformat "%{name}-%{version}-%{release}.$i386arch.rpm " $2`
      if [  ! -s ../../../$DEFAULT/RPMS/$newrpm ] ; then
        echo "There seems to be a i?86 version of this that we do not have"
      	echo "$newrpm $i386" >> i386.log
      fi
   fi
fi
echo "old one"
echo "$okbase"
echo "Press enter if ok  --> $2 ,  enter skip if you want to skip it"
me=""
read me
if [ -n "$me" ] ; then
	if [ $me = "skip" ] ; then
		echo "Skipping  -->  $2 "
        fi	
else
	echo "okbase is $okbase"
	if [ -z "$okbase" ] ; then
		echo "base rpm name is null, skipping"
	else
		if [ -z "$2" ] ; then
                	echo "rpm name is null, skipping"
		else
			mv -v ../../../$DEFAULT/RPMS/$okbase  ../../obsolete/RPMS/
			mv -v $2 ../../../$DEFAULT/RPMS/
			ln -sf ../../../$DEFAULT/RPMS/$2 ../RPMS/$2
			echo -e "\t$2" >> errata.log
# remove old version out of RedHat/RPMS/
			if [ -s ../RPMS/$okbase ] ; then
				rm ../RPMS/$okbase
			fi
		fi
	fi
fi
