/[smeserver]/builds_bin/update_repos
ViewVC logotype

Contents of /builds_bin/update_repos

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


Revision 1.37 - (show annotations) (download)
Tue Jan 22 20:34:23 2008 UTC (16 years, 10 months ago) by slords
Branch: MAIN
Changes since 1.36: +2 -4 lines
Remove qa build areas

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

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