14 |
$| = 1; |
$| = 1; |
15 |
|
|
16 |
my %opts; |
my %opts; |
17 |
getopts( 'otr:', \%opts ); |
getopts( 'osqtr:', \%opts ); |
18 |
$opts{r} ||= ''; |
$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; |
76 |
'/mirrors/centos/~C/updates/~A/RPMS/' => 'centos', |
'/mirrors/centos/~C/updates/~A/RPMS/' => 'centos', |
77 |
'/mirrors/centos/~C/os/~A/CentOS/~O' => 'centos', |
'/mirrors/centos/~C/os/~A/CentOS/~O' => 'centos', |
78 |
'/mirrors/centos/~C/extras/~A/RPMS/' => 'centos', |
'/mirrors/centos/~C/extras/~A/RPMS/' => 'centos', |
|
'/mirrors/centos-qa/CentOS/~C/fasttrack/~A/RPMS/' => 'centos', |
|
|
'/mirrors/centos-qa/CentOS/~C/updates/~A/RPMS/' => 'centos', |
|
|
'/mirrors/centos-qa/CentOS/~C/os/~A/CentOS/~O' => 'centos', |
|
|
'/mirrors/centos-qa/CentOS/~C/extras/~A/RPMS/' => 'centos', |
|
79 |
'/mirrors/fedora/epel/~C/~A/' => 'epel', |
'/mirrors/fedora/epel/~C/~A/' => 'epel', |
80 |
'/mirrors/fedora/epel/testing/~C/~A/' => 'epel', |
'/mirrors/fedora/epel/testing/~C/~A/' => 'epel', |
81 |
'/mirrors/fedora/extras/~F/~A/' => 'fedora-extras', |
'/mirrors/fedora/extras/~F/~A/' => 'fedora-extras', |
89 |
'/mirrors/fedora/core/updates/~F/~A/' => 'fedora', |
'/mirrors/fedora/core/updates/~F/~A/' => 'fedora', |
90 |
}; |
}; |
91 |
|
|
92 |
|
if ( $opts{q} ) { |
93 |
|
$baserepo->{'/mirrors/centos-qa/CentOS/~C/fasttrack/~A/RPMS/'} = 'centos'; |
94 |
|
$baserepo->{'/mirrors/centos-qa/CentOS/~C/updates/~A/RPMS/'} = 'centos'; |
95 |
|
$baserepo->{'/mirrors/centos-qa/CentOS/~C/os/~A/CentOS/~O'} = 'centos'; |
96 |
|
$baserepo->{'/mirrors/centos-qa/CentOS/~C/extras/~A/RPMS/'} = 'centos'; |
97 |
|
} |
98 |
|
|
99 |
my $skippkg = { '7' => { 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3', 'vim' ) }, |
my $skippkg = { '7' => { 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3', 'vim' ) }, |
100 |
'epel' => { map { $_ => 1 } ( 'perl-Razor-Agent' ) }, |
'epel' => { map { $_ => 1 } ( 'perl-Razor-Agent' ) }, |
101 |
'rpmforge' => { map { $_ => 1 } ( 'perl-Test-Inline' ) }, |
'rpmforge' => { map { $_ => 1 } ( 'perl-Test-Inline' ) }, |
157 |
foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) { |
foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) { |
158 |
next if $pkg->{done}; |
next if $pkg->{done}; |
159 |
|
|
160 |
if ( $rpms->{$base}->{vers}->{$pkg->{svr}} ) { |
my $tmp = $pkg->{svr}; |
161 |
foreach my $tmp ( @{$rpms->{$base}->{vers}->{$pkg->{svr}}} ) { |
SRC: { |
162 |
|
$rpms->{$base}->{vers}->{$tmp} && last SRC; |
163 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
164 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
165 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
166 |
|
($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
167 |
|
($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 |
|
($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
171 |
|
($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
172 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.sme$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
173 |
|
} |
174 |
|
if ( $rpms->{$base}->{vers}->{$tmp} ) { |
175 |
|
foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) { |
176 |
$tmp->{svr} = $pkg->{svr}; |
$tmp->{svr} = $pkg->{svr}; |
177 |
push @{$rpms->{$base}->{rpms}}, $tmp; |
push @{$rpms->{$base}->{rpms}}, $tmp unless $tmp->{added}; |
178 |
} |
$tmp->{added}++; |
|
} else { |
|
|
my $tmp = $pkg->{svr}; |
|
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.dag} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d\.rf$}{$1.dag} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
($tmp = $pkg->{svr}) =~ s{\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.sme$}{} && $rpms->{$base}->{vers}->{$tmp} && last; |
|
|
if ( $rpms->{$base}->{vers}->{$tmp} ) { |
|
|
foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) { |
|
|
$tmp->{svr} = $pkg->{svr}; |
|
|
push @{$rpms->{$base}->{rpms}}, $tmp; |
|
|
} |
|
179 |
} |
} |
180 |
} |
} |
181 |
|
|
183 |
my %pkgs = (); |
my %pkgs = (); |
184 |
my %reposrc = (); |
my %reposrc = (); |
185 |
my $srpm = undef; |
my $srpm = undef; |
186 |
foreach my $cmp ( sort { $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} || $a->{src} <=> $b->{src} } @{$rpms->{$base}->{rpms}} ) { |
foreach my $cmp ( sort { $a->{src} <=> $b->{src} || $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} } @{$rpms->{$base}->{rpms}} ) { |
187 |
next unless $cmp->{svr} eq $pkg->{svr}; |
next unless $cmp->{svr} eq $pkg->{svr}; |
188 |
|
|
189 |
if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) { |
if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) { |
|
$track{repo} = $cmp->{repo}; |
|
|
$track{svr} = $cmp->{svr}; |
|
|
} |
|
|
if ( $cmp->{svr} eq $track{svr} ) { |
|
190 |
if ( $cmp->{src} ) { |
if ( $cmp->{src} ) { |
191 |
$srpm = $cmp unless $srpm; |
if ( ! $track{repo} ) { |
|
if ( $reposrc{$cmp->{repo}} ) { |
|
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
|
|
$cmp->{latest}++ if $reposrc{$cmp->{repo}}->{latest}; |
|
|
} elsif ( ! $repos->{$cmp->{repo}}->{base} ) { |
|
192 |
$cmp->{delete}++; |
$cmp->{delete}++; |
193 |
|
$cmp->{done}++; |
194 |
|
next; |
195 |
} |
} |
196 |
} elsif ( $seen{$cmp->{nvra}} ) { |
} else { |
197 |
|
$track{repo} = $cmp->{repo}; |
198 |
|
$track{svr} = $cmp->{svr}; |
199 |
|
} |
200 |
|
} |
201 |
|
if ( $cmp->{svr} eq $track{svr} ) { |
202 |
|
if ( $seen{$cmp->{nvra}} ) { |
203 |
if ( $track{repo} ne $cmp->{repo} ) { |
if ( $track{repo} ne $cmp->{repo} ) { |
204 |
if ($repos->{$cmp->{repo}}->{stage} ) { |
if ($repos->{$cmp->{repo}}->{stage} ) { |
205 |
if ( $seen{$cmp->{nvra}}->{latest} ) { |
if ( $seen{$cmp->{nvra}}->{latest} ) { |
209 |
} |
} |
210 |
} elsif ( $repos->{$cmp->{repo}}->{orig}) { |
} elsif ( $repos->{$cmp->{repo}}->{orig}) { |
211 |
$orig{$cmp->{nvra}}++; |
$orig{$cmp->{nvra}}++; |
212 |
|
} elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) { |
213 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
214 |
} elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) { |
} elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) { |
215 |
$cmp->{delete}++; |
$cmp->{delete}++; |
216 |
} |
} |
218 |
} elsif ($repos->{$cmp->{repo}}->{stage} ) { |
} elsif ($repos->{$cmp->{repo}}->{stage} ) { |
219 |
$cmp->{delete}++; |
$cmp->{delete}++; |
220 |
} else { |
} else { |
221 |
|
$srpm = $cmp if ! $srpm && $cmp->{src}; |
222 |
my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2; |
my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2; |
223 |
$dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms}); |
$dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms}); |
224 |
$dest = $devel1 if verrel($cmp, $dest, \%counts); |
$dest = $devel1 if verrel($cmp, $dest, \%counts); |
226 |
push @{$cmp->{repos}}, $dest; |
push @{$cmp->{repos}}, $dest; |
227 |
if ( $repos->{$cmp->{repo}}->{orig} ) { |
if ( $repos->{$cmp->{repo}}->{orig} ) { |
228 |
$orig{$cmp->{nvra}}++; |
$orig{$cmp->{nvra}}++; |
229 |
|
} elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) { |
230 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
231 |
} else { |
} else { |
232 |
$cmp->{delete}++; |
$cmp->{delete}++; |
233 |
} |
} |
234 |
$cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo}; |
$cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo}; |
235 |
$cmp->{repo} = $dest; |
$cmp->{repo} = $dest; |
236 |
} |
} |
237 |
|
if ( $cmp->{src} && $reposrc{$cmp->{repo}} ) { |
238 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
239 |
|
} |
240 |
} |
} |
241 |
} else { |
} else { |
242 |
if ( $track{repo} eq $cmp->{repo} ) { |
if ( $track{repo} eq $cmp->{repo} ) { |
249 |
$cmp->{delete}++; |
$cmp->{delete}++; |
250 |
} |
} |
251 |
} |
} |
|
$reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{delete} || $repos->{$cmp->{repo}}->{base}; |
|
252 |
unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) { |
unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) { |
253 |
$pkgs{$cmp->{nvra}}++; |
$pkgs{$cmp->{nvra}}++; |
254 |
$latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}}; |
$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}} ) { |
unless ( $seen{$cmp->{nvra}} ) { |
257 |
$seen{$cmp->{nvra}} = $cmp; |
$seen{$cmp->{nvra}} = $cmp; |
258 |
$cmp->{latest}++ if $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc}; |
$cmp->{latest}++ if $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc}; |
262 |
$cmp->{done}++; |
$cmp->{done}++; |
263 |
} |
} |
264 |
if ( $srpm ) { |
if ( $srpm ) { |
265 |
foreach my $r ( keys %reposrc ) { |
foreach my $r ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %reposrc ) { |
|
next if $repos->{$r}->{orig}; |
|
266 |
unless ( $reposrc{$r}->{srpm} ) { |
unless ( $reposrc{$r}->{srpm} ) { |
267 |
push @{$srpm->{repos}}, $r; |
unshift @{$srpm->{repos}}, $r; |
|
$pkgs{$srpm->{nvra}}++; |
|
|
$orig{$srpm->{nvra}}++ if $repos->{$srpm->{repo}}->{orig}; |
|
268 |
$srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo}; |
$srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo}; |
269 |
$srpm->{repo} = $r; |
$srpm->{repo} = $r; |
270 |
$reposrc{$r}->{srpm} = $srpm; |
$reposrc{$r}->{srpm} = $srpm; |
271 |
} |
} |
272 |
} |
} |
273 |
} elsif ( scalar keys %pkgs ) { |
} elsif ( scalar keys %pkgs && $opts{s} ) { |
274 |
print "\n * missing source (", $pkg->{svr}, ")\n"; |
print "\n * missing source (", $pkg->{repo}, ", ", $pkg->{svr}, ")\n"; |
275 |
} |
} |
276 |
print "\n * missing originals (", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs; |
print "\n * missing originals (", $pkg->{repo}, ", ", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs; |
277 |
} |
} |
278 |
|
|
279 |
foreach my $r ( keys %$acnt ) { |
foreach my $r ( keys %$acnt ) { |
305 |
|
|
306 |
my $src = $pkg->{rpm}->filename; |
my $src = $pkg->{rpm}->filename; |
307 |
if ( $pkg->{nosig} ) { |
if ( $pkg->{nosig} ) { |
308 |
print "sign package (", basename($pkg->{rpm}->filename), ")\n"; |
print "sign package (", $pkg->{repo}, ", ", basename($pkg->{rpm}->filename), ")\n"; |
309 |
unless ( $opts{t} ) { |
unless ( $opts{t} ) { |
310 |
qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null); |
qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null); |
311 |
if ($?) { |
if ($?) { |
350 |
qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t}; |
qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t}; |
351 |
} elsif ( $pkg->{delete} ) { |
} elsif ( $pkg->{delete} ) { |
352 |
print "delete from ", $pkg->{repo}, " (", basename($pkg->{rpm}->filename), ")\n"; |
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->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage}; |
$repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage}; |
355 |
} |
} |
356 |
} |
} |
388 |
my $repo = shift; |
my $repo = shift; |
389 |
my $counts = shift; |
my $counts = shift; |
390 |
|
|
391 |
|
return 0 if $pkg->{src}; |
392 |
$counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++; |
$counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++; |
393 |
return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver}; |
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}; |
return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel}; |
402 |
my $pkgs = shift; |
my $pkgs = shift; |
403 |
|
|
404 |
foreach my $cmp ( @$pkgs ) { |
foreach my $cmp ( @$pkgs ) { |
405 |
next if $cmp->{src} || $cmp->{name} ne $pkg->{name} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio}; |
next if $cmp->{src} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio}; |
406 |
|
next if $pkg->{name} ne ( $pkg->{src} ? $cmp->{base} : $cmp->{name} ); |
407 |
if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) { |
if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) { |
408 |
$dest = $hirepo; |
$dest = $hirepo; |
409 |
last; |
last; |