/[smeserver]/builds_bin/update_repos
ViewVC logotype

Annotation of /builds_bin/update_repos

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


Revision 1.30 - (hide annotations) (download)
Tue Dec 11 00:04:40 2007 UTC (16 years, 11 months ago) by slords
Branch: MAIN
Changes since 1.29: +350 -433 lines
Fix for repo_update script

1 slords 1.1 #!/usr/bin/perl
2    
3     use strict;
4     use warnings;
5     use RPM2;
6 slords 1.20 use File::Find;
7     use File::Basename;
8     use Getopt::Std;
9 slords 1.1 use Data::Dumper;
10    
11 slords 1.20 delete $ENV{PATH};
12     my $HOME=$ENV{HOME};
13     umask 002;
14 slords 1.30 $| = 1;
15    
16     my %opts;
17     getopts( 'otr:', \%opts );
18     $opts{r} ||= '';
19 slords 1.20
20     my $rpm_flags = RPM2->vsf_nosha1header | RPM2->vsf_nomd5header | RPM2->vsf_nodsaheader | RPM2->vsf_norsaheader;
21     $rpm_flags |= RPM2->vsf_nosha1 | RPM2->vsf_nomd5 | RPM2->vsf_nodsa | RPM2->vsf_norsa;
22    
23     my @archs = ( 'i386', 'x86_64' );
24    
25 slords 1.27 my $distrepo = { '7' => { active => 1,
26     centos => 4,
27     fedora => 3,
28     repo => '/releases/7/',
29 slords 1.30 os => 'RPMS/',
30 slords 1.27 builds => '/builds/smeserver-7-core/',
31     contribs => '/builds/smeserver-7-contribs/',
32 slords 1.30 qa => '/builds/smeserver-7-qa/',
33 slords 1.27 stage => '/stage/7/',
34 slords 1.20 },
35 slords 1.27 '8' => { active => 1,
36     centos => 5,
37     fedora => 6,
38     repo => '/releases/testing/8/',
39 slords 1.30 os => '',
40 slords 1.27 builds => '/builds/smeserver-8-core/',
41     contribs => '/builds/smeserver-8-contribs/',
42 slords 1.30 qa => '/builds/smeserver-8-qa/',
43 slords 1.27 stage => '/stage/8/',
44 slords 1.20 },
45     };
46    
47 slords 1.30 my $repos = { 'smeos' => { prio => 18, inc => 1, ver => 1, rel => 1, os => 1 },
48     'smeupdates' => { prio => 17, inc => 1, ver => 1, rel => 1 },
49     'smeupdates-testing' => { prio => 16, inc => 1, ver => 1, rel => 1 },
50     'smeextras' => { prio => 15, inc => 0, ver => 1, rel => 1 },
51     'smeaddons' => { prio => 14, inc => 0, ver => 1, rel => 1 },
52     'smecontribs' => { prio => 13, inc => 0, ver => 1, rel => 2 },
53     'smetest' => { prio => 12, inc => 0, ver => 2, rel => 2, devel => 2 },
54     'smedev' => { prio => 11, inc => 0, ver => 2, rel => 2, devel => 1 },
55     'centos' => { prio => 10, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
56     'epel' => { prio => 9, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
57     'fedora-extras' => { prio => 8, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
58     'rpmforge' => { prio => 7, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
59     'atrpms' => { prio => 6, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
60     'fedora' => { prio => 5, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
61     'builds' => { prio => 4, inc => 0, ver => 0, rel => 0, orig => 1 },
62     'contribs' => { prio => 2, inc => 0, ver => 0, rel => 0, orig => 1 },
63     'stage' => { prio => 1, inc => 0, ver => 0, rel => 0, stage => 1, os => 1 },
64     };
65    
66     my $baserepo = { '~Ssmeos/~A/SME/~O' => 'smeos',
67     '~Ssmeupdates/~A/RPMS/' => 'smeupdates',
68     '~Ssmeupdates-testing/~A/RPMS/' => 'smeupdates-testing',
69     '~Ssmeextras/~A/RPMS/' => 'smeextras',
70     '~Ssmeaddons/~A/RPMS/' => 'smeaddons',
71     '~Ssmecontribs/~A/RPMS/' => 'smecontribs',
72     '~Ssmetest/~A/RPMS/' => 'smetest',
73     '~Ssmedev/~A/RPMS/' => 'smedev',
74     '/stage/~s/~A/SME/~O' => 'stage',
75     '/mirrors/centos/~C/fasttrack/~A/RPMS/' => 'centos',
76     '/mirrors/centos/~C/updates/~A/RPMS/' => 'centos',
77     '/mirrors/centos/~C/os/~A/CentOS/~O' => 'centos',
78     '/mirrors/centos/~C/extras/~A/RPMS/' => 'centos',
79     '/mirrors/centos-qa/CentOS/~C/fasttrack/~A/RPMS/' => 'centos',
80     '/mirrors/centos-qa/CentOS/~C/updates/~A/RPMS/' => 'centos',
81     '/mirrors/centos-qa/CentOS/~C/os/~A/CentOS/~O' => 'centos',
82     '/mirrors/centos-qa/CentOS/~C/extras/~A/RPMS/' => 'centos',
83     '/mirrors/fedora/epel/~C/~A/' => 'epel',
84     '/mirrors/fedora/epel/testing/~C/~A/' => 'epel',
85     '/mirrors/fedora/extras/~F/~A/' => 'fedora-extras',
86     '/mirrors/rpmforge/dag/redhat/el~C/en/~A/dag/RPMS/' => 'rpmforge',
87     '/mirrors/rpmforge/dag/source/' => 'rpmforge',
88     '/mirrors/atrpms/el~C-~A/atrpms/stable/' => 'atrpms',
89     '/mirrors/atrpms/el~C-~A/atrpms/testing/' => 'atrpms',
90     '/mirrors/atrpms/src/el~C-~A/atrpms/stable/' => 'atrpms',
91     '/mirrors/atrpms/src/el~C-~A/atrpms/testing/' => 'atrpms',
92     '/mirrors/fedora/core/~F/~A/os/Fedora/RPMS/' => 'fedora',
93     '/mirrors/fedora/core/updates/~F/~A/' => 'fedora',
94     };
95    
96     my $skippkg = { '7' => { 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3', 'vim' ) },
97     'epel' => { map { $_ => 1 } ( 'perl-Razor-Agent' ) },
98     'rpmforge' => { map { $_ => 1 } ( 'perl-Test-Inline' ) },
99     'atrpms' => { map { $_ => 1 } ( 'dovecot', 'trac', 'yum' ) },
100 slords 1.20 },
101 slords 1.30 '8' => { 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3' ) },
102     'fedora' => { map { $_ => 1 } ( 'kernel-xen' ) },
103     'epel' => { map { $_ => 1 } ( 'perl-Razor-Agent', 'smolt' ) },
104     'fedora-extras' => { map { $_ => 1 } ( 'dstat', 'gocr', 'horde', 'oidentd', 'perl-Test-Inline', 'perl-Razor-Agent', 'smolt' ) },
105     'rpmforge' => { map { $_ => 1 } ( 'perl-Test-Inline' ) },
106 slords 1.20 },
107     };
108    
109 slords 1.30 my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos;
110 slords 1.20 my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos;
111     $devel2 ||= $devel1;
112    
113 slords 1.30 my ($rpms, %base, %latest, %sources);
114     foreach my $smever ( sort { $a <=> $b } keys %$distrepo ) {
115     next unless $distrepo->{$smever}->{active};
116     my %repochg = ();
117     $rpms = ();
118 slords 1.21 %latest = ();
119 slords 1.20 %sources = ();
120 slords 1.30 %base = ();
121 slords 1.20
122 slords 1.30 foreach my $dir ( sort { $repos->{$baserepo->{$b}}->{prio} <=> $repos->{$baserepo->{$a}}->{prio} || $a cmp $b } keys %$baserepo ) {
123     my $bdir = $dir;
124     $bdir =~ s/~O/$distrepo->{$smever}->{os}/;
125     $bdir =~ s/~S/$distrepo->{$smever}->{repo}/;
126     $bdir =~ s/~s/$smever/;
127 slords 1.20 $bdir =~ s/~C/$distrepo->{$smever}->{centos}/;
128     $bdir =~ s/~F/$distrepo->{$smever}->{fedora}/;
129 slords 1.30 for my $arch ( @archs, 'SRPMS/' ) {
130     my $adir = $bdir;
131     if ( $arch eq 'SRPMS/' ) {
132     $adir =~ s/~A.*/$arch/ if $arch eq 'SRPMS/';
133     } else {
134     $adir =~ s/~A/$arch/;
135     }
136     opendir DIR, $adir or next;
137     next unless -d $adir;
138     process_rpm("$adir$_", $smever, $baserepo->{$dir}) foreach readdir DIR;
139     closedir DIR;
140     last unless $dir =~ m{~A};
141 slords 1.20 }
142     }
143 slords 1.30 find( { wanted => sub { process_rpm($_, $smever, 'builds'); }, no_chdir => 1, follow_fast => 1 }, ( $distrepo->{$smever}->{'builds'}, $distrepo->{$smever}->{'qa'} ) );
144     find( { wanted => sub { process_rpm($_, $smever, 'contribs'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$smever}->{'contribs'} );
145 slords 1.20
146 slords 1.30 foreach my $base ( sort keys %$rpms ) {
147     my %track = ();
148 slords 1.20 my %seen = ();
149 slords 1.30 my %counts = ();
150     my $acnt = ();
151     my $print = 0;
152     %latest = ();
153    
154     foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) {
155     next if $pkg->{done};
156    
157     if ( $rpms->{$base}->{vers}->{$pkg->{svr}} ) {
158     foreach my $tmp ( @{$rpms->{$base}->{vers}->{$pkg->{svr}}} ) {
159     $tmp->{svr} = $pkg->{svr};
160     push @{$rpms->{$base}->{rpms}}, $tmp;
161     }
162     } else {
163     my $tmp = $pkg->{svr};
164     ($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last;
165     ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last;
166     ($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last;
167     ($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.dag} && $rpms->{$base}->{vers}->{$tmp} && last;
168     ($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d\.rf$}{$1.dag} && $rpms->{$base}->{vers}->{$tmp} && last;
169     ($tmp = $pkg->{svr}) =~ s{\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last;
170     ($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last;
171     ($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last;
172     ($tmp = $pkg->{svr}) =~ s{\.el\d\.sme$}{} && $rpms->{$base}->{vers}->{$tmp} && last;
173     if ( $rpms->{$base}->{vers}->{$tmp} ) {
174     foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) {
175     $tmp->{svr} = $pkg->{svr};
176     push @{$rpms->{$base}->{rpms}}, $tmp;
177 slords 1.20 }
178 slords 1.30 }
179 slords 1.20 }
180    
181 slords 1.30 my %orig = ();
182     my %pkgs = ();
183     my %reposrc = ();
184     my $srpm = undef;
185     foreach my $cmp ( sort { $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} || $a->{src} <=> $b->{src} } @{$rpms->{$base}->{rpms}} ) {
186     next unless $cmp->{svr} eq $pkg->{svr};
187    
188     if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) {
189     $track{repo} = $cmp->{repo};
190     $track{svr} = $cmp->{svr};
191 slords 1.20 }
192 slords 1.30 if ( $cmp->{svr} eq $track{svr} ) {
193     if ( $cmp->{src} ) {
194     $srpm = $cmp unless $srpm;
195     if ( $reposrc{$cmp->{repo}} ) {
196     $reposrc{$cmp->{repo}}->{srpm} = $cmp;
197     $cmp->{latest}++ if $reposrc{$cmp->{repo}}->{latest};
198     } elsif ( ! $repos->{$cmp->{repo}}->{base} ) {
199     $cmp->{delete}++;
200     }
201     } elsif ( $seen{$cmp->{nvra}} ) {
202     if ( $track{repo} ne $cmp->{repo} ) {
203     if ($repos->{$cmp->{repo}}->{stage} ) {
204     if ( $seen{$cmp->{nvra}}->{latest} ) {
205     $seen{$cmp->{nvra}}->{latest}++;
206     } else {
207     $cmp->{delete}++;
208     }
209     } elsif ( $repos->{$cmp->{repo}}->{orig}) {
210     $orig{$cmp->{nvra}}++;
211     } elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) {
212     $cmp->{delete}++;
213 slords 1.26 }
214 slords 1.20 }
215 slords 1.30 } elsif ($repos->{$cmp->{repo}}->{stage} ) {
216     $cmp->{delete}++;
217     } else {
218     my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
219     $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
220     $dest = $devel1 if verrel($cmp, $dest, \%counts);
221     if ( $cmp->{repo} ne $dest ) {
222     push @{$cmp->{repos}}, $dest;
223     if ( $repos->{$cmp->{repo}}->{orig} ) {
224     $orig{$cmp->{nvra}}++;
225     } else {
226     $cmp->{delete}++;
227 slords 1.21 }
228 slords 1.30 $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
229     $cmp->{repo} = $dest;
230 slords 1.20 }
231     }
232 slords 1.30 } else {
233     if ( $track{repo} eq $cmp->{repo} ) {
234     if ( verrel($cmp, $cmp->{repo}, \%counts) ) {
235     $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
236 slords 1.18 } else {
237 slords 1.30 $track{svr} = $cmp->{svr};
238 slords 1.11 }
239 slords 1.30 } elsif ( ! $repos->{$cmp->{repo}}->{base} ) {
240     $cmp->{delete}++;
241     }
242     }
243     $reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{delete} || $repos->{$cmp->{repo}}->{base};
244     unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) {
245     $pkgs{$cmp->{nvra}}++;
246     $latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}};
247     unless ( $seen{$cmp->{nvra}} ) {
248     $seen{$cmp->{nvra}} = $cmp;
249     $cmp->{latest}++ if $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc};
250 slords 1.20 }
251 slords 1.30 push @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{$cmp->{src} ? 'src' : $cmp->{rpm}->arch}}, $cmp;
252 slords 1.20 }
253 slords 1.30 $cmp->{done}++;
254 slords 1.20 }
255 slords 1.30 if ( $srpm ) {
256     foreach my $r ( keys %reposrc ) {
257     next if $repos->{$r}->{orig};
258     unless ( $reposrc{$r}->{srpm} ) {
259     push @{$srpm->{repos}}, $r;
260     $pkgs{$srpm->{nvra}}++;
261     $orig{$srpm->{nvra}}++ if $repos->{$srpm->{repo}}->{orig};
262     $srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo};
263     $srpm->{repo} = $r;
264     $reposrc{$r}->{srpm} = $srpm;
265     }
266 slords 1.20 }
267 slords 1.30 } elsif ( scalar keys %pkgs ) {
268     print "\n * missing source (", $pkg->{svr}, ")\n";
269 slords 1.20 }
270 slords 1.30 print "\n * missing originals (", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs;
271 slords 1.20 }
272 slords 1.30
273     foreach my $r ( keys %$acnt ) {
274     foreach my $p ( keys %{$acnt->{$r}} ) {
275     foreach my $a ( keys %{$acnt->{$r}->{$p}} ) {
276 slords 1.20 if ( $a eq 'noarch' ) {
277 slords 1.30 my $p2 = ${$acnt->{$r}->{$p}->{$a}}[0];
278     if ( ! $p2->{repos} && scalar @{$acnt->{$r}->{$p}->{$a}} != scalar @archs ) {
279     $p2->{oldrepo} = $p2->{repo};
280     push @{$p2->{repos}}, $p2->{repo};
281     }
282     } elsif ( scalar @{$acnt->{$r}->{$p}->{$a}} != 1 ) {
283     print "\n * many packages ($r, $a, $p)\n";
284 slords 1.20 }
285     }
286     }
287     }
288 slords 1.25
289 slords 1.30 foreach my $pkg ( sort { $a->{nvra} cmp $b->{nvra} } @{$rpms->{$base}->{rpms}} ) {
290     if ( $pkg->{latest} && $pkg->{latest} == 1 ) {
291     $pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo};
292     $pkg->{repo} = $stage;
293     push @{$pkg->{repos}}, $stage;
294     }
295     if ( ! $print && ($pkg->{delete} || $pkg->{repos} || $pkg->{nosig} ) ) {
296     print "\n$base (sme$smever)\n", "=" x length("$base (sme$smever)"), "\n";
297     $print++;
298     }
299 slords 1.20
300     my $src = $pkg->{rpm}->filename;
301 slords 1.30 if ( $pkg->{nosig} ) {
302     print "sign package (", basename($pkg->{rpm}->filename), ")\n";
303     unless ( $opts{t} ) {
304     qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null);
305     if ($?) {
306     print " * failed to sign package\n";
307     next;
308     }
309     }
310     }
311 slords 1.20
312     if ( $pkg->{repos} ) {
313 slords 1.30 foreach my $repo ( @{$pkg->{repos}} ) {
314     if ( $pkg->{delete} ) {
315     print "move from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
316     $pkg->{delete} = 0;
317     $repochg{$pkg->{oldrepo}}++ unless $repos->{$pkg->{oldrepo}}->{base} || $repos->{$pkg->{oldrepo}}->{stage};
318     } elsif ( $pkg->{oldrepo} eq $repo ) {
319     print "distribute noarch in $repo (", basename($pkg->{rpm}->filename), ")\n";
320     } else {
321     print "copy from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
322     }
323     $repochg{$repo}++ unless $repos->{$repo}->{base} || $repos->{$repo}->{stage};
324     $pkg->{oldrepo} = $repo unless $pkg->{oldrepo} eq ${$pkg->{repos}}[0];
325    
326     my @d = ();
327     my $head = $distrepo->{$smever}->{repo} . $repo . '/';
328     $head = $distrepo->{$smever}->{stage} if $repos->{$repo}->{stage};
329     my $tail = $repos->{$repo}->{os} ? 'SME/' . $distrepo->{$smever}->{os} : 'RPMS/';
330     if ( $pkg->{src} ) {
331     push @d, "${head}SRPMS/" . basename($pkg->{rpm}->filename);
332     } elsif ( $pkg->{rpm}->arch eq 'noarch' ) {
333     push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @archs;
334     } elsif ( $pkg->{rpm}->arch =~ m{^(i[356]86)$} ) {
335     push @d, "${head}i386/$tail" . basename($pkg->{rpm}->filename);
336     } else {
337     push @d, $head . $pkg->{rpm}->arch . "/$tail" . basename($pkg->{rpm}->filename);
338     }
339     foreach my $dest ( @d ) {
340     qx(cp --preserve=timestamps $src $dest) unless $opts{t} || -f "$dest";
341     }
342    
343 slords 1.11 }
344 slords 1.30 qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t};
345     } elsif ( $pkg->{delete} ) {
346     print "delete from ", $pkg->{repo}, " (", basename($pkg->{rpm}->filename), ")\n";
347 slords 1.20 qx(rm -f $src);
348 slords 1.30 $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
349 slords 1.20 }
350     }
351 slords 1.30 }
352    
353     if ( %repochg ) {
354     print "\nrebuild repo (sme$smever)\n", "=" x length("rebuild repo (sme$smever)"), "\n";
355     }
356     foreach my $repo ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %repochg ) {
357     next if $repos->{$repo}->{orig} || $repos->{$repo}->{stage};
358     foreach my $arch ( @archs ) {
359     my $dir = $distrepo->{$smever}->{repo} . "$repo/$arch";
360     $dir = qx(readlink -f $dir);
361     chomp $dir;
362     print "rebuild $repo/$arch\n";
363     unless ( $opts{t} ) {
364     if ( -f "$dir/repodata/comps.xml" ) {
365     qx(createrepo -g $dir/repodata/comps.xml $dir);
366     } else {
367     qx(createrepo $dir);
368     }
369 slords 1.20 qx(repoview $dir);
370     qx(rm -rf $dir/.olddata) if -d "$dir/.olddata";
371     qx(rm -rf $dir/.repodata) if -d "$dir/.repodata";
372     }
373 slords 1.11 }
374 slords 1.20 }
375 slords 1.30 unless ( $opts{t} ) {
376     finddepth(sub{rmdir}, $distrepo->{$smever}->{$_}) foreach ('builds','contribs','qa');
377     }
378 slords 1.1 }
379    
380 slords 1.30 sub verrel {
381     my $pkg = shift;
382     my $repo = shift;
383     my $counts = shift;
384 slords 1.20
385 slords 1.30 $counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++;
386     return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver};
387     return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel};
388     return 0;
389 slords 1.20 }
390    
391 slords 1.30 sub pkgdest {
392 slords 1.20 my $pkg = shift;
393 slords 1.30 my $dest = shift;
394     my $hirepo = shift;
395     my $pkgs = shift;
396    
397     foreach my $cmp ( @$pkgs ) {
398     next if $cmp->{src} || $cmp->{name} ne $pkg->{name} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio};
399     if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) {
400     $dest = $hirepo;
401     last;
402 slords 1.20 } else {
403 slords 1.30 $dest = $cmp->{repo};
404 slords 1.20 }
405     }
406 slords 1.30 return $dest;
407 slords 1.20 }
408    
409 slords 1.30 sub process_rpm {
410     my $rpm = shift;
411     my $smever = shift;
412     my $repo = shift;
413     return unless $rpm =~ m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$};
414     my $base = $1;
415     return unless ! $opts{r} || $base =~ m[$opts{r}];
416     return unless $latest{$base} || $sources{$base} || ! $repos->{$repo}->{base};
417 slords 1.20
418     my $pkg;
419 slords 1.30 eval { $pkg = RPM2->open_package($rpm, $rpm_flags); };
420     if ($@) { print " * corrupt package ($rpm)\n"; return; }
421 slords 1.20 eval { my $sig = $pkg->siggpg };
422     my $nosig = ! $@;
423    
424 slords 1.30 my $cmp = $latest{$pkg->name};
425     if ( $repos->{$repo}->{base} && ! $pkg->is_source_package ) {
426     return unless $cmp;
427     return if $repos->{$cmp->{repo}}->{base} && $repos->{$cmp->{repo}}->{prio} > $repos->{$repo}->{prio} && $pkg ge $cmp->{rpm};
428     }
429     my ($src, $version, $release) = ($pkg->is_source_package ? $pkg->filename : $pkg->sourcerpm) =~ m{(?:^|/)([^/]*)-([^-]+)-([^-]+)\.\w+\.rpm$};
430     return if $skippkg->{$smever}->{$repo} && $skippkg->{$smever}->{$repo}->{$src};
431     return if $repos->{$repo}->{base} && $nosig;
432     if ( $nosig && ! -f "$HOME/.rpmpass" ) { print " * missing signature (" .$pkg->filename . ")\n"; return; }
433    
434     my $rpmhash = { base => $src,
435     name => $pkg->name,
436     repo => $repo,
437     nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ),
438     svr => $src.'-'.$version.'-'.$release,
439     src => $pkg->is_source_package,
440     ver => $version,
441     rel => $release,
442     rpm => $pkg,
443     nosig => $nosig,
444     };
445     if ( $pkg->is_source_package ) {
446     push @{$rpms->{$src}->{srpms}}, $rpmhash;
447     push @{$rpms->{$src}->{vers}->{$rpmhash->{svr}}}, $rpmhash;
448     } else {
449     push @{$rpms->{$src}->{rpms}}, $rpmhash;
450 slords 1.26 }
451 slords 1.30 $sources{$src}++;
452 slords 1.20
453 slords 1.30 return if $pkg->is_source_package || $repos->{$repo}->{stage};
454     if ( ! $repos->{$repo}->{base} ) {
455     if ( ! $cmp || $pkg gt $cmp->{rpm} ) {
456     $latest{$pkg->name} = $rpmhash;
457 slords 1.20 }
458 slords 1.30 } elsif ( ( $repos->{$repo}->{prio} >= $repos->{$cmp->{repo}}->{prio} || ! $repos->{$cmp->{repo}}->{base} ) && $pkg ge $cmp->{rpm} ) {
459     $latest{$pkg->name} = $rpmhash;
460 slords 1.20 }
461 slords 1.1 }

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