4 |
use warnings; |
use warnings; |
5 |
use RPM2; |
use RPM2; |
6 |
use File::Copy; |
use File::Copy; |
7 |
|
use Getopt::Std; |
8 |
|
|
9 |
|
my %opts; |
10 |
|
getopts( "s:d:", \%opts ); |
11 |
|
my $src = $opts{s} || '/builds/RPMS'; |
12 |
|
my $dest = $opts{d} || '/builds/SRPMS'; |
13 |
|
|
14 |
my $rpm_flags = RPM2->vsf_nodsa; |
my $rpm_flags = RPM2->vsf_nodsa; |
15 |
my @repositories = qw( |
my @repositories = qw( |
16 |
/mirrors/centos/4/updates/SRPMS/ |
/mirrors/centos/4/fasttrack/SRPMS |
17 |
/mirrors/centos/4/os/SRPMS/ |
/mirrors/centos/4/updates/SRPMS |
18 |
/mirrors/centos/4/dag/SRPMS/ |
/mirrors/centos/4/os/SRPMS |
19 |
/mirrors/centos/4/atrpms/SRPMS/SRPMS.stable/ |
/mirrors/centos/4/extras/SRPMS |
20 |
/mirrors/centos/4/dries/SRPMS/ |
/mirrors/rpmforge/dag/source/ |
21 |
/mirrors/fedora/updates/3/SRPMS/ |
/mirrors/atrpms/src/el4-i386/atrpms/stable/ |
22 |
/mirrors/fedora/3/SRPMS/ |
/mirrors/fedora-legacy/fedora/3/updates/SRPMS/ |
23 |
/mirrors/mitel/devel/repo/SRPMS/ |
/mirrors/fedora-legacy/fedora/3/os/SRPMS/ |
24 |
/builds/rpms/SRPMS/ |
/builds/rpms/SRPMS/ |
25 |
); |
/builds/old_rpms/SRPMS/ |
26 |
|
); |
27 |
|
|
28 |
opendir RPMS, "/builds/RPMS" or die "Couldn't opendir /builds/RPMS"; |
opendir RPMS, "$src" or die "Couldn't opendir $src"; |
29 |
my %rpms = map { my $x = RPM2->open_package("/builds/RPMS/$_", $rpm_flags); $x->tag('NAME') => $x; } grep { /\.rpm$/ } readdir RPMS; |
my %rpms = map { my $x = RPM2->open_package("$src/$_", $rpm_flags); $x->tag('NAME') => $x; } grep { /\.rpm$/ } readdir RPMS; |
30 |
closedir RPMS; |
closedir RPMS; |
31 |
|
|
32 |
my %repos; |
my %repos; |
49 |
my $src = $rpms{$rpm}->tag('SOURCERPM'); |
my $src = $rpms{$rpm}->tag('SOURCERPM'); |
50 |
push @sources, $src; |
push @sources, $src; |
51 |
push @sources, $src if ($src =~ s/\.2\.el4\.rf\./\.rf\./); |
push @sources, $src if ($src =~ s/\.2\.el4\.rf\./\.rf\./); |
52 |
|
push @sources, $src if ($src =~ s/\.el4\.rf\./\.rf\./); |
53 |
|
push @sources, $src if ($src =~ s/\.el4\.at\./\.at\./); |
54 |
push @sources, $src if ($src =~ s/\.rf\./\.dag\./); |
push @sources, $src if ($src =~ s/\.rf\./\.dag\./); |
55 |
|
|
56 |
my $found = 0; |
my $found = 0; |
57 |
foreach my $source ( @sources ) |
foreach my $source ( @sources ) |
58 |
{ |
{ |
59 |
if( -f "/builds/SRPMS/$source" ) |
if( -f "$dest/$source" ) |
60 |
{ |
{ |
61 |
$found = 1; |
$found = 1; |
62 |
last; |
last; |
65 |
{ |
{ |
66 |
my $fromfile = $repos{$source} . "/$source"; |
my $fromfile = $repos{$source} . "/$source"; |
67 |
$fromfile =~ s#//#/#g; |
$fromfile =~ s#//#/#g; |
68 |
`ln -s $fromfile /builds/SRPMS/`; |
`cp --preserve=timestamps $fromfile $dest/`; |
69 |
$found = 1; |
$found = 1; |
70 |
last; |
last; |
71 |
} |
} |