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 => 18, inc => 1, ver => 1, rel => 1, os => 1 }, |
25 |
'smeupdates' => { prio => 15, inc => 1, ver => 1, rel => 1 }, |
'smeupdates' => { prio => 17, inc => 1, ver => 1, rel => 1 }, |
26 |
'smeupdates-testing' => { prio => 14, inc => 1, ver => 1, rel => 1 }, |
'smeupdates-testing' => { prio => 16, inc => 1, ver => 1, rel => 1 }, |
27 |
'smeextras' => { prio => 13, inc => 0, ver => 1, rel => 1 }, |
'smeextras' => { prio => 15, inc => 0, ver => 1, rel => 1 }, |
28 |
'smeaddons' => { prio => 12, inc => 0, ver => 1, rel => 1 }, |
'smeaddons' => { prio => 14, inc => 0, ver => 1, rel => 1 }, |
29 |
'smecontribs' => { prio => 11, inc => 0, ver => 1, rel => 1 }, |
'smecontribs' => { prio => 13, inc => 0, ver => 1, rel => 1, contribs => 1 }, |
30 |
'smetest' => { prio => 10, inc => 1, ver => 2, rel => 2, devel => 2 }, |
'smetest' => { prio => 12, inc => 1, ver => 2, rel => 2, devel => 2 }, |
31 |
'smedev' => { prio => 9, inc => 0, ver => 2, rel => 2, devel => 1 }, |
'smedev' => { prio => 11, inc => 0, ver => 2, rel => 2, devel => 1 }, |
32 |
'centos' => { prio => 8, inc => 0, ver => 0, rel => 0, base => 1 }, |
'centos' => { prio => 10, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
33 |
'fedora/epel' => { prio => 7, inc => 0, ver => 0, rel => 0, base => 1 }, |
'fedora/epel' => { prio => 9, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
34 |
'fedora/extras' => { prio => 6, inc => 0, ver => 0, rel => 0, base => 1 }, |
'fedora/extras' => { prio => 8, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
35 |
'rpmforge' => { prio => 5, inc => 0, ver => 0, rel => 0, base => 1 }, |
'rpmforge' => { prio => 7, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
36 |
'atrpms' => { prio => 4, inc => 0, ver => 0, rel => 0, base => 1 }, |
'atrpms' => { prio => 6, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
37 |
'fedora/core' => { prio => 3, inc => 0, ver => 0, rel => 0, base => 1 }, |
'fedora/core' => { prio => 5, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
38 |
'base' => { prio => 2, inc => 0, ver => 0, rel => 0, base => 1 }, |
'base' => { prio => 4, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
39 |
'builds' => { prio => 1, inc => 0, ver => 0, rel => 0, builds => 1 }, |
'builds' => { prio => 3, inc => 0, ver => 0, rel => 0, orig => 1 }, |
40 |
|
'contribs' => { prio => 2, inc => 0, ver => 0, rel => 0, orig => 1 }, |
41 |
|
'stage' => { prio => 1, inc => 0, ver => 0, rel => 0, stage => 1, os => 1 }, |
42 |
}; |
}; |
43 |
|
|
44 |
my $distrepo = { '7' => { active => 1, |
my $distrepo = { '7' => { active => 1, |
45 |
centos => 4, |
centos => 4, |
46 |
fedora => 3, |
fedora => 3, |
47 |
repo => '/releases/7/', |
repo => '/releases/7/', |
48 |
os => 'SME/RPMS/', |
os => 'SME/RPMS/', |
49 |
builds => '/builds2/smeserver-7-core/', |
builds => '/builds/smeserver-7-core/', |
50 |
|
contribs => '/builds/smeserver-7-contribs/', |
51 |
|
stage => '/stage/7/', |
52 |
}, |
}, |
53 |
'8' => { active => 1, |
'8' => { active => 1, |
54 |
centos => 5, |
centos => 5, |
55 |
fedora => 6, |
fedora => 6, |
56 |
repo => '/releases/testing/8/', |
repo => '/releases/testing/8/', |
57 |
os => 'SME/', |
os => 'SME/', |
58 |
builds => '/builds2/smeserver-8-core/', |
builds => '/builds/smeserver-8-core/', |
59 |
|
contribs => '/builds/smeserver-8-contribs/', |
60 |
|
stage => '/stage/8/', |
61 |
}, |
}, |
62 |
}; |
}; |
63 |
|
|
91 |
|
|
92 |
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; |
93 |
$devel2 ||= $devel1; |
$devel2 ||= $devel1; |
94 |
|
my ($contribs) = sort { $repos->{$a}->{contribs} <=> $repos->{$b}->{contribs} } grep { $repos->{$_}->{contribs} } keys %$repos; |
95 |
|
my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos; |
96 |
|
|
97 |
my ($rel, @rpms, %pkgnames, %sources, $archs, $rebuild, $newline); |
my ($rel, @rpms, %latest, %sources, $archs, $rebuild, $newline); |
98 |
foreach my $smever ( sort { $a <=> $b } grep { $distrepo->{$_}->{active} } keys %$distrepo ) { |
foreach my $smever ( sort { $a <=> $b } grep { $distrepo->{$_}->{active} } keys %$distrepo ) { |
99 |
$rel = $smever; |
$rel = $smever; |
100 |
%pkgnames = (); |
%latest = (); |
101 |
%sources = (); |
%sources = (); |
102 |
@rpms = (); |
@rpms = (); |
103 |
$rebuild = (); |
$rebuild = (); |
104 |
|
|
105 |
# Load distro packages |
# Load distro packages |
106 |
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','contribs','stage') ); |
107 |
printline('white', 0, "Distro (SME Server $rel) packages loaded.\n"); |
printline('white', 0, "Distro (SME Server $rel) packages loaded.\n"); |
108 |
|
|
109 |
# Load base packages |
# Load base packages |
123 |
} |
} |
124 |
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"); |
125 |
|
|
126 |
|
%latest = (); |
127 |
foreach my $name ( sort keys %{{ map { $_->{base} => 1 } @rpms }} ) { |
foreach my $name ( sort keys %{{ map { $_->{base} => 1 } @rpms }} ) { |
128 |
printline('white', 0, "Processing: $name"); |
printline('white', 0, "Processing: $name"); |
129 |
my @pkgs = sort pkgsrt grep { $_->{base} eq $name } @rpms; |
my @pkgs = sort pkgsrt grep { $_->{base} eq $name } @rpms; |
139 |
# Find names of packages in same or higher repos |
# Find names of packages in same or higher repos |
140 |
my %names = names($pkg, @pkgs); |
my %names = names($pkg, @pkgs); |
141 |
|
|
142 |
|
# Stage packages should never be most current |
143 |
|
if ( rprop($pkg, 'stage') ) { |
144 |
|
printline('dark blue', 1, ' - checking stage') if $opts{d}; |
145 |
|
tagpkg($pkg, 'obsolete'); |
146 |
|
next; |
147 |
|
} |
148 |
|
|
149 |
# Move packages from base/builds to correct area |
# Move packages from base/builds to correct area |
150 |
if ( rprop($pkg, 'base') || rprop($pkg, 'builds') ) { |
elsif ( rprop($pkg, 'orig') ) { |
151 |
printline('dark blue', 1, ' - checking base/builds') if $opts{d}; |
printline('dark blue', 1, ' - checking base/builds/contribs') if $opts{d}; |
152 |
my $repo = $names{$pkg->{name}} && $names{$pkg->{name}} > 1 ? $devel2 : $devel1; |
my $repo = $names{$pkg->{name}} && $names{$pkg->{name}} > 1 ? $devel2 : $devel1; |
153 |
|
$repo = $contribs if $pkg->{repo} eq 'contribs'; |
154 |
if ( $pkg->{nonbase} ) { |
if ( $pkg->{nonbase} ) { |
155 |
foreach my $up ( grep { $_->{name} eq $pkg->{name} && $_->{rpm} lt $pkg->{rpm} && $_->{obsolete} } @rpms ) { |
foreach my $up ( @pkgs ) { |
156 |
next if rprop($up, 'builds') || rprop($up, 'base'); |
next if rprop($up, 'orig'); |
157 |
|
next if $up->{name} ne $pkg->{name} || ! $up->{obsolete} || $up->{rpm} ge $pkg->{rpm}; |
158 |
$repo = $up->{repo}; |
$repo = $up->{repo}; |
159 |
last; |
last; |
160 |
} |
} |
161 |
} |
} |
162 |
next if rprop($pkg, 'base') && $repo eq $devel1 && $devel1 ne $devel2; |
next if rprop($pkg, 'base') && $repo eq $devel1; |
163 |
movepkg($pkg, $repo); |
movepkg($pkg, $repo); |
164 |
%names = names($pkg, @pkgs); |
%names = names($pkg, @pkgs); |
165 |
$seen{$pkg->{nvra}}++; |
$seen{$pkg->{nvra}}++; |
185 |
if ( $cmp->{rpm}->is_source_package ) { |
if ( $cmp->{rpm}->is_source_package ) { |
186 |
if ( $cmp->{name} eq $pkg->{base} ) { |
if ( $cmp->{name} eq $pkg->{base} ) { |
187 |
if ( $cmp->{rpm} eq $pkg->{rpm} ) { |
if ( $cmp->{rpm} eq $pkg->{rpm} ) { |
188 |
$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} ) { |
189 |
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}; |
190 |
|
$pkg->{srpm} = $cmp; |
191 |
|
$pkg->{srpm}->{latest}++ if $pkg->{latest}; |
192 |
|
} |
193 |
|
if ( $pkg->{latest} && rprop($cmp, 'stage') ) { |
194 |
|
tagpkg($cmp, 'inuse'); |
195 |
|
$pkg->{srpm}->{latest}++; |
196 |
|
} |
197 |
|
if ( $pkg->{repo} eq $cmp->{repo} || ( $cmp->{oldrepo} && $pkg->{repo} eq $cmp->{oldrepo} ) || rprop($cmp, 'orig') ) { |
198 |
|
tagpkg($cmp, 'inuse') |
199 |
|
} |
200 |
} |
} |
201 |
next if $pkg->{srpm} && $pkg->{srpm}->{rpm} eq $pkg->{rpm}; |
next if $pkg->{srpm} && $pkg->{srpm}->{rpm} eq $pkg->{rpm}; |
202 |
|
|
216 |
$src = ''; |
$src = ''; |
217 |
} |
} |
218 |
if ( $src eq $source && ( ! $pkg->{srpm} || $pkg->{srpm}->{rpm} eq $cmp->{rpm} ) ) { |
if ( $src eq $source && ( ! $pkg->{srpm} || $pkg->{srpm}->{rpm} eq $cmp->{rpm} ) ) { |
219 |
$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} ) { |
220 |
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}; |
221 |
|
$pkg->{srpm} = $cmp; |
222 |
|
$pkg->{srpm}->{latest}++ if $pkg->{latest}; |
223 |
|
} |
224 |
|
if ( $pkg->{latest} && rprop($cmp, 'stage') ) { |
225 |
|
tagpkg($cmp, 'inuse'); |
226 |
|
$pkg->{srpm}->{latest}++; |
227 |
|
} |
228 |
|
tagpkg($cmp, 'inuse') if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'orig'); |
229 |
} |
} |
230 |
} |
} |
231 |
} elsif ( $cmp->{rpm} eq $pkg->{rpm} ) { |
} elsif ( $cmp->{rpm} eq $pkg->{rpm} ) { |
233 |
if ( $pkg->{repo} eq $cmp->{repo} ) { |
if ( $pkg->{repo} eq $cmp->{repo} ) { |
234 |
tagpkg($cmp, 'correct', 1); |
tagpkg($cmp, 'correct', 1); |
235 |
$seen{$cmp->{nvra}}++; |
$seen{$cmp->{nvra}}++; |
236 |
|
} elsif ( $seen{$cmp->{nvra}} && rprop($cmp, 'stage') && $pkg->{latest} ) { |
237 |
|
$_->{latest}++ foreach grep { $_->{nvra} eq $cmp->{nvra} && $_->{latest} && $_->{done} } @pkgs; |
238 |
|
tagpkg($cmp, 'correct', 1); |
239 |
} elsif ( $seen{$cmp->{nvra}} ) { |
} elsif ( $seen{$cmp->{nvra}} ) { |
240 |
$orig++ if rprop($cmp, 'base') || rprop($cmp, 'builds'); |
$orig++ if rprop($cmp, 'orig'); |
241 |
movepkg($cmp, 'delete', 1); |
movepkg($cmp, 'delete', 1); |
242 |
} else { |
} else { |
243 |
movepkg($cmp, $pkg->{repo}, 1, 1); |
movepkg($cmp, $pkg->{repo}, 1, 1); |
244 |
$seen{$cmp->{nvra}}++; |
$seen{$cmp->{nvra}}++; |
245 |
} |
} |
246 |
} else { |
} else { |
247 |
tagpkg($cmp, 'nonbase', 0); |
tagpkg($cmp, 'nonbase'); |
248 |
} |
} |
249 |
} elsif ( rprop($cmp, 'prio') < rprop($pkg, 'prio') ) { |
} elsif ( rprop($cmp, 'prio') < rprop($pkg, 'prio') ) { |
250 |
tagpkg($cmp, 'obsolete', 0); |
tagpkg($cmp, 'obsolete'); |
251 |
} |
} |
252 |
} |
} |
253 |
printline('dark blue', 1, ' - checking source packages') if $opts{d}; |
printline('dark blue', 1, ' - checking source packages') if $opts{d}; |
254 |
if ( ! $pkg->{srpm} ) { |
if ( ! $pkg->{srpm} ) { |
255 |
printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (missing source ', $pkg->{rpm}->sourcerpm, ')'); |
printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (missing source ', $pkg->{rpm}->sourcerpm, ')'); |
256 |
} elsif ( $pkg->{srpm}->{repo} ne $pkg->{repo} ) { |
} elsif ( $pkg->{srpm}->{repo} ne $pkg->{repo} && ( ! $pkg->{srpm}->{oldrepo} || $pkg->{srpm}->{oldrepo} ne $pkg->{repo} ) ) { |
257 |
movepkg($pkg->{srpm}, $pkg->{repo}, 0); |
movepkg($pkg->{srpm}, $pkg->{repo}, 0); |
258 |
} |
} |
259 |
unless ( $orig ) { |
unless ( $orig ) { |
262 |
} |
} |
263 |
} |
} |
264 |
} |
} |
|
printline('bold black', 1, ' - obsolete packages') if $opts{d}; |
|
|
movepkg($_, 'delete') foreach grep { ! rprop($_, 'base') && ! $_->{done} && ( $_->{obsolete} || ( $_->{rpm}->is_source_package && ! $_->{inuse} ) ) } @pkgs; |
|
|
|
|
265 |
printline('bold black', 1, ' - arch count check') if $opts{d}; |
printline('bold black', 1, ' - arch count check') if $opts{d}; |
266 |
foreach my $r ( keys %$archs ) { |
foreach my $r ( keys %$archs ) { |
267 |
foreach my $p ( keys %{$archs->{$r}} ) { |
foreach my $p ( keys %{$archs->{$r}} ) { |
275 |
} |
} |
276 |
} |
} |
277 |
} |
} |
278 |
|
|
279 |
|
printline('bold black', 1, ' - missing stage packages') if $opts{d}; |
280 |
|
movepkg($_, $stage, 0) foreach grep { $_->{latest} && $_->{latest} == 1 } @pkgs; |
281 |
|
|
282 |
|
printline('bold black', 1, ' - obsolete packages') if $opts{d}; |
283 |
|
movepkg($_, 'delete') foreach grep { ! rprop($_, 'base') && ! $_->{done} && ( $_->{obsolete} || ( $_->{rpm}->is_source_package && ! $_->{inuse} ) ) } @pkgs; |
284 |
} |
} |
285 |
printline('white', 0, "Finished processing.\n"); |
printline('white', 0, "Finished processing.\n"); |
286 |
|
|
294 |
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}; |
295 |
if ( $pkg->{repos} ) { |
if ( $pkg->{repos} ) { |
296 |
foreach my $dest ( dest($pkg, @{$pkg->{repos}}) ) { |
foreach my $dest ( dest($pkg, @{$pkg->{repos}}) ) { |
297 |
qx(cp --preserve=timestamps $src $dest) unless -f $dest; |
qx(cp --preserve=timestamps $src $dest) unless -f "$dest"; |
298 |
} |
} |
299 |
$repochg{$_}++ foreach @{$pkg->{repos}}; |
$repochg{$_}++ foreach @{$pkg->{repos}}; |
300 |
} |
} |
304 |
} |
} |
305 |
} |
} |
306 |
finddepth(sub{rmdir}, $distrepo->{$rel}->{builds}); |
finddepth(sub{rmdir}, $distrepo->{$rel}->{builds}); |
307 |
|
finddepth(sub{rmdir}, $distrepo->{$rel}->{contribs}); |
308 |
printline('white', 0, "Finished copying/moving.\n"); |
printline('white', 0, "Finished copying/moving.\n"); |
309 |
|
|
310 |
foreach my $repo ( sort keys %repochg ) { |
foreach my $repo ( sort keys %repochg ) { |
311 |
next if ! $repos->{$repo} || $repos->{$repo}->{base} || $repos->{$repo}->{builds}; |
next if ! $repos->{$repo} || $repos->{$repo}->{orig} || $repos->{$repo}->{stage}; |
312 |
foreach my $arch ( @archs ) { |
foreach my $arch ( @archs ) { |
313 |
my $dir = $distrepo->{$rel}->{repo} . "$repo/$arch"; |
my $dir = $distrepo->{$rel}->{repo} . "$repo/$arch"; |
314 |
$dir = qx(readlink -f $dir); |
$dir = qx(readlink -f $dir); |
328 |
} |
} |
329 |
|
|
330 |
sub pkgsrt { |
sub pkgsrt { |
331 |
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'); |
332 |
} |
} |
333 |
|
|
334 |
sub rprop { |
sub rprop { |
341 |
my @rpms = @_; |
my @rpms = @_; |
342 |
return map { $_->{name} => rprop($_, 'inc') ? 2 : 1 } grep { $_->{base} eq $pkg->{base} && |
return map { $_->{name} => rprop($_, 'inc') ? 2 : 1 } grep { $_->{base} eq $pkg->{base} && |
343 |
rprop($_, 'prio') >= rprop($pkg, 'prio') && |
rprop($_, 'prio') >= rprop($pkg, 'prio') && |
344 |
! rprop($_, 'base') && |
! rprop($_, 'orig') && |
|
! rprop($_, 'builds') && |
|
345 |
! $_->{rpm}->is_source_package |
! $_->{rpm}->is_source_package |
346 |
} @rpms; |
} @rpms; |
347 |
} |
} |
350 |
my ($pkg, @repos) = @_; |
my ($pkg, @repos) = @_; |
351 |
my @d = (); |
my @d = (); |
352 |
foreach my $repo ( @repos ) { |
foreach my $repo ( @repos ) { |
353 |
|
my $base = $distrepo->{$rel}->{repo} . $repo; |
354 |
|
$base = $distrepo->{$rel}->{stage} if $repos->{$repo}->{stage}; |
355 |
if ( $pkg->{arch} eq 'noarch' ) { |
if ( $pkg->{arch} eq 'noarch' ) { |
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 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/x86_64/" . |
|
"$repo/x86_64/" . |
|
360 |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
361 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
362 |
} elsif ( $pkg->{arch} =~ m{^(i[356]86)$} ) { |
} elsif ( $pkg->{arch} =~ m{^(i[356]86)$} ) { |
363 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/i386/" . |
|
"$repo/i386/" . |
|
364 |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
365 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
366 |
} elsif ( $pkg->{arch} eq 'x86_64' ) { |
} elsif ( $pkg->{arch} eq 'x86_64' ) { |
367 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/x86_64/" . |
|
"$repo/x86_64/" . |
|
368 |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
369 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
370 |
} elsif ( $pkg->{arch} eq 'zsrc' ) { |
} elsif ( $pkg->{arch} eq 'zsrc' ) { |
371 |
push @d, $distrepo->{$rel}->{repo} . |
push @d, "$base/SRPMS/" . |
|
"$repo/SRPMS/" . |
|
372 |
basename $pkg->{rpm}->filename; |
basename $pkg->{rpm}->filename; |
373 |
} else { |
} else { |
374 |
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}, ')'); |
381 |
my ($pkg, $repo, $done, $remove) = @_; |
my ($pkg, $repo, $done, $remove) = @_; |
382 |
defined $done or $done = 2; |
defined $done or $done = 2; |
383 |
defined $remove or $remove = 0; |
defined $remove or $remove = 0; |
384 |
$remove = 0 if rprop($pkg, 'base') || rprop($pkg, 'builds'); |
$remove = 0 if rprop($pkg, 'orig'); |
385 |
$remove = 1 if $repo eq 'delete'; |
$remove = 1 if $repo eq 'delete'; |
386 |
|
|
387 |
if ( $repo eq 'delete' && ( rprop($pkg, 'base') || ( rprop($pkg, 'builds') && $done == 1 ) ) ) { |
if ( $repo eq 'delete' && ( rprop($pkg, 'base') || ( rprop($pkg, 'orig') && $done == 1 ) ) ) { |
388 |
tagpkg($pkg, 'inuse', 1); |
tagpkg($pkg, 'inuse', 1); |
389 |
} else { |
} else { |
390 |
printline('bold magenta', 1, " - ($repo) ", $pkg->{rpm}->filename) if $opts{d}; |
printline('bold magenta', 1, " - ($repo) ", $pkg->{rpm}->filename) if $opts{d}; |
391 |
my $color = 'bold white'; |
my $color = 'bold white'; |
392 |
$color = 'bold yellow' if rprop($pkg, 'builds'); |
$color = 'bold yellow' if rprop($pkg, 'orig'); |
393 |
$color = 'dark green' if $repos->{$repo} && $repos->{$repo}->{devel}; |
$color = 'dark green' if $repos->{$repo} && $repos->{$repo}->{devel}; |
394 |
$color = 'dark red' if $repo eq 'delete'; |
$color = 'dark red' if $repo eq 'delete'; |
395 |
push @{$pkg->{repos}}, $repo unless $repo eq 'delete'; |
push @{$pkg->{repos}}, $repo unless $repo eq 'delete'; |
403 |
|
|
404 |
sub tagpkg { |
sub tagpkg { |
405 |
my ($pkg, $tag, $done) = @_; |
my ($pkg, $tag, $done) = @_; |
406 |
|
defined $done or $done = 0; |
407 |
|
|
408 |
printline('bold magenta', 1, " - ($tag) ", $pkg->{rpm}->filename) if $opts{d}; |
printline('bold magenta', 1, " - ($tag) ", $pkg->{rpm}->filename) if $opts{d}; |
409 |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
417 |
$pkg->{done}++; |
$pkg->{done}++; |
418 |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
419 |
|
|
420 |
if ( $repos->{$pkg->{repo}} && ! rprop($pkg, 'base') && ! rprop($pkg, 'builds') ) { |
if ( $repos->{$pkg->{repo}} && ! rprop($pkg, 'orig') ) { |
421 |
|
# FIXME: Nasty hack for comps package |
422 |
|
if ( $pkg->{name} eq 'comps' ) { |
423 |
|
if ( ! $latest{$pkg->{name}.'.'.$pkg->{arch}} || $latest{$pkg->{name}.'.'.$pkg->{arch}}->{rpm} eq $pkg->{rpm} ) { |
424 |
|
if ( rprop($pkg, 'inc') && ! $pkg->{rpm}->is_source_package ) { |
425 |
|
$latest{$pkg->{name}.'.'.$pkg->{arch}} = $pkg if ! $latest{$pkg->{name}.'.'.$pkg->{arch}}; |
426 |
|
$pkg->{latest}++; |
427 |
|
} |
428 |
|
} |
429 |
|
} elsif ( ! $latest{$pkg->{name}} || $latest{$pkg->{name}}->{rpm} eq $pkg->{rpm} ) { |
430 |
|
if ( rprop($pkg, 'inc') && ! $pkg->{rpm}->is_source_package ) { |
431 |
|
$latest{$pkg->{name}} = $pkg if ! $latest{$pkg->{name}}; |
432 |
|
$pkg->{latest}++; |
433 |
|
} |
434 |
|
} |
435 |
unless ( $pkg->{oldrepo} ) { |
unless ( $pkg->{oldrepo} ) { |
436 |
my $goodarch = 0; |
my $goodarch = 0; |
437 |
$goodarch++ if $pkg->{rpm}->filename =~ m{/(i386|x86_64)/.*\.noarch\.rpm$}; |
$goodarch++ if $pkg->{rpm}->filename =~ m{/(i386|x86_64)/.*\.noarch\.rpm$}; |
470 |
if ($@) { printline('bold yellow on_red', 1, "Corrupt package $_"); return; } |
if ($@) { printline('bold yellow on_red', 1, "Corrupt package $_"); return; } |
471 |
eval { my $sig = $pkg->siggpg }; |
eval { my $sig = $pkg->siggpg }; |
472 |
my $nosig = ! $@; |
my $nosig = ! $@; |
|
if ( $nosig && ! -f "$HOME/.rpmpass" ) { |
|
|
printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); |
|
|
return; |
|
|
} |
|
473 |
|
|
474 |
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}; |
475 |
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}}; } |
476 |
(my $reponame = dirname $pkg->filename) =~ s{^.*\d/(sme[^/]+)/.*$}{$1}; |
my $reponame = 'unknown'; |
477 |
$reponame = 'builds' if ( dirname $pkg->filename) =~ m{/smeserver-\d+-core/}; |
if ( substr($_, 0, length($distrepo->{$rel}->{builds})) eq $distrepo->{$rel}->{builds} ) { |
478 |
|
$reponame = 'builds'; |
479 |
|
} elsif ( substr($_, 0, length($distrepo->{$rel}->{contribs})) eq $distrepo->{$rel}->{contribs} ) { |
480 |
|
$reponame = 'contribs'; |
481 |
|
} elsif ( substr($_, 0, length($distrepo->{$rel}->{stage})) eq $distrepo->{$rel}->{stage} ) { |
482 |
|
$reponame = 'stage'; |
483 |
|
} elsif ( (dirname $pkg->filename) =~ m{\d/(sme[^/]+)/} ) { |
484 |
|
$reponame = $1; |
485 |
|
} |
486 |
|
if ( $nosig && ( ! -f "$HOME/.rpmpass" || ! $repos->{$reponame}->{orig} ) ) { |
487 |
|
printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); |
488 |
|
return; |
489 |
|
} |
490 |
push @rpms, { base => $srcname, |
push @rpms, { base => $srcname, |
491 |
name => $pkg->name, |
name => $pkg->name, |
492 |
repo => $reponame, |
repo => $reponame, |
493 |
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') ), |
494 |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
495 |
version => $version, |
version => $version, |
496 |
release => $release, |
release => $release, |
498 |
nosig => $nosig, |
nosig => $nosig, |
499 |
}; |
}; |
500 |
$sources{$srcname}++; |
$sources{$srcname}++; |
501 |
$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} ) { |
502 |
|
$latest{$pkg->name} = $rpms[$#rpms] if ! $latest{$pkg->name} || $pkg gt $latest{$pkg->name}->{rpm}; |
503 |
|
} |
504 |
} |
} |
505 |
|
|
506 |
sub loadbase { |
sub loadbase { |
507 |
printline('white', 0, "Loading: $_") if -d _; |
printline('white', 0, "Loading: $_") if -d _; |
508 |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ($pkgnames{$1} || $sources{$1}); |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ($latest{$1} || $sources{$1}); |
509 |
|
|
510 |
my $pkg; |
my $pkg; |
511 |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
513 |
eval { my $sig = $pkg->siggpg }; |
eval { my $sig = $pkg->siggpg }; |
514 |
unless ($@) { printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); return; } |
unless ($@) { printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); return; } |
515 |
|
|
516 |
my $cmp = $pkgnames{$pkg->name}; |
my $cmp = $latest{$pkg->name}; |
517 |
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}; |
518 |
my $pkgrepo = 'base'; |
my $pkgrepo = 'base'; |
519 |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { |
521 |
return if grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; |
return if grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; |
522 |
$pkgrepo = $repo; |
$pkgrepo = $repo; |
523 |
return unless $pkg->is_source_package || $cmp; |
return unless $pkg->is_source_package || $cmp; |
524 |
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}; |
525 |
last; |
last; |
526 |
} |
} |
527 |
} |
} |
529 |
push @rpms, { base => $srcname, |
push @rpms, { base => $srcname, |
530 |
name => $pkg->name, |
name => $pkg->name, |
531 |
repo => $pkgrepo, |
repo => $pkgrepo, |
532 |
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') ), |
533 |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
534 |
version => $version, |
version => $version, |
535 |
release => $release, |
release => $release, |
537 |
nosig => 0, |
nosig => 0, |
538 |
}; |
}; |
539 |
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') ) ) { |
540 |
$pkgnames{$pkg->name} = $rpms[$#rpms]; |
$latest{$pkg->name} = $rpms[$#rpms]; |
541 |
} |
} |
542 |
} |
} |
543 |
|
|