#!/bin/bash

rpm -qp --qf "%{SOURCERPM}\n" /home/centos/u4build/i386/RedHat/RPMS/* | sort | uniq > /home/centos/u4build/srpmlist

rm -rf /home/centos/u4build/SRPMS/*

for srpm in `cat /home/centos/u4build/srpmlist` 
do
#	echo $srpm
	if [ ! -f /home/centos/u4build/SRPMS/$srpm ]; then
		
		
		if [ -f /home/centos/u4build/SRPMS.centos/$srpm ]; then
			cp -al /home/centos/u4build/SRPMS.centos/$srpm /home/centos/u4build/SRPMS
		elif [ -f /home/centos/4build/SRPMS/$srpm ]; then
			cp -al /home/centos/4build/SRPMS/$srpm /home/centos/u4build/SRPMS
        	elif [ -f /mnt/hdb2/home/centos/rhel3-U4beta/SRPMS/$srpm ]; then
        	        cp -au /mnt/hdb2/home/centos/rhel3-U4beta/SRPMS/$srpm /home/centos/u4build/SRPMS
        	elif [ -f /mnt/hdb2/home/centos/rhel3-U4/i386/SRPMS/$srpm ]; then
        	        cp -au /mnt/hdb2/home/centos/rhel3-U4/i386/SRPMS/$srpm /home/centos/u4build/SRPMS
        	elif [ -f /mnt/u4beta/home/centos/U4beta/i386/SRPMS/$srpm ]; then
        	        cp -au /mnt/hdb2/home/centos/U4beta/i386/SRPMS/$srpm /home/centos/u4build/SRPMS
        	elif [ -f /mnt/hdb2/home/centos/3.3/updates/i386/SRPMS/$srpm ]; then
        	        cp -au /mnt/hdb2/home/centos/3.3/updates/i386/SRPMS/$srpm /home/centos/u4build/SRPMS
        	elif [ -f /mnt/hdb2/home/centos/3.3/SRPMS/SRPMS/$srpm ]; then
        	        cp -au /mnt/hdb2/home/centos/3.3/SRPMS/SRPMS/$srpm /home/centos/u4build/SRPMS
        	elif [ -f /mnt/hdb2/home/centos/upd4beta/SRPMS/$srpm ]; then
        	        cp -au /mnt/hdb2/home/centos/upd4beta/SRPMS/$srpm /home/centos/u4build/SRPMS
        	elif [ -f /mnt/hdb2/home/centos/build/SRPMS/$srpm ]; then
        	        cp -au /mnt/hdb2/home/centos/build/SRPMS/$srpm /home/centos/u4build/SRPMS
        	elif [ -f /mnt/hdb2/home/centos/cenmodrpms/SRPMS/$srpm ]; then
        	        cp -au /mnt/hdb2/home/centos/cenmodrpms/SRPMS/$srpm /home/centos/u4build/SRPMS
        	else	
        	        echo $srpm not found
        	fi
	fi

done

