#!/bin/bash

BASE_URL="http://download.opensuse.org/repositories/home:/PavelVinogradov:/SAMS/"
SRC_PACKAGE=sams2
BIN_PACKAGE="sams2 sams2-doc sams2-web"
ARCHS="i386 i586 x86_64"
BASE_VERSION="2.0.0"
PREFIX_VERSIONS="b2.el5.10.1 b2.fc12.10.1 b2.fc13.10.1 b2.mdv2008.10.1 b2.mdv2009.10.1 b2.suse.10.1"

#For each supported distributive
for os in CentOS_5 Fedora_12 Fedora_13 Mandriva_2008 Mandriva_2009.1 Mandriva_2010 RHEL_5 SLE_10 
do

	#Create distrib folder
        mkdir $os
        cd $os

        #Get source rpm
	for prefix in $PREFIX_VERSIONS
	do
		wget $BASE_URL$os"/src/"$SRC_PACKAGE"-"$BASE_VERSION"-"$prefix".src.rpm"
	done

	#For each arch
        for arch in $ARCHS
        do
		#Create arch folder
                mkdir $arch
                cd $arch
                
		for prefix in $PREFIX_VERSIONS
		do
			#Get binary packages for specified arch
	                for pkg in $BIN_PACKAGE
        	        do
                	        wget $BASE_URL$os"/"$arch"/"$pkg"-"$BASE_VERSION"-"$prefix"."$arch".rpm"
	                done
		done

                cd ..

        done

        cd ..

done

rm -rf CentOS_5/i586 Fedora_12/i586 Fedora_13/i586 Mandriva_2008/i386 RMandriva_2009.1/i386 Mandriva_2009.1/x86_64 Mandriva_2010/i386 Mandriva_2010/x86_64 RHEL_5/i586 SLE_10/i386

