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