/[smeserver]/builds_bin/checkrpms
ViewVC logotype

Contents of /builds_bin/checkrpms

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Mon Mar 6 04:02:12 2006 UTC (18 years, 8 months ago) by gordonr
Branch: MAIN
Changes since 1.1: +19 -19 lines
Allow a different target directory when checking for updates - WIP

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 /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
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 if (grep { $_->filename =~ m#/centos/[\d.]+/updates/# } @headers)
54 {
55 @headers = grep { $_->filename !~ m#/centos/[\d.]+/os/# } @headers;
56 }
57 if (grep { $_->filename =~ m#/centos/[\d.]+/(updates|os)/# || $_->filename =~ m#/dag/# } @headers)
58 {
59 @headers = grep { $_->filename !~ m#/fedora/# } @headers;
60 @headers = grep { $_->filename !~ m#/atrpms/# } @headers;
61 }
62 if ($#headers < 0)
63 {
64 print "$rpm\n";
65 print " ***** can't find $rpm in any repository *****\n";
66 }
67 elsif ( $headers[0]->filename !~ m#/centos/[\d.]+/(updates|os)/# || $headers[0] ne $rpms{$rpm} )
68 {
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 }

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed