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/fasttrack/SRPMS/ |
/mirrors/centos/4/fasttrack/SRPMS |
17 |
/mirrors/centos/4/updates/SRPMS/ |
/mirrors/centos/4/updates/SRPMS |
18 |
/mirrors/centos/4/os/SRPMS/ |
/mirrors/centos/4/os/SRPMS |
19 |
/mirrors/dag/source/ |
/mirrors/centos/4/extras/SRPMS |
20 |
/mirrors/atrpms/src/el4-i386/atrpms/SRPMS.stable/ |
/mirrors/rpmforge/dag/source/ |
21 |
/mirrors/centos/4/dries/SRPMS/ |
/mirrors/atrpms/src/el4-i386/atrpms/stable/ |
22 |
/mirrors/fedora/updates/3/SRPMS/ |
/mirrors/fedora-legacy/fedora/3/updates/SRPMS/ |
23 |
/mirrors/fedora/3/SRPMS/ |
/mirrors/fedora-legacy/fedora/3/os/SRPMS/ |
24 |
/builds/rpms/SRPMS/ |
/builds/rpms/SRPMS/ |
25 |
/mirrors/mitel/devel/repo/SRPMS/ |
); |
|
); |
|
26 |
|
|
27 |
opendir RPMS, "/builds/RPMS" or die "Couldn't opendir /builds/RPMS"; |
opendir RPMS, "$src" or die "Couldn't opendir $src"; |
28 |
my %rpms = map { my $x = RPM2->open_package("/builds/RPMS/$_", $rpm_flags); $x->tag('NAME') => $x; } grep { /\.rpm$/ } readdir RPMS; |
my @rpms = map { RPM2->open_package("$src/$_", $rpm_flags) } grep { /\.rpm$/ } readdir RPMS; |
29 |
closedir RPMS; |
closedir RPMS; |
30 |
|
|
31 |
my %repos; |
my %repos; |
37 |
%repos = (%repos, %temp_repo); |
%repos = (%repos, %temp_repo); |
38 |
} |
} |
39 |
|
|
40 |
foreach my $rpm ( sort keys %rpms ) |
foreach my $rpm ( sort @rpms ) |
41 |
{ |
{ |
42 |
my (@headers, $header); |
my (@headers, $header); |
43 |
|
|
45 |
$rpmfix =~ s@\+@\\+@g; |
$rpmfix =~ s@\+@\\+@g; |
46 |
|
|
47 |
my @sources; |
my @sources; |
48 |
my $src = $rpms{$rpm}->tag('SOURCERPM'); |
my $src = $rpm->tag('SOURCERPM'); |
49 |
push @sources, $src; |
push @sources, $src; |
50 |
push @sources, $src if ($src =~ s/\.2\.el4\.rf\./\.rf\./); |
push @sources, $src if ($src =~ s/\.2\.el4\.rf\./\.rf\./); |
51 |
push @sources, $src if ($src =~ s/\.el4\.rf\./\.rf\./); |
push @sources, $src if ($src =~ s/\.el4\.rf\./\.rf\./); |
52 |
|
push @sources, $src if ($src =~ s/\.el4\.at\./\.at\./); |
53 |
push @sources, $src if ($src =~ s/\.rf\./\.dag\./); |
push @sources, $src if ($src =~ s/\.rf\./\.dag\./); |
54 |
|
|
55 |
my $found = 0; |
my $found = 0; |
56 |
foreach my $source ( @sources ) |
foreach my $source ( @sources ) |
57 |
{ |
{ |
58 |
if( -f "/builds/SRPMS/$source" ) |
if( -f "$dest/$source" ) |
59 |
{ |
{ |
60 |
$found = 1; |
$found = 1; |
61 |
last; |
last; |
64 |
{ |
{ |
65 |
my $fromfile = $repos{$source} . "/$source"; |
my $fromfile = $repos{$source} . "/$source"; |
66 |
$fromfile =~ s#//#/#g; |
$fromfile =~ s#//#/#g; |
67 |
`cp -pl $fromfile /builds/SRPMS/`; |
`cp --preserve=timestamps $fromfile $dest/`; |
68 |
$found = 1; |
$found = 1; |
69 |
last; |
last; |
70 |
} |
} |