1 |
gordonr |
1.1 |
#!/usr/bin/perl |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use warnings; |
5 |
|
|
use RPM2; |
6 |
|
|
use Data::Dumper; |
7 |
|
|
|
8 |
|
|
my $rpm_flags = RPM2->vsf_nodsa; |
9 |
|
|
my $build_dir = "/builds/RPMS"; |
10 |
|
|
my @repositories = qw( |
11 |
slords |
1.4 |
/mirrors/centos/4/fasttrack/i386/RPMS/ |
12 |
gordonr |
1.2 |
/mirrors/centos/4/updates/i386/RPMS/ |
13 |
|
|
/mirrors/centos/4/os/i386/CentOS/RPMS/ |
14 |
slords |
1.4 |
/mirrors/centos/4/extras/i386/RPMS/ |
15 |
|
|
/mirrors/rpmforge/dag/redhat/el4/en/i386/dag/RPMS/ |
16 |
gordonr |
1.2 |
/mirrors/atrpms/el4-i386/atrpms/stable/ |
17 |
slords |
1.4 |
/mirrors/rpmforge/dag/dries/redhat/el4/en/i386/RPMS.dries/ |
18 |
|
|
/mirrors/fedora-legacy/fedora/3/updates/i386/ |
19 |
|
|
/mirrors/fedora-legacy/fedora/3/os/i386/ |
20 |
gordonr |
1.2 |
/builds/rpms/RPMS/i686/ |
21 |
|
|
/builds/rpms/RPMS/i586/ |
22 |
|
|
/builds/rpms/RPMS/i386/ |
23 |
|
|
/builds/rpms/RPMS/noarch/ |
24 |
|
|
); |
25 |
gordonr |
1.1 |
|
26 |
|
|
opendir RPMS, $build_dir or die "Couldn't opendir $build_dir"; |
27 |
|
|
my %rpms = map { my $x = RPM2->open_package("$build_dir/$_", $rpm_flags); $x->tag('NAME') => $x; } grep { /\.rpm$/ } readdir RPMS; |
28 |
|
|
closedir RPMS; |
29 |
|
|
|
30 |
|
|
my %repos; |
31 |
|
|
foreach my $repo (reverse @repositories) |
32 |
|
|
{ |
33 |
|
|
my %temp_repo = map { $_ => $repo } grep { /\.rpm$/ } readdir RPMS if ( opendir RPMS, $repo ); |
34 |
|
|
closedir RPMS; |
35 |
|
|
%repos = (%repos, %temp_repo); |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
foreach my $rpm ( sort keys %rpms ) |
39 |
|
|
{ |
40 |
|
|
my (@headers, $header); |
41 |
|
|
|
42 |
|
|
my $rpmfix = $rpm; |
43 |
|
|
$rpmfix =~ s@\+@\\+@g; |
44 |
|
|
@headers = (); |
45 |
|
|
foreach my $file ( grep { /^$rpmfix-[0-9].*\.rpm$/ } keys %repos ) |
46 |
|
|
{ |
47 |
|
|
$header = RPM2->open_package("$repos{$file}/$file", $rpm_flags); |
48 |
slords |
1.4 |
if ($header ge $rpms{$rpm} || $header->filename =~ m#/centos/[\d.]+/(os|updates|fasttrack|extras)/#) |
49 |
gordonr |
1.1 |
{ |
50 |
|
|
push @headers, $header; |
51 |
|
|
} |
52 |
|
|
} |
53 |
|
|
@headers = reverse sort { $a cmp $b } @headers; |
54 |
slords |
1.4 |
if (grep { $_->filename =~ m#/centos/[\d.]+/(updates|fasttrack)/# } @headers) |
55 |
gordonr |
1.1 |
{ |
56 |
slords |
1.5 |
@headers = grep { $_->filename !~ m#/centos/[\d.]+/os/# || $_ eq $rpms{$rpm} } @headers; |
57 |
gordonr |
1.1 |
} |
58 |
slords |
1.4 |
if (grep { $_->filename =~ m#/centos/[\d.]+/(os|updates|fasttrack|extras)/# || $_->filename =~ m#/dag/[^d]# } @headers) |
59 |
gordonr |
1.1 |
{ |
60 |
slords |
1.5 |
@headers = grep { $_->filename !~ m#/atrpms/# || $_ eq $rpms{$rpm} } @headers; |
61 |
|
|
@headers = grep { $_->filename !~ m#/fedora/# || $_ eq $rpms{$rpm} } @headers; |
62 |
|
|
@headers = grep { $_->filename !~ m#/fedora-legacy/# || $_ eq $rpms{$rpm} } @headers; |
63 |
gordonr |
1.1 |
} |
64 |
|
|
if ($#headers < 0) |
65 |
|
|
{ |
66 |
|
|
print "$rpm\n"; |
67 |
|
|
print " ***** can't find $rpm in any repository *****\n"; |
68 |
|
|
} |
69 |
slords |
1.4 |
elsif ( $headers[0]->filename !~ m#/centos/[\d.]+/(os|updates|fastrrack|extras)/# || $headers[0] ne $rpms{$rpm} ) |
70 |
gordonr |
1.1 |
{ |
71 |
|
|
if (grep { $_ ne $rpms{$rpm} } @headers) |
72 |
|
|
{ |
73 |
|
|
print "$rpm\n"; |
74 |
|
|
foreach $header ( @headers) |
75 |
|
|
{ |
76 |
|
|
my $path = $header->filename; |
77 |
|
|
$path =~ s@^(.*)/.*@$1@; |
78 |
slords |
1.4 |
my $filename = $rpms{$rpm}->filename; |
79 |
|
|
$filename =~ s@^.*/(.*)@$1@; |
80 |
gordonr |
1.1 |
print " " . ($header eq $rpms{$rpm} ? "** " : "-- ") . $header->as_nvre . " ($path)\n"; |
81 |
slords |
1.4 |
#print " - rm $build_dir/$filename; cp ". $header->filename . " $build_dir\n"; |
82 |
gordonr |
1.1 |
} |
83 |
|
|
} |
84 |
|
|
} |
85 |
|
|
} |