21 |
|
|
22 |
my @archs = ( 'i386', 'x86_64' ); |
my @archs = ( 'i386', 'x86_64' ); |
23 |
|
|
24 |
my $repos = { 'smeos' => { prio => 17, inc => 1, ver => 1, rel => 1, os => 1 }, |
my $repos = { 'smeos' => { prio => 18, inc => 1, ver => 1, rel => 1, os => 1 }, |
25 |
'smeupdates' => { prio => 16, inc => 1, ver => 1, rel => 1 }, |
'smeupdates' => { prio => 17, inc => 1, ver => 1, rel => 1 }, |
26 |
'smeupdates-testing' => { prio => 15, inc => 1, ver => 1, rel => 1 }, |
'smeupdates-testing' => { prio => 16, inc => 1, ver => 1, rel => 1 }, |
27 |
'smeextras' => { prio => 14, inc => 0, ver => 1, rel => 1 }, |
'smeextras' => { prio => 15, inc => 0, ver => 1, rel => 1 }, |
28 |
'smeaddons' => { prio => 13, inc => 0, ver => 1, rel => 1 }, |
'smeaddons' => { prio => 14, inc => 0, ver => 1, rel => 1 }, |
29 |
'smecontribs' => { prio => 12, inc => 0, ver => 1, rel => 1 }, |
'smecontribs' => { prio => 13, inc => 0, ver => 1, rel => 2, contribs => 1 }, |
30 |
'smetest' => { prio => 11, inc => 1, ver => 2, rel => 2, devel => 2 }, |
'smetest' => { prio => 12, inc => 0, ver => 2, rel => 2, devel => 2 }, |
31 |
'smedev' => { prio => 10, inc => 0, ver => 2, rel => 2, devel => 1 }, |
'smedev' => { prio => 11, inc => 0, ver => 2, rel => 2, devel => 1 }, |
32 |
'centos' => { prio => 9, 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 => 8, 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 => 7, 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 => 6, inc => 0, ver => 0, rel => 0, base => 1 }, |
'rpmforge' => { prio => 7, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
36 |
'atrpms' => { prio => 5, 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 => 4, 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 => 3, inc => 0, ver => 0, rel => 0, base => 1 }, |
'base' => { prio => 4, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
39 |
'builds' => { prio => 2, 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 }, |
'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 => '/builds/smeserver-7-core/', |
builds => '/builds/smeserver-7-core/', |
50 |
stage => '/stage/7/', |
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 => '/builds/smeserver-8-core/', |
builds => '/builds/smeserver-8-core/', |
59 |
stage => '/stage/8/', |
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; |
my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos; |
96 |
|
|
97 |
my ($rel, @rpms, %latest, %sources, $archs, $rebuild, $newline); |
my ($rel, @rpms, %latest, %sources, $archs, $rebuild, $newline); |
103 |
$rebuild = (); |
$rebuild = (); |
104 |
|
|
105 |
# Load distro packages |
# Load distro packages |
106 |
find( { wanted => \&loadpkg, no_chdir => 1, follow_fast => 1 }, map { $distrepo->{$smever}->{$_} } ('repo','builds','stage') ); |
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 |
147 |
} |
} |
148 |
|
|
149 |
# Move packages from base/builds to correct area |
# Move packages from base/builds to correct area |
150 |
elsif ( 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}} > 1 ? $devel2 : $devel1; |
153 |
|
$repo = $contribs if $pkg->{repo} eq 'contribs'; |
154 |
if ( $pkg->{nonbase} ) { |
if ( $pkg->{nonbase} ) { |
155 |
foreach my $up ( @pkgs ) { |
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}; |
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 |
} |
} |
|
next if rprop($pkg, 'base') && $repo eq $devel1 && $devel1 ne $devel2; |
|
162 |
movepkg($pkg, $repo); |
movepkg($pkg, $repo); |
163 |
%names = names($pkg, @pkgs); |
%names = names($pkg, @pkgs); |
164 |
$seen{$pkg->{nvra}}++; |
$seen{$pkg->{nvra}}++; |
193 |
tagpkg($cmp, 'inuse'); |
tagpkg($cmp, 'inuse'); |
194 |
$pkg->{srpm}->{latest}++; |
$pkg->{srpm}->{latest}++; |
195 |
} |
} |
196 |
if ( $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds') || ( $cmp->{oldrepo} && $pkg->{repo} eq $cmp->{oldrepo} ) ) { |
if ( $pkg->{repo} eq $cmp->{repo} || ( $cmp->{oldrepo} && $pkg->{repo} eq $cmp->{oldrepo} ) || rprop($cmp, 'orig') ) { |
197 |
tagpkg($cmp, 'inuse') |
tagpkg($cmp, 'inuse') |
198 |
} |
} |
199 |
} |
} |
224 |
tagpkg($cmp, 'inuse'); |
tagpkg($cmp, 'inuse'); |
225 |
$pkg->{srpm}->{latest}++; |
$pkg->{srpm}->{latest}++; |
226 |
} |
} |
227 |
tagpkg($cmp, 'inuse') if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds'); |
tagpkg($cmp, 'inuse') if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'orig'); |
228 |
} |
} |
229 |
} |
} |
230 |
} elsif ( $cmp->{rpm} eq $pkg->{rpm} ) { |
} elsif ( $cmp->{rpm} eq $pkg->{rpm} ) { |
236 |
$_->{latest}++ foreach grep { $_->{nvra} eq $cmp->{nvra} && $_->{latest} && $_->{done} } @pkgs; |
$_->{latest}++ foreach grep { $_->{nvra} eq $cmp->{nvra} && $_->{latest} && $_->{done} } @pkgs; |
237 |
tagpkg($cmp, 'correct', 1); |
tagpkg($cmp, 'correct', 1); |
238 |
} elsif ( $seen{$cmp->{nvra}} ) { |
} elsif ( $seen{$cmp->{nvra}} ) { |
239 |
$orig++ if rprop($cmp, 'base') || rprop($cmp, 'builds'); |
$orig++ if rprop($cmp, 'orig'); |
240 |
movepkg($cmp, 'delete', 1); |
movepkg($cmp, 'delete', 1); |
241 |
} else { |
} else { |
242 |
movepkg($cmp, $pkg->{repo}, 1, 1); |
unless ( $pkg->{repo} eq $devel1 && $devel1 ne $devel2 && $names{$cmp->{name}} > 1 ) { |
243 |
$seen{$cmp->{nvra}}++; |
movepkg($cmp, $pkg->{repo}, 1, 1); |
244 |
|
$seen{$cmp->{nvra}}++; |
245 |
|
} |
246 |
} |
} |
247 |
} else { |
} else { |
248 |
tagpkg($cmp, 'nonbase'); |
tagpkg($cmp, 'nonbase'); |
305 |
} |
} |
306 |
} |
} |
307 |
finddepth(sub{rmdir}, $distrepo->{$rel}->{builds}); |
finddepth(sub{rmdir}, $distrepo->{$rel}->{builds}); |
308 |
|
finddepth(sub{rmdir}, $distrepo->{$rel}->{contribs}); |
309 |
printline('white', 0, "Finished copying/moving.\n"); |
printline('white', 0, "Finished copying/moving.\n"); |
310 |
|
|
311 |
foreach my $repo ( sort keys %repochg ) { |
foreach my $repo ( sort keys %repochg ) { |
312 |
next if ! $repos->{$repo} || $repos->{$repo}->{base} || $repos->{$repo}->{builds} || $repos->{$repo}->{stage}; |
next if ! $repos->{$repo} || $repos->{$repo}->{orig} || $repos->{$repo}->{stage}; |
313 |
foreach my $arch ( @archs ) { |
foreach my $arch ( @archs ) { |
314 |
my $dir = $distrepo->{$rel}->{repo} . "$repo/$arch"; |
my $dir = $distrepo->{$rel}->{repo} . "$repo/$arch"; |
315 |
$dir = qx(readlink -f $dir); |
$dir = qx(readlink -f $dir); |
342 |
my @rpms = @_; |
my @rpms = @_; |
343 |
return map { $_->{name} => rprop($_, 'inc') ? 2 : 1 } grep { $_->{base} eq $pkg->{base} && |
return map { $_->{name} => rprop($_, 'inc') ? 2 : 1 } grep { $_->{base} eq $pkg->{base} && |
344 |
rprop($_, 'prio') >= rprop($pkg, 'prio') && |
rprop($_, 'prio') >= rprop($pkg, 'prio') && |
345 |
! rprop($_, 'base') && |
! rprop($_, 'orig') && |
|
! rprop($_, 'builds') && |
|
346 |
! $_->{rpm}->is_source_package |
! $_->{rpm}->is_source_package |
347 |
} @rpms; |
} @rpms; |
348 |
} |
} |
382 |
my ($pkg, $repo, $done, $remove) = @_; |
my ($pkg, $repo, $done, $remove) = @_; |
383 |
defined $done or $done = 2; |
defined $done or $done = 2; |
384 |
defined $remove or $remove = 0; |
defined $remove or $remove = 0; |
385 |
$remove = 0 if rprop($pkg, 'base') || rprop($pkg, 'builds'); |
$remove = 0 if rprop($pkg, 'orig'); |
386 |
$remove = 1 if $repo eq 'delete'; |
$remove = 1 if $repo eq 'delete'; |
387 |
|
|
388 |
if ( $repo eq 'delete' && ( rprop($pkg, 'base') || ( rprop($pkg, 'builds') && $done == 1 ) ) ) { |
if ( $repo eq 'delete' && ( rprop($pkg, 'base') || ( rprop($pkg, 'orig') && $done == 1 ) ) ) { |
389 |
tagpkg($pkg, 'inuse', 1); |
tagpkg($pkg, 'inuse', 1); |
390 |
} else { |
} else { |
391 |
printline('bold magenta', 1, " - ($repo) ", $pkg->{rpm}->filename) if $opts{d}; |
printline('bold magenta', 1, " - ($repo) ", $pkg->{rpm}->filename) if $opts{d}; |
392 |
my $color = 'bold white'; |
my $color = 'bold white'; |
393 |
$color = 'bold yellow' if rprop($pkg, 'builds'); |
$color = 'bold yellow' if rprop($pkg, 'orig'); |
394 |
$color = 'dark green' if $repos->{$repo} && $repos->{$repo}->{devel}; |
$color = 'dark green' if $repos->{$repo} && $repos->{$repo}->{devel}; |
395 |
$color = 'dark red' if $repo eq 'delete'; |
$color = 'dark red' if $repo eq 'delete'; |
396 |
push @{$pkg->{repos}}, $repo unless $repo eq 'delete'; |
push @{$pkg->{repos}}, $repo unless $repo eq 'delete'; |
418 |
$pkg->{done}++; |
$pkg->{done}++; |
419 |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
420 |
|
|
421 |
if ( $repos->{$pkg->{repo}} && ! rprop($pkg, 'base') && ! rprop($pkg, 'builds') ) { |
if ( $repos->{$pkg->{repo}} && ! rprop($pkg, 'orig') ) { |
422 |
# FIXME: Nasty hack for comps package |
# FIXME: Nasty hack for comps package |
423 |
if ( $pkg->{name} eq 'comps' ) { |
if ( $pkg->{name} eq 'comps' ) { |
424 |
if ( ! $latest{$pkg->{name}.'.'.$pkg->{arch}} || $latest{$pkg->{name}.'.'.$pkg->{arch}}->{rpm} eq $pkg->{rpm} ) { |
if ( ! $latest{$pkg->{name}.'.'.$pkg->{arch}} || $latest{$pkg->{name}.'.'.$pkg->{arch}}->{rpm} eq $pkg->{rpm} ) { |
464 |
|
|
465 |
sub loadpkg { |
sub loadpkg { |
466 |
printline('white', 0, "Loading: $_") if -d _; |
printline('white', 0, "Loading: $_") if -d _; |
467 |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ( ! $opts{r} || $1 =~ m{$opts{r}} ); |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$} && ( ! $opts{r} || $1 =~ m{$opts{r}} ); |
468 |
|
|
469 |
my $pkg; |
my $pkg; |
470 |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
472 |
eval { my $sig = $pkg->siggpg }; |
eval { my $sig = $pkg->siggpg }; |
473 |
my $nosig = ! $@; |
my $nosig = ! $@; |
474 |
|
|
475 |
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$}; |
476 |
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}}; } |
477 |
my $reponame = 'unknown'; |
my $reponame = 'unknown'; |
478 |
if ( substr($_, 0, length($distrepo->{$rel}->{builds})) eq $distrepo->{$rel}->{builds} ) { |
if ( substr($_, 0, length($distrepo->{$rel}->{builds})) eq $distrepo->{$rel}->{builds} ) { |
479 |
$reponame = 'builds'; |
$reponame = 'builds'; |
480 |
|
} elsif ( substr($_, 0, length($distrepo->{$rel}->{contribs})) eq $distrepo->{$rel}->{contribs} ) { |
481 |
|
$reponame = 'contribs'; |
482 |
} elsif ( substr($_, 0, length($distrepo->{$rel}->{stage})) eq $distrepo->{$rel}->{stage} ) { |
} elsif ( substr($_, 0, length($distrepo->{$rel}->{stage})) eq $distrepo->{$rel}->{stage} ) { |
483 |
$reponame = 'stage'; |
$reponame = 'stage'; |
484 |
} elsif ( (dirname $pkg->filename) =~ m{\d/(sme[^/]+)/} ) { |
} elsif ( (dirname $pkg->filename) =~ m{\d/(sme[^/]+)/} ) { |
485 |
$reponame = $1; |
$reponame = $1; |
486 |
} |
} |
487 |
if ( $nosig && ( ! -f "$HOME/.rpmpass" || $reponame eq 'builds' ) ) { |
if ( $nosig && ( ! -f "$HOME/.rpmpass" || ! $repos->{$reponame}->{orig} ) ) { |
488 |
printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); |
printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); |
489 |
return; |
return; |
490 |
} |
} |
506 |
|
|
507 |
sub loadbase { |
sub loadbase { |
508 |
printline('white', 0, "Loading: $_") if -d _; |
printline('white', 0, "Loading: $_") if -d _; |
509 |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ($latest{$1} || $sources{$1}); |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$} && ($latest{$1} || $sources{$1}); |
510 |
|
|
511 |
my $pkg; |
my $pkg; |
512 |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
515 |
unless ($@) { printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); return; } |
unless ($@) { printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); return; } |
516 |
|
|
517 |
my $cmp = $latest{$pkg->name}; |
my $cmp = $latest{$pkg->name}; |
518 |
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$}; |
519 |
my $pkgrepo = 'base'; |
my $pkgrepo = 'base'; |
520 |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { |
521 |
if ( (dirname $pkg->filename) =~ m{/$repo/} ) { |
if ( (dirname $pkg->filename) =~ m{/$repo/} ) { |