#!/bin/bash

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

rm -rf /home/centos/u7build/i386/SRPMS/*

for srpm in `cat /home/centos/u7build/srpmlist` 
do
#	echo $srpm
	if [ -f /home/centos/u6build/SRPMS/$srpm ]; then
		cp -al /home/centos/u6build/SRPMS/$srpm /home/centos/u7build/i386/SRPMS
        elif [ -f /home/centos/3.7/SRPMS/$srpm ]; then
                cp -al /home/centos/3.7/SRPMS/$srpm /home/centos/u7build/i386/SRPMS
        elif [ -f /home/centos/3.7beta/SRPMS/$srpm ]; then
                cp -al /home/centos/3.7beta/SRPMS/$srpm /home/centos/u7build/i386/SRPMS
        elif [ -f /home/centos/7build/SRPMS/$srpm ]; then
                cp -al /home/centos/7build/SRPMS/$srpm /home/centos/u7build/i386/SRPMS
        elif [ -f /home/centos/c3.7build/SRPMS/$srpm ]; then
                cp -al /home/centos/c3.7build/SRPMS/$srpm /home/centos/u7build/i386/SRPMS
        elif [ -f /home/centos/3.6/updates/SRPMS/$srpm ]; then
                cp -al /home/centos/3.6/updates/SRPMS/$srpm /home/centos/u7build/i386/SRPMS

	else
                echo $srpm not found
        fi

done

cp -al /home/centos/u7build/SRPMS.arches/* /home/centos/u7build/i386/SRPMS

