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