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