21 |
|
|
22 |
my @archs = ( 'i386', 'x86_64' ); |
my @archs = ( 'i386', 'x86_64' ); |
23 |
|
|
24 |
my $repos = { 'smeos' => { prio => 16, inc => 1, ver => 1, rel => 1, os => 1 }, |
my $repos = { 'smeos' => { prio => 17, inc => 1, ver => 1, rel => 1, os => 1 }, |
25 |
'smeupdates' => { prio => 15, inc => 1, ver => 1, rel => 1 }, |
'smeupdates' => { prio => 16, inc => 1, ver => 1, rel => 1 }, |
26 |
'smeupdates-testing' => { prio => 14, inc => 1, ver => 1, rel => 1 }, |
'smeupdates-testing' => { prio => 15, inc => 1, ver => 1, rel => 1 }, |
27 |
'smeextras' => { prio => 13, inc => 0, ver => 1, rel => 1 }, |
'smeextras' => { prio => 14, inc => 0, ver => 1, rel => 1 }, |
28 |
'smeaddons' => { prio => 12, inc => 0, ver => 1, rel => 1 }, |
'smeaddons' => { prio => 13, inc => 0, ver => 1, rel => 1 }, |
29 |
'smecontribs' => { prio => 11, inc => 0, ver => 1, rel => 1 }, |
'smecontribs' => { prio => 12, inc => 0, ver => 1, rel => 1 }, |
30 |
'smetest' => { prio => 10, inc => 1, ver => 2, rel => 2, devel => 2 }, |
'smetest' => { prio => 11, inc => 1, ver => 2, rel => 2, devel => 2 }, |
31 |
'smedev' => { prio => 9, inc => 0, ver => 2, rel => 2, devel => 1 }, |
'smedev' => { prio => 10, inc => 0, ver => 2, rel => 2, devel => 1 }, |
32 |
'centos' => { prio => 8, inc => 0, ver => 0, rel => 0, base => 1 }, |
'centos' => { prio => 9, inc => 0, ver => 0, rel => 0, base => 1 }, |
33 |
'fedora/epel' => { prio => 7, inc => 0, ver => 0, rel => 0, base => 1 }, |
'fedora/epel' => { prio => 8, inc => 0, ver => 0, rel => 0, base => 1 }, |
34 |
'fedora/extras' => { prio => 6, inc => 0, ver => 0, rel => 0, base => 1 }, |
'fedora/extras' => { prio => 7, inc => 0, ver => 0, rel => 0, base => 1 }, |
35 |
'rpmforge' => { prio => 5, inc => 0, ver => 0, rel => 0, base => 1 }, |
'rpmforge' => { prio => 6, inc => 0, ver => 0, rel => 0, base => 1 }, |
36 |
'atrpms' => { prio => 4, inc => 0, ver => 0, rel => 0, base => 1 }, |
'atrpms' => { prio => 5, inc => 0, ver => 0, rel => 0, base => 1 }, |
37 |
'fedora/core' => { prio => 3, inc => 0, ver => 0, rel => 0, base => 1 }, |
'fedora/core' => { prio => 4, inc => 0, ver => 0, rel => 0, base => 1 }, |
38 |
'base' => { prio => 2, inc => 0, ver => 0, rel => 0, base => 1 }, |
'base' => { prio => 3, inc => 0, ver => 0, rel => 0, base => 1 }, |
39 |
'builds' => { prio => 1, inc => 0, ver => 0, rel => 0, builds => 1 }, |
'builds' => { prio => 2, inc => 0, ver => 0, rel => 0, builds => 1 }, |
40 |
|
'stage' => { prio => 1, inc => 0, ver => 0, rel => 0, stage => 1, os => 1 }, |
41 |
}; |
}; |
42 |
|
|
43 |
my $distrepo = { '7' => { active => 1, |
my $distrepo = { '7' => { active => 1, |
45 |
fedora => 3, |
fedora => 3, |
46 |
repo => '/releases/7/', |
repo => '/releases/7/', |
47 |
os => 'SME/RPMS/', |
os => 'SME/RPMS/', |
48 |
builds => '/builds2/smeserver-7-core/', |
builds => '/builds/smeserver-7-core/', |
49 |
|
stage => '/stage/7/', |
50 |
}, |
}, |
51 |
'8' => { active => 1, |
'8' => { active => 1, |
52 |
centos => 5, |
centos => 5, |
53 |
fedora => 6, |
fedora => 6, |
54 |
repo => '/releases/testing/8/', |
repo => '/releases/testing/8/', |
55 |
os => 'SME/', |
os => 'SME/', |
56 |
builds => '/builds2/smeserver-8-core/', |
builds => '/builds/smeserver-8-core/', |
57 |
|
stage => '/stage/8/', |
58 |
}, |
}, |
59 |
}; |
}; |
60 |
|
|
88 |
|
|
89 |
my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos; |
my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos; |
90 |
$devel2 ||= $devel1; |
$devel2 ||= $devel1; |
91 |
|
my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos; |
92 |
|
|
93 |
my ($rel, @rpms, %pkgnames, %sources, $archs, $rebuild, $newline); |
my ($rel, @rpms, %latest, %sources, $archs, $rebuild, $newline); |
94 |
foreach my $smever ( sort { $a <=> $b } grep { $distrepo->{$_}->{active} } keys %$distrepo ) { |
foreach my $smever ( sort { $a <=> $b } grep { $distrepo->{$_}->{active} } keys %$distrepo ) { |
95 |
$rel = $smever; |
$rel = $smever; |
96 |
%pkgnames = (); |
%latest = (); |
97 |
%sources = (); |
%sources = (); |
98 |
@rpms = (); |
@rpms = (); |
99 |
$rebuild = (); |
$rebuild = (); |
100 |
|
|
101 |
# Load distro packages |
# Load distro packages |
102 |
find( { wanted => \&loadpkg, no_chdir => 1, follow_fast => 1 }, $distrepo->{$smever}->{repo}, $distrepo->{$smever}->{builds} ); |
find( { wanted => \&loadpkg, no_chdir => 1, follow_fast => 1 }, map { $distrepo->{$smever}->{$_} } ('repo','builds','stage') ); |
103 |
printline('white', 0, "Distro (SME Server $rel) packages loaded.\n"); |
printline('white', 0, "Distro (SME Server $rel) packages loaded.\n"); |
104 |
|
|
105 |
# Load base packages |
# Load base packages |
119 |
} |
} |
120 |
printline('white', 0, 'Base (Centos: ', $distrepo->{$smever}->{centos}, ', Fedora: ', $distrepo->{$smever}->{fedora}, ") packages loaded.\n"); |
printline('white', 0, 'Base (Centos: ', $distrepo->{$smever}->{centos}, ', Fedora: ', $distrepo->{$smever}->{fedora}, ") packages loaded.\n"); |
121 |
|
|
122 |
|
%latest = (); |
123 |
foreach my $name ( sort keys %{{ map { $_->{base} => 1 } @rpms }} ) { |
foreach my $name ( sort keys %{{ map { $_->{base} => 1 } @rpms }} ) { |
124 |
printline('white', 0, "Processing: $name"); |
printline('white', 0, "Processing: $name"); |
125 |
my @pkgs = sort pkgsrt grep { $_->{base} eq $name } @rpms; |
my @pkgs = sort pkgsrt grep { $_->{base} eq $name } @rpms; |
135 |
# Find names of packages in same or higher repos |
# Find names of packages in same or higher repos |
136 |
my %names = names($pkg, @pkgs); |
my %names = names($pkg, @pkgs); |
137 |
|
|
138 |
|
# Stage packages should never be most current |
139 |
|
if ( rprop($pkg, 'stage') ) { |
140 |
|
printline('dark blue', 1, ' - checking stage') if $opts{d}; |
141 |
|
tagpkg($pkg, 'obsolete'); |
142 |
|
next; |
143 |
|
} |
144 |
|
|
145 |
# Move packages from base/builds to correct area |
# Move packages from base/builds to correct area |
146 |
if ( rprop($pkg, 'base') || rprop($pkg, 'builds') ) { |
elsif ( rprop($pkg, 'base') || rprop($pkg, 'builds') ) { |
147 |
printline('dark blue', 1, ' - checking base/builds') if $opts{d}; |
printline('dark blue', 1, ' - checking base/builds') if $opts{d}; |
148 |
my $repo = $names{$pkg->{name}} && $names{$pkg->{name}} > 1 ? $devel2 : $devel1; |
my $repo = $names{$pkg->{name}} && $names{$pkg->{name}} > 1 ? $devel2 : $devel1; |
149 |
if ( $pkg->{nonbase} ) { |
if ( $pkg->{nonbase} ) { |
150 |
foreach my $up ( grep { $_->{name} eq $pkg->{name} && $_->{rpm} lt $pkg->{rpm} && $_->{obsolete} } @rpms ) { |
foreach my $up ( @pkgs ) { |
151 |
next if rprop($up, 'builds') || rprop($up, 'base'); |
next if rprop($up, 'builds') || rprop($up, 'base'); |
152 |
|
next if $up->{name} ne $pkg->{name} || ! $up->{obsolete} || $up->{rpm} ge $pkg->{rpm}; |
153 |
$repo = $up->{repo}; |
$repo = $up->{repo}; |
154 |
last; |
last; |
155 |
} |
} |
180 |
if ( $cmp->{rpm}->is_source_package ) { |
if ( $cmp->{rpm}->is_source_package ) { |
181 |
if ( $cmp->{name} eq $pkg->{base} ) { |
if ( $cmp->{name} eq $pkg->{base} ) { |
182 |
if ( $cmp->{rpm} eq $pkg->{rpm} ) { |
if ( $cmp->{rpm} eq $pkg->{rpm} ) { |
183 |
$pkg->{srpm} = $cmp if ! $pkg->{srpm} || $pkg->{srpm}->{rpm} ne $pkg->{rpm} || $pkg->{srpm}->{repo} ne $pkg->{repo}; |
if ( $pkg->{repo} eq $cmp->{repo} || ! $pkg->{srpm} || $pkg->{srpm}->{rpm} ne $pkg->{rpm} ) { |
184 |
tagpkg($cmp, 'inuse', 0) if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds'); |
delete $pkg->{srpm}->{latest} if $pkg->{latest} && $pkg->{srpm} && $pkg->{srpm}->{latest}; |
185 |
|
$pkg->{srpm} = $cmp; |
186 |
|
$pkg->{srpm}->{latest}++ if $pkg->{latest}; |
187 |
|
} |
188 |
|
if ( $pkg->{latest} && rprop($cmp, 'stage') ) { |
189 |
|
tagpkg($cmp, 'inuse'); |
190 |
|
$pkg->{srpm}->{latest}++; |
191 |
|
} |
192 |
|
tagpkg($cmp, 'inuse') if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds'); |
193 |
} |
} |
194 |
next if $pkg->{srpm} && $pkg->{srpm}->{rpm} eq $pkg->{rpm}; |
next if $pkg->{srpm} && $pkg->{srpm}->{rpm} eq $pkg->{rpm}; |
195 |
|
|
209 |
$src = ''; |
$src = ''; |
210 |
} |
} |
211 |
if ( $src eq $source && ( ! $pkg->{srpm} || $pkg->{srpm}->{rpm} eq $cmp->{rpm} ) ) { |
if ( $src eq $source && ( ! $pkg->{srpm} || $pkg->{srpm}->{rpm} eq $cmp->{rpm} ) ) { |
212 |
$pkg->{srpm} = $cmp if ! $pkg->{srpm} || ( $pkg->{srpm}->{rpm} eq $pkg->{rpm} && $pkg->{srpm}->{repo} ne $pkg->{repo} ); |
if ( ! $pkg->{srpm} || $pkg->{repo} eq $cmp->{repo} ) { |
213 |
tagpkg($cmp, 'inuse', 0) if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds'); |
delete $pkg->{srpm}->{latest} if $pkg->{latest} && $pkg->{srpm} && $pkg->{srpm}->{latest}; |
214 |
|
$pkg->{srpm} = $cmp; |
215 |
|
$pkg->{srpm}->{latest}++ if $pkg->{latest}; |
216 |
|
} |
217 |
|
if ( $pkg->{latest} && rprop($cmp, 'stage') ) { |
218 |
|
tagpkg($cmp, 'inuse'); |
219 |
|
$pkg->{srpm}->{latest}++; |
220 |
|
} |
221 |
|
tagpkg($cmp, 'inuse') if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds'); |
222 |
} |
} |
223 |
} |
} |
224 |
} elsif ( $cmp->{rpm} eq $pkg->{rpm} ) { |
} elsif ( $cmp->{rpm} eq $pkg->{rpm} ) { |
226 |
if ( $pkg->{repo} eq $cmp->{repo} ) { |
if ( $pkg->{repo} eq $cmp->{repo} ) { |
227 |
tagpkg($cmp, 'correct', 1); |
tagpkg($cmp, 'correct', 1); |
228 |
$seen{$cmp->{nvra}}++; |
$seen{$cmp->{nvra}}++; |
229 |
|
} elsif ( $seen{$cmp->{nvra}} && rprop($cmp, 'stage') && $pkg->{latest} ) { |
230 |
|
$_->{latest}++ foreach grep { $_->{nvra} eq $cmp->{nvra} && $_->{latest} && $_->{done} } @pkgs; |
231 |
|
tagpkg($cmp, 'correct', 1); |
232 |
} elsif ( $seen{$cmp->{nvra}} ) { |
} elsif ( $seen{$cmp->{nvra}} ) { |
233 |
$orig++ if rprop($cmp, 'base') || rprop($cmp, 'builds'); |
$orig++ if rprop($cmp, 'base') || rprop($cmp, 'builds'); |
234 |
movepkg($cmp, 'delete', 1); |
movepkg($cmp, 'delete', 1); |
237 |
$seen{$cmp->{nvra}}++; |
$seen{$cmp->{nvra}}++; |
238 |
} |
} |
239 |
} else { |
} else { |
240 |
tagpkg($cmp, 'nonbase', 0); |
tagpkg($cmp, 'nonbase'); |
241 |
} |
} |
242 |
} elsif ( rprop($cmp, 'prio') < rprop($pkg, 'prio') ) { |
} elsif ( rprop($cmp, 'prio') < rprop($pkg, 'prio') ) { |
243 |
tagpkg($cmp, 'obsolete', 0); |
tagpkg($cmp, 'obsolete'); |
244 |
} |
} |
245 |
} |
} |
246 |
printline('dark blue', 1, ' - checking source packages') if $opts{d}; |
printline('dark blue', 1, ' - checking source packages') if $opts{d}; |
255 |
} |
} |
256 |
} |
} |
257 |
} |
} |
|
printline('bold black', 1, ' - obsolete packages') if $opts{d}; |
|
|
movepkg($_, 'delete') foreach grep { ! rprop($_, 'base') && ! $_->{done} && ( $_->{obsolete} || ( $_->{rpm}->is_source_package && ! $_->{inuse} ) ) } @pkgs; |
|
|
|
|
258 |
printline('bold black', 1, ' - arch count check') if $opts{d}; |
printline('bold black', 1, ' - arch count check') if $opts{d}; |
259 |
foreach my $r ( keys %$archs ) { |
foreach my $r ( keys %$archs ) { |
260 |
foreach my $p ( keys %{$archs->{$r}} ) { |
foreach my $p ( keys %{$archs->{$r}} ) { |
268 |
} |
} |
269 |
} |
} |
270 |
} |
} |
271 |
|
|
272 |
|
printline('bold black', 1, ' - missing stage packages') if $opts{d}; |
273 |
|
movepkg($_, $stage, 0) foreach grep { $_->{latest} && $_->{latest} == 1 } @pkgs; |
274 |
|
|
275 |
|
printline('bold black', 1, ' - obsolete packages') if $opts{d}; |
276 |
|
movepkg($_, 'delete') foreach grep { ! rprop($_, 'base') && ! $_->{done} && ( $_->{obsolete} || ( $_->{rpm}->is_source_package && ! $_->{inuse} ) ) } @pkgs; |
277 |
} |
} |
278 |
printline('white', 0, "Finished processing.\n"); |
printline('white', 0, "Finished processing.\n"); |
279 |
|
|
287 |
qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null) if $pkg->{nosig}; |
qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null) if $pkg->{nosig}; |
288 |
if ( $pkg->{repos} ) { |
if ( $pkg->{repos} ) { |
289 |
foreach my $dest ( dest($pkg, @{$pkg->{repos}}) ) { |
foreach my $dest ( dest($pkg, @{$pkg->{repos}}) ) { |
290 |
qx(cp --preserve=timestamps $src $dest) unless -f $dest; |
qx(cp --preserve=timestamps $src $dest) unless -f "$dest"; |
291 |
} |
} |
292 |
$repochg{$_}++ foreach @{$pkg->{repos}}; |
$repochg{$_}++ foreach @{$pkg->{repos}}; |
293 |
} |
} |
300 |
printline('white', 0, "Finished copying/moving.\n"); |
printline('white', 0, "Finished copying/moving.\n"); |
301 |
|
|
302 |
foreach my $repo ( sort keys %repochg ) { |
foreach my $repo ( sort keys %repochg ) { |
303 |
next if ! $repos->{$repo} || $repos->{$repo}->{base} || $repos->{$repo}->{builds}; |
next if ! $repos->{$repo} || $repos->{$repo}->{base} || $repos->{$repo}->{builds} || $repos->{$repo}->{stage}; |
304 |
foreach my $arch ( @archs ) { |
foreach my $arch ( @archs ) { |
305 |
my $dir = $distrepo->{$rel}->{repo} . "$repo/$arch"; |
my $dir = $distrepo->{$rel}->{repo} . "$repo/$arch"; |
306 |
$dir = qx(readlink -f $dir); |
$dir = qx(readlink -f $dir); |
320 |
} |
} |
321 |
|
|
322 |
sub pkgsrt { |
sub pkgsrt { |
323 |
return $b->{rpm} cmp $a->{rpm} || rprop($b, 'prio') <=> rprop($a, 'prio') || $a->{arch} cmp $b->{arch} || $a->{name} cmp $b->{name}; |
return $a->{rpm}->is_source_package <=> $b->{rpm}->is_source_package || $b->{rpm} cmp $a->{rpm} || rprop($b, 'prio') <=> rprop($a, 'prio'); |
324 |
} |
} |
325 |
|
|
326 |
sub rprop { |
sub rprop { |
343 |
my ($pkg, @repos) = @_; |
my ($pkg, @repos) = @_; |
344 |
my @d = (); |
my @d = (); |
345 |
foreach my $repo ( @repos ) { |
foreach my $repo ( @repos ) { |
346 |
|
my $base = $distrepo->{$rel}->{repo} . $repo; |
347 |
|
$base = $distrepo->{$rel}->{stage} if $repos->{$repo}->{stage}; |
348 |
if ( $pkg->{arch} eq 'noarch' ) { |
if ( $pkg->{arch} eq 'noarch' ) { |
349 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/i386/" . |
|
"$repo/i386/" . |
|
350 |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
351 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
352 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/x86_64/" . |
|
"$repo/x86_64/" . |
|
353 |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
354 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
355 |
} elsif ( $pkg->{arch} =~ m{^(i[356]86)$} ) { |
} elsif ( $pkg->{arch} =~ m{^(i[356]86)$} ) { |
356 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/i386/" . |
|
"$repo/i386/" . |
|
357 |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
358 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
359 |
} elsif ( $pkg->{arch} eq 'x86_64' ) { |
} elsif ( $pkg->{arch} eq 'x86_64' ) { |
360 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/x86_64/" . |
|
"$repo/x86_64/" . |
|
361 |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
362 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
363 |
} elsif ( $pkg->{arch} eq 'zsrc' ) { |
} elsif ( $pkg->{arch} eq 'zsrc' ) { |
364 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/SRPMS/" . |
|
"$repo/SRPMS/" . |
|
365 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
366 |
} else { |
} else { |
367 |
printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (bad arch: ', $pkg->{arch}, ')'); |
printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (bad arch: ', $pkg->{arch}, ')'); |
396 |
|
|
397 |
sub tagpkg { |
sub tagpkg { |
398 |
my ($pkg, $tag, $done) = @_; |
my ($pkg, $tag, $done) = @_; |
399 |
|
defined $done or $done = 0; |
400 |
|
|
401 |
printline('bold magenta', 1, " - ($tag) ", $pkg->{rpm}->filename) if $opts{d}; |
printline('bold magenta', 1, " - ($tag) ", $pkg->{rpm}->filename) if $opts{d}; |
402 |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
411 |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
412 |
|
|
413 |
if ( $repos->{$pkg->{repo}} && ! rprop($pkg, 'base') && ! rprop($pkg, 'builds') ) { |
if ( $repos->{$pkg->{repo}} && ! rprop($pkg, 'base') && ! rprop($pkg, 'builds') ) { |
414 |
|
# FIXME: Nasty hack for comps package |
415 |
|
if ( $pkg->{name} eq 'comps' ) { |
416 |
|
if ( ! $latest{$pkg->{name}.'.'.$pkg->{arch}} || $latest{$pkg->{name}.'.'.$pkg->{arch}}->{rpm} eq $pkg->{rpm} ) { |
417 |
|
if ( rprop($pkg, 'inc') && ! $pkg->{rpm}->is_source_package ) { |
418 |
|
$latest{$pkg->{name}.'.'.$pkg->{arch}} = $pkg if ! $latest{$pkg->{name}.'.'.$pkg->{arch}}; |
419 |
|
$pkg->{latest}++; |
420 |
|
} |
421 |
|
} |
422 |
|
} elsif ( ! $latest{$pkg->{name}} || $latest{$pkg->{name}}->{rpm} eq $pkg->{rpm} ) { |
423 |
|
if ( rprop($pkg, 'inc') && ! $pkg->{rpm}->is_source_package ) { |
424 |
|
$latest{$pkg->{name}} = $pkg if ! $latest{$pkg->{name}}; |
425 |
|
$pkg->{latest}++; |
426 |
|
} |
427 |
|
} |
428 |
unless ( $pkg->{oldrepo} ) { |
unless ( $pkg->{oldrepo} ) { |
429 |
my $goodarch = 0; |
my $goodarch = 0; |
430 |
$goodarch++ if $pkg->{rpm}->filename =~ m{/(i386|x86_64)/.*\.noarch\.rpm$}; |
$goodarch++ if $pkg->{rpm}->filename =~ m{/(i386|x86_64)/.*\.noarch\.rpm$}; |
470 |
|
|
471 |
my ($srcname, $version, $release) = ($pkg->is_source_package ? basename $pkg->filename : $pkg->sourcerpm) =~ m{^([^/]*)-([^-]+)-([^-]+)\.\w+.rpm}; |
my ($srcname, $version, $release) = ($pkg->is_source_package ? basename $pkg->filename : $pkg->sourcerpm) =~ m{^([^/]*)-([^-]+)-([^-]+)\.\w+.rpm}; |
472 |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { return if (dirname $pkg->filename) =~ m{/$repo/} && grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; } |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { return if (dirname $pkg->filename) =~ m{/$repo/} && grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; } |
473 |
(my $reponame = dirname $pkg->filename) =~ s{^.*\d/(sme[^/]+)/.*$}{$1}; |
my $reponame = 'unknown'; |
474 |
$reponame = 'builds' if ( dirname $pkg->filename) =~ m{/smeserver-\d+-core/}; |
if ( substr($_, 0, length($distrepo->{$rel}->{builds})) eq $distrepo->{$rel}->{builds} ) { |
475 |
|
$reponame = 'builds'; |
476 |
|
} elsif ( substr($_, 0, length($distrepo->{$rel}->{stage})) eq $distrepo->{$rel}->{stage} ) { |
477 |
|
$reponame = 'stage'; |
478 |
|
} elsif ( (dirname $pkg->filename) =~ m{\d/(sme[^/]+)/} ) { |
479 |
|
$reponame = $1; |
480 |
|
} |
481 |
|
|
482 |
push @rpms, { base => $srcname, |
push @rpms, { base => $srcname, |
483 |
name => $pkg->name, |
name => $pkg->name, |
484 |
repo => $reponame, |
repo => $reponame, |
485 |
nvra => $pkg->as_nvre . '.' . ( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ), |
nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ), |
486 |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
487 |
version => $version, |
version => $version, |
488 |
release => $release, |
release => $release, |
490 |
nosig => $nosig, |
nosig => $nosig, |
491 |
}; |
}; |
492 |
$sources{$srcname}++; |
$sources{$srcname}++; |
493 |
$pkgnames{$pkg->name} = $rpms[$#rpms] if ! $pkg->is_source_package && ( ! $pkgnames{$pkg->name} || $pkg gt $pkgnames{$pkg->name}->{rpm} ); |
if ( ! $pkg->is_source_package && ! $repos->{$reponame}->{stage} ) { |
494 |
|
$latest{$pkg->name} = $rpms[$#rpms] if ! $latest{$pkg->name} || $pkg gt $latest{$pkg->name}->{rpm}; |
495 |
|
} |
496 |
} |
} |
497 |
|
|
498 |
sub loadbase { |
sub loadbase { |
499 |
printline('white', 0, "Loading: $_") if -d _; |
printline('white', 0, "Loading: $_") if -d _; |
500 |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ($pkgnames{$1} || $sources{$1}); |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ($latest{$1} || $sources{$1}); |
501 |
|
|
502 |
my $pkg; |
my $pkg; |
503 |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
505 |
eval { my $sig = $pkg->siggpg }; |
eval { my $sig = $pkg->siggpg }; |
506 |
unless ($@) { printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); return; } |
unless ($@) { printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); return; } |
507 |
|
|
508 |
my $cmp = $pkgnames{$pkg->name}; |
my $cmp = $latest{$pkg->name}; |
509 |
my ($srcname, $version, $release) = ($pkg->is_source_package ? basename $pkg->filename : $pkg->sourcerpm) =~ m{^([^/]*)-([^-]+)-([^-]+)\.\w+.rpm}; |
my ($srcname, $version, $release) = ($pkg->is_source_package ? basename $pkg->filename : $pkg->sourcerpm) =~ m{^([^/]*)-([^-]+)-([^-]+)\.\w+.rpm}; |
510 |
my $pkgrepo = 'base'; |
my $pkgrepo = 'base'; |
511 |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { |
513 |
return if grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; |
return if grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; |
514 |
$pkgrepo = $repo; |
$pkgrepo = $repo; |
515 |
return unless $pkg->is_source_package || $cmp; |
return unless $pkg->is_source_package || $cmp; |
516 |
return if ! $pkg->is_source_package && $pkg gt $cmp->{rpm} && rprop($cmp, 'base') && rprop($cmp, 'prio') > $repos->{$pkgrepo}->{prio}; |
return if ! $pkg->is_source_package && $pkg ge $cmp->{rpm} && rprop($cmp, 'base') && rprop($cmp, 'prio') > $repos->{$pkgrepo}->{prio}; |
517 |
last; |
last; |
518 |
} |
} |
519 |
} |
} |
521 |
push @rpms, { base => $srcname, |
push @rpms, { base => $srcname, |
522 |
name => $pkg->name, |
name => $pkg->name, |
523 |
repo => $pkgrepo, |
repo => $pkgrepo, |
524 |
nvra => $pkg->as_nvre . '.' . ( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ), |
nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ), |
525 |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
526 |
version => $version, |
version => $version, |
527 |
release => $release, |
release => $release, |
529 |
nosig => 0, |
nosig => 0, |
530 |
}; |
}; |
531 |
if ( ! $pkg->is_source_package && $pkg ge $cmp->{rpm} && ( $repos->{$pkgrepo}->{prio} >= rprop($cmp, 'prio') || ! rprop($cmp, 'base') ) ) { |
if ( ! $pkg->is_source_package && $pkg ge $cmp->{rpm} && ( $repos->{$pkgrepo}->{prio} >= rprop($cmp, 'prio') || ! rprop($cmp, 'base') ) ) { |
532 |
$pkgnames{$pkg->name} = $rpms[$#rpms]; |
$latest{$pkg->name} = $rpms[$#rpms]; |
533 |
} |
} |
534 |
} |
} |
535 |
|
|