1 |
gordonr |
1.1 |
#!/usr/bin/perl |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use warnings; |
5 |
|
|
use RPM2; |
6 |
|
|
use File::Copy; |
7 |
|
|
|
8 |
|
|
my $rpm_flags = RPM2->vsf_nodsa; |
9 |
|
|
my @repositories = qw( |
10 |
gordonr |
1.2 |
/mirrors/centos/4/fasttrack/SRPMS/ |
11 |
gordonr |
1.1 |
/mirrors/centos/4/updates/SRPMS/ |
12 |
|
|
/mirrors/centos/4/os/SRPMS/ |
13 |
gordonr |
1.2 |
/mirrors/dag/source/ |
14 |
|
|
/mirrors/atrpms/src/el4-i386/atrpms/SRPMS.stable/ |
15 |
gordonr |
1.1 |
/mirrors/centos/4/dries/SRPMS/ |
16 |
|
|
/mirrors/fedora/updates/3/SRPMS/ |
17 |
|
|
/mirrors/fedora/3/SRPMS/ |
18 |
gordonr |
1.2 |
/builds/rpms/SRPMS/ |
19 |
gordonr |
1.1 |
/mirrors/mitel/devel/repo/SRPMS/ |
20 |
|
|
); |
21 |
|
|
|
22 |
|
|
opendir RPMS, "/builds/RPMS" or die "Couldn't opendir /builds/RPMS"; |
23 |
|
|
my %rpms = map { my $x = RPM2->open_package("/builds/RPMS/$_", $rpm_flags); $x->tag('NAME') => $x; } grep { /\.rpm$/ } readdir RPMS; |
24 |
|
|
closedir RPMS; |
25 |
|
|
|
26 |
|
|
my %repos; |
27 |
|
|
foreach my $repo (reverse @repositories) |
28 |
|
|
{ |
29 |
|
|
my %temp_repo = map { $_ => $repo } grep { /\.rpm$/ } readdir RPMS if ( opendir RPMS, $repo ); |
30 |
|
|
closedir RPMS; |
31 |
|
|
|
32 |
|
|
%repos = (%repos, %temp_repo); |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
foreach my $rpm ( sort keys %rpms ) |
36 |
|
|
{ |
37 |
|
|
my (@headers, $header); |
38 |
|
|
|
39 |
|
|
my $rpmfix = $rpm; |
40 |
|
|
$rpmfix =~ s@\+@\\+@g; |
41 |
|
|
|
42 |
|
|
my @sources; |
43 |
|
|
my $src = $rpms{$rpm}->tag('SOURCERPM'); |
44 |
|
|
push @sources, $src; |
45 |
|
|
push @sources, $src if ($src =~ s/\.2\.el4\.rf\./\.rf\./); |
46 |
gordonr |
1.2 |
push @sources, $src if ($src =~ s/\.el4\.rf\./\.rf\./); |
47 |
gordonr |
1.1 |
push @sources, $src if ($src =~ s/\.rf\./\.dag\./); |
48 |
|
|
|
49 |
|
|
my $found = 0; |
50 |
|
|
foreach my $source ( @sources ) |
51 |
|
|
{ |
52 |
|
|
if( -f "/builds/SRPMS/$source" ) |
53 |
|
|
{ |
54 |
|
|
$found = 1; |
55 |
|
|
last; |
56 |
|
|
} else { |
57 |
|
|
if ($repos{$source}) |
58 |
|
|
{ |
59 |
|
|
my $fromfile = $repos{$source} . "/$source"; |
60 |
|
|
$fromfile =~ s#//#/#g; |
61 |
gordonr |
1.2 |
`cp -pl $fromfile /builds/SRPMS/`; |
62 |
gordonr |
1.1 |
$found = 1; |
63 |
|
|
last; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
} |
67 |
|
|
} |
68 |
|
|
print "can't find SRPM ($sources[0]) for $rpm\n" unless $found; |
69 |
|
|
} |