/[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.20 - (show annotations) (download)
Sat Nov 3 19:06:19 2007 UTC (17 years ago) by slords
Branch: MAIN
Changes since 1.19: +461 -236 lines
New updates script

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 Term::ANSIColor;
10 use Data::Dumper;
11
12 delete $ENV{PATH};
13 my $HOME=$ENV{HOME};
14 umask 002;
15
16 my $rpm_flags = RPM2->vsf_nosha1header | RPM2->vsf_nomd5header | RPM2->vsf_nodsaheader | RPM2->vsf_norsaheader;
17 $rpm_flags |= RPM2->vsf_nosha1 | RPM2->vsf_nomd5 | RPM2->vsf_nodsa | RPM2->vsf_norsa;
18
19 $Term::ANSIColor::AUTORESET = 1;
20 $| = 1;
21
22 my @archs = ( 'i386', 'x86_64' );
23
24 my $repos = { 'smeos' => { prio => 16, inc => 1, ver => 1, rel => 1, os => 1 },
25 'smeupdates' => { prio => 15, inc => 1, ver => 1, rel => 1 },
26 'smeupdates-testing' => { prio => 14, inc => 1, ver => 1, rel => 1 },
27 'smeextras' => { prio => 13, inc => 0, ver => 1, rel => 1 },
28 'smeaddons' => { prio => 12, inc => 0, ver => 1, rel => 1 },
29 'smecontribs' => { prio => 11, inc => 0, ver => 1, rel => 1 },
30 'smetest' => { prio => 10, inc => 1, ver => 2, rel => 2, devel => 2 },
31 'smedev' => { prio => 9, inc => 0, ver => 2, rel => 2, devel => 1 },
32 'centos' => { prio => 8, inc => 0, ver => 0, rel => 0, base => 1 },
33 'fedora/epel' => { prio => 7, inc => 0, ver => 0, rel => 0, base => 1 },
34 'fedora/extras' => { prio => 6, inc => 0, ver => 0, rel => 0, base => 1 },
35 'rpmforge' => { prio => 5, inc => 0, ver => 0, rel => 0, base => 1 },
36 'atrpms' => { prio => 4, inc => 0, ver => 0, rel => 0, base => 1 },
37 'fedora/core' => { prio => 3, inc => 0, ver => 0, rel => 0, base => 1 },
38 'base' => { prio => 2, inc => 0, ver => 0, rel => 0, base => 1 },
39 'builds' => { prio => 1, inc => 0, ver => 0, rel => 0, builds => 1 },
40 };
41
42 my $distrepo = { '7' => { active => 1,
43 centos => 4,
44 fedora => 3,
45 repo => '/releases/7/',
46 os => 'SME/RPMS/',
47 builds => '/builds2/smeserver-7-core/',
48 },
49 '8' => { active => 1,
50 centos => 5,
51 fedora => 6,
52 repo => '/releases/testing/8/',
53 os => 'SME/',
54 builds => '/builds2/smeserver-8-core/',
55 },
56 };
57
58 my @baserepo = ( ( map { "/mirrors/centos/~C/$_/" } ('os','updates','fasttrack','extras') ),
59 ( map { "/mirrors/fedora/epel$_/~C/" } ('','/testing') ),
60 '/mirrors/fedora/extras/~F/',
61 '/mirrors/rpmforge/dag/redhat/el~C/en/~A/RPMS.dag/',
62 '/mirrors/rpmforge/dag/source/',
63 ( map { "/mirrors/atrpms$_/el~C-~A/atrpms/stable/" } ('','/src') ),
64 ( map { "/mirrors/atrpms$_/el~C-~A/atrpms/testing/" } ('','/src') ),
65 ( map {"/mirrors/fedora/core$_/~F/" } ('','/updates') ),
66 );
67
68 my $skippkg = { '7' => { 'centos' => ['horde','imp-h3','ingo-h3','turba-h3','vim'],
69 'fedora/epel' => ['perl-Razor-Agent'],
70 'rpmforge' => ['perl-Test-Inline'],
71 'atrpms' => ['dovecot','yum'],
72 },
73 '8' => { 'centos' => ['horde','imp-h3','ingo-h3','turba-h3'],
74 'fedora/epel' => ['perl-Razor-Agent','smolt'],
75 'fedora/extras' => ['dstat','gocr','horde','oidentd','perl-Test-Inline','perl-Razor-Agent','smolt'],
76 'rpmforge' => ['perl-Test-Inline'],
77 'atrpms' => [],
78 'fedora/core' => [],
79 },
80 };
81
82 my %opts;
83 getopts( 'dtvr:', \%opts );
84 $opts{r} ||= '';
85
86 my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos;
87 $devel2 ||= $devel1;
88
89 my ($rel, @rpms, %pkgnames, %sources, $archs, $rebuild, $newline);
90 foreach my $smever ( sort { $a <=> $b } grep { $distrepo->{$_}->{active} } keys %$distrepo ) {
91 $rel = $smever;
92 %pkgnames = ();
93 %sources = ();
94 @rpms = ();
95 $rebuild = ();
96
97 # Load distro packages
98 find( { wanted => \&loadpkg, no_chdir => 1, follow_fast => 1 }, $distrepo->{$smever}->{repo}, $distrepo->{$smever}->{builds} );
99 printline('white', 0, "Distro (SME Server $rel) packages loaded.\n");
100
101 # Load base packages
102 foreach my $base ( @baserepo ) {
103 my $bdir = $base;
104 $bdir =~ s/~C/$distrepo->{$smever}->{centos}/;
105 $bdir =~ s/~F/$distrepo->{$smever}->{fedora}/;
106 if ( $bdir =~ m{~A} ) {
107 for my $arch ( @archs ) {
108 my $basearch = $bdir;
109 $basearch =~ s/~A/$arch/;
110 find( { wanted => \&loadbase, no_chdir => 1, follow_fast => 1 }, $basearch ) if -r $basearch;
111 }
112 } else {
113 find( { wanted => \&loadbase, no_chdir => 1, follow_fast => 1 }, $bdir ) if -r $bdir;
114 }
115 }
116 printline('white', 0, 'Base (Centos: ', $distrepo->{$smever}->{centos}, ', Fedora: ', $distrepo->{$smever}->{fedora}, ") packages loaded.\n");
117
118 foreach my $name ( sort keys %{{ map { $_->{base} => 1 } @rpms }} ) {
119 printline('white', 0, "Processing: $name");
120 my @pkgs = sort pkgsrt grep { $_->{base} eq $name } @rpms;
121 my %seen = ();
122 my $count = ();
123 $archs = ();
124
125 foreach my $pkg ( @pkgs ) {
126 next if $pkg->{done} || $pkg->{obsolete} || $pkg->{rpm}->is_source_package || ! $repos->{$pkg->{repo}};
127 printline('bold black', 1, ' - ', $pkg->{rpm}->filename) if $opts{d};
128 my $orig = 0;
129
130 # Find names of packages in same or higher repos
131 my %names = names($pkg, @pkgs);
132
133 # Move packages from base/builds to correct area
134 if ( rprop($pkg, 'base') || rprop($pkg, 'builds') ) {
135 printline('dark blue', 1, ' - checking base/builds') if $opts{d};
136 my $repo = $names{$pkg->{name}} && $names{$pkg->{name}} > 1 ? $devel2 : $devel1;
137 if ( $pkg->{nonbase} ) {
138 foreach my $up ( grep { $_->{name} eq $pkg->{name} && $_->{rpm} lt $pkg->{rpm} && $_->{obsolete} } @rpms ) {
139 next if rprop($up, 'builds') || rprop($up, 'base');
140 $repo = $up->{repo};
141 last;
142 }
143 }
144 next if rprop($pkg, 'base') && $repo eq $devel1 && $devel1 ne $devel2;
145 movepkg($pkg, $repo);
146 %names = names($pkg, @pkgs);
147 $seen{$pkg->{nvra}}++;
148 $orig++;
149 }
150
151 # Check version/release counts
152 unless ( $pkg->{nonbase} ) {
153 printline('dark blue', 1, ' - checking version/release counts') if $opts{d};
154 $count->{$pkg->{repo}}->{$pkg->{version}}->{$pkg->{release}}++;
155 if ( rprop($pkg, 'ver') && scalar keys %{$count->{$pkg->{repo}}} > rprop($pkg, 'ver') ) {
156 movepkg($_, 'delete') foreach grep { $_->{rpm} eq $pkg->{rpm} } @pkgs;
157 next;
158 }
159 if ( rprop($pkg, 'rel') && scalar keys %{$count->{$pkg->{repo}}->{$pkg->{version}}} > rprop($pkg, 'rel') ) {
160 movepkg($_, 'delete') foreach grep { $_->{rpm} eq $pkg->{rpm} } @pkgs;
161 next;
162 }
163 }
164
165 foreach my $cmp ( grep { $_->{rpm}->is_source_package || ( ! $_->{done} && $_->{rpm} le $pkg->{rpm} && rprop($_, 'prio') <= rprop($pkg, 'prio') ) } @pkgs ) {
166 printline('dark blue', 1, ' - ', $cmp->{rpm}->filename) if $opts{d};
167 if ( $cmp->{rpm}->is_source_package ) {
168 if ( $cmp->{name} eq $pkg->{base} ) {
169 if ( $cmp->{rpm} eq $pkg->{rpm} ) {
170 $pkg->{srpm} = $cmp if ! $pkg->{srpm} || $pkg->{srpm}->{rpm} ne $pkg->{rpm} || $pkg->{srpm}->{repo} ne $pkg->{repo};
171 tagpkg($cmp, 'inuse', 0) if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds');
172 }
173 next if $pkg->{srpm} && $pkg->{srpm}->{rpm} eq $pkg->{rpm};
174
175 my $src = $pkg->{rpm}->sourcerpm;
176 my $source = basename $cmp->{rpm}->filename;
177 SRC: {
178 $src eq $source && last SRC;
179 ($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d\.at(\.src)}{$1} && $src eq $source && last SRC;
180 ($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d(\.rf\.src)}{$1} && $src eq $source && last SRC;
181 ($src = $pkg->{rpm}->sourcerpm) =~ s{(\d+)\.\d+\.el\d(\.rf\.src)}{$1$2} && $src eq $source && last SRC;
182 ($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d\.rf(\.src)}{.dag$1} && $src eq $source && last SRC;
183 ($src = $pkg->{rpm}->sourcerpm) =~ s{(\d+)\.\d+\.el\d\.rf(\.src)}{$1.dag$2} && $src eq $source && last SRC;
184 ($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d(\.src)}{$1} && $src eq $source && last SRC;
185 ($src = $pkg->{rpm}->sourcerpm) =~ s{(-\d+)\.\d+\.el\d(\.src)}{$1$2} && $src eq $source && last SRC;
186 ($src = $pkg->{rpm}->sourcerpm) =~ s{\.centos\d(\.src)}{$1} && $src eq $source && last SRC;
187 ($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d\.sme(\.src)}{$1} && $src eq $source && last SRC;
188 $src = '';
189 }
190 if ( $src eq $source && ( ! $pkg->{srpm} || $pkg->{srpm}->{rpm} eq $cmp->{rpm} ) ) {
191 $pkg->{srpm} = $cmp if ! $pkg->{srpm} || ( $pkg->{srpm}->{rpm} eq $pkg->{rpm} && $pkg->{srpm}->{repo} ne $pkg->{repo} );
192 tagpkg($cmp, 'inuse', 0) if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds');
193 }
194 }
195 } elsif ( $cmp->{rpm} eq $pkg->{rpm} ) {
196 if ( $names{$cmp->{name}} ) {
197 if ( $pkg->{repo} eq $cmp->{repo} ) {
198 tagpkg($cmp, 'correct', 1);
199 $seen{$cmp->{nvra}}++;
200 } elsif ( $seen{$cmp->{nvra}} ) {
201 $orig++ if rprop($cmp, 'base') || rprop($cmp, 'builds');
202 movepkg($cmp, 'delete', 1);
203 } else {
204 movepkg($cmp, $pkg->{repo}, 1, 1);
205 $seen{$cmp->{nvra}}++;
206 }
207 } else {
208 tagpkg($cmp, 'nonbase', 0);
209 }
210 } elsif ( rprop($cmp, 'prio') < rprop($pkg, 'prio') ) {
211 tagpkg($cmp, 'obsolete', 0);
212 }
213 }
214 printline('dark blue', 1, ' - checking source packages') if $opts{d};
215 if ( ! $pkg->{srpm} ) {
216 printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (missing source ', $pkg->{rpm}->sourcerpm, ')');
217 } elsif ( $pkg->{srpm}->{repo} ne $pkg->{repo} ) {
218 movepkg($pkg->{srpm}, $pkg->{repo}, 0);
219 }
220 unless ( $orig ) {
221 foreach ( grep { $_->{base} eq $pkg->{base} && $_->{repo} eq $pkg->{repo} } @pkgs ) {
222 printline('bold yellow on_red', 1, ' - ', $_->{rpm}->filename, ' (missing original)');
223 }
224 }
225 }
226 printline('bold black', 1, ' - obsolete packages') if $opts{d};
227 movepkg($_, 'delete') foreach grep { ! rprop($_, 'base') && ! $_->{done} && ( $_->{obsolete} || ( $_->{rpm}->is_source_package && ! $_->{inuse} ) ) } @pkgs;
228
229 printline('bold black', 1, ' - arch count check') if $opts{d};
230 foreach my $r ( keys %$archs ) {
231 foreach my $p ( keys %{$archs->{$r}} ) {
232 foreach my $a ( keys %{$archs->{$r}->{$p}} ) {
233 my $p2 = ${$archs->{$r}->{$p}->{$a}}[0];
234 if ( $a eq 'noarch' ) {
235 movepkg($p2, $p2->{repo}, 0) if ! $p2->{repos} && scalar @{$archs->{$r}->{$p}->{$a}} != scalar @archs;
236 } elsif ( scalar @{$archs->{$r}->{$p}->{$a}} != 1 ) {
237 printline('bold yellow on_red', 1, ' - ', $p2->{rpm}->filename, ' (many arch)');
238 }
239 }
240 }
241 }
242 }
243 printline('white', 0, "Finished processing.\n");
244
245 unless ( $opts{t} || $opts{r} ) {
246 my %repochg = ();
247 # Move / Copy / Delete packages and tag repo for rebuild.
248 foreach my $pkg ( grep { $_->{oldrepo} } @rpms ) {
249 printline('white', 0, 'Copy/move: ', $pkg->{rpm}->filename);
250 my $src = $pkg->{rpm}->filename;
251
252 qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null) if $pkg->{nosig};
253 if ( $pkg->{repos} ) {
254 foreach my $dest ( dest($pkg, @{$pkg->{repos}}) ) {
255 qx(cp --preserve=timestamps $src $dest) unless -f $dest;
256 }
257 $repochg{$_}++ foreach @{$pkg->{repos}};
258 }
259 if ( $pkg->{remove} ) {
260 qx(rm -f $src);
261 $repochg{$pkg->{oldrepo}}++;
262 }
263 }
264 finddepth(sub{rmdir}, $distrepo->{$rel}->{builds});
265 printline('white', 0, "Finished copying/moving.\n");
266
267 foreach my $repo ( sort keys %repochg ) {
268 next if ! $repos->{$repo} || $repos->{$repo}->{base} || $repos->{$repo}->{builds};
269 foreach my $arch ( @archs ) {
270 my $dir = $distrepo->{$rel}->{repo} . "$repo/$arch";
271 $dir = qx(readlink -f $dir);
272 chomp $dir;
273 printline('white', 0, "Createrepo: $repo/$arch");
274 qx(createrepo $dir);
275 printline('white', 0, "Repoview: $repo/$arch");
276 qx(repoview $dir);
277 qx(rm -rf $dir/.olddata) if -d "$dir/.olddata";
278 qx(rm -rf $dir/.repodata) if -d "$dir/.repodata";
279 }
280 }
281 printline('white', 0, "Finished rebuilding repos.\n");
282 }
283
284 print "\n================================================================================\n\n";
285 }
286
287 sub pkgsrt {
288 return $b->{rpm} cmp $a->{rpm} || rprop($b, 'prio') <=> rprop($a, 'prio') || $a->{arch} cmp $b->{arch} || $a->{name} cmp $b->{name};
289 }
290
291 sub rprop {
292 my ($pkg, $prop) = @_;
293 return $repos->{$pkg->{repo}} ? $repos->{$pkg->{repo}}->{$prop} : 0;
294 }
295
296 sub names {
297 my $pkg = shift;
298 my @rpms = @_;
299 return map { $_->{name} => rprop($_, 'inc') ? 2 : 1 } grep { $_->{base} eq $pkg->{base} &&
300 rprop($_, 'prio') >= rprop($pkg, 'prio') &&
301 ! rprop($_, 'base') &&
302 ! rprop($_, 'builds') &&
303 ! $_->{rpm}->is_source_package
304 } @rpms;
305 }
306
307 sub dest {
308 my ($pkg, @repos) = @_;
309 my @d = ();
310 foreach my $repo ( @repos ) {
311 if ( $pkg->{arch} eq 'noarch' ) {
312 push @d, $distrepo->{$rel}->{repo} .
313 "$repo/i386/" .
314 ( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) .
315 basename $pkg->{rpm}->filename;
316 push @d, $distrepo->{$rel}->{repo} .
317 "$repo/x86_64/" .
318 ( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) .
319 basename $pkg->{rpm}->filename;
320 } elsif ( $pkg->{arch} =~ m{^(i[356]86)$} ) {
321 push @d, $distrepo->{$rel}->{repo} .
322 "$repo/i386/" .
323 ( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) .
324 basename $pkg->{rpm}->filename;
325 } elsif ( $pkg->{arch} eq 'x86_64' ) {
326 push @d, $distrepo->{$rel}->{repo} .
327 "$repo/x86_64/" .
328 ( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) .
329 basename $pkg->{rpm}->filename;
330 } elsif ( $pkg->{arch} eq 'zsrc' ) {
331 push @d, $distrepo->{$rel}->{repo} .
332 "$repo/SRPMS/" .
333 basename $pkg->{rpm}->filename;
334 } else {
335 printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (bad arch: ', $pkg->{arch}, ')');
336 }
337 }
338 return @d;
339 }
340
341 sub movepkg {
342 my ($pkg, $repo, $done, $remove) = @_;
343 defined $done or $done = 2;
344 defined $remove or $remove = 0;
345 $remove = 0 if rprop($pkg, 'base') || rprop($pkg, 'builds');
346 $remove = 1 if $repo eq 'delete';
347
348 if ( $repo eq 'delete' && ( rprop($pkg, 'base') || ( rprop($pkg, 'builds') && $done == 1 ) ) ) {
349 tagpkg($pkg, 'inuse', 1);
350 } else {
351 printline('bold magenta', 1, " - ($repo) ", $pkg->{rpm}->filename) if $opts{d};
352 my $color = 'bold white';
353 $color = 'bold yellow' if rprop($pkg, 'builds');
354 $color = 'dark green' if $repos->{$repo} && $repos->{$repo}->{devel};
355 $color = 'dark red' if $repo eq 'delete';
356 push @{$pkg->{repos}}, $repo unless $repo eq 'delete';
357 $pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo};
358 $pkg->{repo} = $repo;
359 $pkg->{remove}++ if $remove;
360 printline($color, 1, ' - ', $pkg->{rpm}->filename, ' (', $pkg->{oldrepo}, " to $repo)") if $opts{v} || $opts{d};
361 done($pkg) if $done;
362 }
363 }
364
365 sub tagpkg {
366 my ($pkg, $tag, $done) = @_;
367
368 printline('bold magenta', 1, " - ($tag) ", $pkg->{rpm}->filename) if $opts{d};
369 delete $pkg->{obsolete} if $pkg->{obsolete};
370 $pkg->{$tag}++;
371 done($pkg) if $done;
372 }
373
374 sub done {
375 my $pkg = shift;
376 printline('bold yellow on_red', 1, " - ", $pkg->{rpm}->filename, " (already processed)") if $pkg->{done};
377 $pkg->{done}++;
378 delete $pkg->{obsolete} if $pkg->{obsolete};
379
380 if ( $repos->{$pkg->{repo}} && ! rprop($pkg, 'base') && ! rprop($pkg, 'builds') ) {
381 unless ( $pkg->{oldrepo} ) {
382 my $goodarch = 0;
383 $goodarch++ if $pkg->{rpm}->filename =~ m{/(i386|x86_64)/.*\.noarch\.rpm$};
384 $goodarch++ if $pkg->{rpm}->filename =~ m{/i386/.*\.(i[56]86)\.rpm$};
385 $goodarch++ if $pkg->{rpm}->filename =~ m{/(noarch|i[356]86|x86_64)/.*\.\1\.rpm$};
386 printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (wrong arch)') unless $goodarch;
387 }
388 push @{$archs->{$pkg->{repo}}->{$pkg->{rpm}->as_nvre}->{$pkg->{rpm}->is_source_package ? 'src' : $pkg->{rpm}->arch}}, $pkg;
389 }
390 }
391
392 sub printline {
393 my $color = shift;
394 my $nline = shift;
395 my $string = join '', @_;
396
397 if ( $nline ) {
398 print "\n" unless $newline;
399 $newline++;
400 } else {
401 $newline = 0;
402 print "\r\e[0K";
403 }
404 print color $color;
405 print $string;
406 print color 'reset';
407 print "\n" if $nline;
408 }
409
410 sub loadpkg {
411 printline('white', 0, "Loading: $_") if -d _;
412 return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ( ! $opts{r} || $1 =~ m{$opts{r}} );
413
414 my $pkg;
415 eval { $pkg = RPM2->open_package($_, $rpm_flags); };
416 if ($@) { printline('bold yellow on_red', 1, "Corrupt package $_"); return; }
417 eval { my $sig = $pkg->siggpg };
418 my $nosig = ! $@;
419 if ( $nosig && ! -f "$HOME/.rpmpass" ) {
420 printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)');
421 return;
422 }
423
424 my ($srcname, $version, $release) = ($pkg->is_source_package ? basename $pkg->filename : $pkg->sourcerpm) =~ m{^([^/]*)-([^-]+)-([^-]+)\.\w+.rpm};
425 foreach my $repo ( keys %{$skippkg->{$rel}} ) { return if (dirname $pkg->filename) =~ m{/$repo/} && grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; }
426 (my $reponame = dirname $pkg->filename) =~ s{^.*\d/(sme[^/]+)/.*$}{$1};
427 $reponame = 'builds' if ( dirname $pkg->filename) =~ m{/smeserver-\d+-core/};
428
429 push @rpms, { base => $srcname,
430 name => $pkg->name,
431 repo => $reponame,
432 nvra => $pkg->as_nvre . '.' . ( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ),
433 arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'),
434 version => $version,
435 release => $release,
436 rpm => $pkg,
437 nosig => $nosig,
438 };
439 $sources{$srcname}++;
440 $pkgnames{$pkg->name} = $rpms[$#rpms] if ! $pkg->is_source_package && ( ! $pkgnames{$pkg->name} || $pkg gt $pkgnames{$pkg->name}->{rpm} );
441 }
442
443 sub loadbase {
444 printline('white', 0, "Loading: $_") if -d _;
445 return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ($pkgnames{$1} || $sources{$1});
446
447 my $pkg;
448 eval { $pkg = RPM2->open_package($_, $rpm_flags); };
449 if ($@) { printline('bold yellow on_red', 1, "Corrupt package $_"); return; }
450 eval { my $sig = $pkg->siggpg };
451 unless ($@) { printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); return; }
452
453 my $cmp = $pkgnames{$pkg->name};
454 my ($srcname, $version, $release) = ($pkg->is_source_package ? basename $pkg->filename : $pkg->sourcerpm) =~ m{^([^/]*)-([^-]+)-([^-]+)\.\w+.rpm};
455 my $pkgrepo = 'base';
456 foreach my $repo ( keys %{$skippkg->{$rel}} ) {
457 if ( (dirname $pkg->filename) =~ m{/$repo/} ) {
458 return if grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}};
459 $pkgrepo = $repo;
460 return unless $pkg->is_source_package || $cmp;
461 return if ! $pkg->is_source_package && $pkg gt $cmp->{rpm} && rprop($cmp, 'base') && rprop($cmp, 'prio') > $repos->{$pkgrepo}->{prio};
462 last;
463 }
464 }
465
466 push @rpms, { base => $srcname,
467 name => $pkg->name,
468 repo => $pkgrepo,
469 nvra => $pkg->as_nvre . '.' . ( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ),
470 arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'),
471 version => $version,
472 release => $release,
473 rpm => $pkg,
474 nosig => 0,
475 };
476 if ( ! $pkg->is_source_package && $pkg ge $cmp->{rpm} && ( $repos->{$pkgrepo}->{prio} >= rprop($cmp, 'prio') || ! rprop($cmp, 'base') ) ) {
477 $pkgnames{$pkg->name} = $rpms[$#rpms];
478 }
479 }
480

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