/[smeserver]/builds_bin/update_repos
ViewVC logotype

Contents of /builds_bin/update_repos

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.58 - (show annotations) (download)
Sat Jul 24 15:28:38 2010 UTC (14 years, 4 months ago) by slords
Branch: MAIN
Changes since 1.57: +4 -3 lines
Update tools

1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use RPM2;
6 use File::Find;
7 use File::Basename;
8 use Getopt::Std;
9 use Data::Dumper;
10
11 delete $ENV{PATH};
12 my $HOME=$ENV{HOME};
13 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;
21 $rpm_flags |= RPM2->vsf_nosha1 | RPM2->vsf_nomd5 | RPM2->vsf_nodsa | RPM2->vsf_norsa;
22
23 my $osdir = 'SME';
24 my $disttag = 'sme';
25 my $repotag = 'sme';
26
27 my @archs = ( 'i386', 'x86_64' );
28
29 my $distrepo = { '7' => { active => 1,
30 centos => 4,
31 repo => '/releases/7/',
32 os => 'RPMS/',
33 builds => '/builds/smeserver-7-core/',
34 community => '/builds/smeserver-7-contribs/',
35 stage => '/stage/7/',
36 },
37 '8' => { active => 1,
38 centos => 5,
39 repo => '/releases/testing/8/',
40 os => '',
41 builds => '/builds/smeserver-8-core/',
42 community => '/builds/smeserver-8-contribs/',
43 stage => '/stage/8/',
44 },
45 };
46
47 my $repos = { "${repotag}os" => { prio => 18, inc => 1, ver => 1, rel => 1, os => 1 },
48 "${repotag}updates" => { prio => 17, inc => 1, ver => 1, rel => 1 },
49 "${repotag}updates-testing" => { prio => 16, inc => 1, ver => 1, rel => 3 },
50 "${repotag}extras" => { prio => 15, inc => 0, ver => 1, rel => 1 },
51 "${repotag}addons" => { prio => 14, inc => 0, ver => 1, rel => 1 },
52 "${repotag}contribs" => { prio => 13, inc => 0, ver => 1, rel => 1 },
53 "${repotag}test" => { prio => 12, inc => 0, ver => 2, rel => 3, devel => 2 },
54 "${repotag}dev" => { prio => 11, inc => 0, ver => 1, rel => 1, 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 'rpmforge' => { prio => 7, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
58 'atrpms' => { prio => 6, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
59 'builds' => { prio => 4, inc => 0, ver => 0, rel => 0, orig => 1 },
60 'community' => { prio => 2, inc => 0, ver => 0, rel => 0, orig => 1 },
61 'stage' => { prio => 1, inc => 0, ver => 0, rel => 0, stage => 1, os => 1 },
62 };
63
64 my $baserepo = { "~S${repotag}os/~A/$osdir/~O" => "${repotag}os",
65 "~S${repotag}updates/~A/RPMS/" => "${repotag}updates",
66 "~S${repotag}updates-testing/~A/RPMS/" => "${repotag}updates-testing",
67 "~S${repotag}extras/~A/RPMS/" => "${repotag}extras",
68 "~S${repotag}addons/~A/RPMS/" => "${repotag}addons",
69 "~S${repotag}contribs/~A/RPMS/" => "${repotag}contribs",
70 "~S${repotag}test/~A/RPMS/" => "${repotag}test",
71 "~S${repotag}dev/~A/RPMS/" => "${repotag}dev",
72 "/stage/~s/~A/$osdir/~O" => 'stage',
73 '/mirrors/centos/~C/fasttrack/~A/RPMS/' => 'centos',
74 '/mirrors/centos/~C/updates/~A/RPMS/' => 'centos',
75 '/mirrors/centos/~C/os/~A/CentOS/~O' => 'centos',
76 '/mirrors/centos/~C/extras/~A/RPMS/' => 'centos',
77 '/mirrors/fedora/epel/~C/~A/' => 'epel',
78 '/mirrors/fedora/epel/testing/~C/~A/' => 'epel',
79 '/mirrors/rpmforge/dag/redhat/el~C/en/~A/dag/RPMS/' => 'rpmforge',
80 '/mirrors/rpmforge/dag/source/' => 'rpmforge',
81 '/mirrors/atrpms/el~C-~A/atrpms/stable/' => 'atrpms',
82 '/mirrors/atrpms/el~C-~A/atrpms/testing/' => 'atrpms',
83 '/mirrors/atrpms/src/el~C-~A/atrpms/stable/' => 'atrpms',
84 '/mirrors/atrpms/src/el~C-~A/atrpms/testing/' => 'atrpms',
85 };
86
87 if ( $opts{q} ) {
88 $baserepo->{'/mirrors/centos-qa/CentOS/~C/fasttrack/~A/RPMS/'} = 'centos';
89 $baserepo->{'/mirrors/centos-qa/CentOS/~C/updates/~A/RPMS/'} = 'centos';
90 $baserepo->{'/mirrors/centos-qa/CentOS/~C/os/~A/CentOS/~O'} = 'centos';
91 $baserepo->{'/mirrors/centos-qa/CentOS/~C/extras/~A/RPMS/'} = 'centos';
92 }
93
94 my $skippkg = { '7' => { 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3' ) },
95 'epel' => { map { $_ => 1 } ( 'clamav', 'fping', 'ocsinventory', 'perl-Compress-Bzip2', 'perl-Compress-Raw-Zlib', 'perl-Compress-Raw-Bzip2', 'perl-Crypt-OpenSSL-Bignum', 'perl-Crypt-OpenSSL-Random', 'perl-Crypt-OpenSSL-RSA', 'perl-DateTime', 'perl-Razor-Agent', 'perl-Text-Iconv', 'proftpd' ) },
96 'rpmforge' => { map { $_ => 1 } ( 'mod_auth_tkt', 'perl-Test-Inline', 'spamassassin' ) },
97 'atrpms' => { map { $_ => 1 } ( 'check4updates', 'dovecot', 'trac', 'yum' ) },
98 },
99 '8' => { 'atrpms' => { map { $_ => 1 } ( 'gnupg' ) },
100 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3' ) },
101 'epel' => { map { $_ => 1 } ( 'clamav', 'horde', 'libtalloc', 'libtdb', 'perl-Compress-Bzip2', 'perl-Compress-Raw-Zlib', 'perl-Compress-Raw-Bzip2', 'perl-Crypt-OpenSSL-Bignum', 'perl-Crypt-OpenSSL-Random', 'perl-Crypt-OpenSSL-RSA', 'perl-Razor-Agent', 'proftpd', 'smolt' ) },
102 'rpmforge' => { map { $_ => 1 } ( 'libtalloc', 'mod_auth_tkt', 'perl-Test-Inline', 'spamassassin' ) },
103 },
104 };
105
106 my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos;
107 my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos;
108 $devel2 ||= $devel1;
109
110 my ($rpms, %base, %latest, %sources);
111 foreach my $ver ( sort { $a <=> $b } keys %$distrepo ) {
112 next unless $distrepo->{$ver}->{active};
113 my %repochg = ();
114 $rpms = ();
115 %latest = ();
116 %sources = ();
117 %base = ();
118
119 foreach my $dir ( sort { $repos->{$baserepo->{$b}}->{prio} <=> $repos->{$baserepo->{$a}}->{prio} || $a cmp $b } keys %$baserepo ) {
120 my $bdir = $dir;
121 $bdir =~ s/~O/$distrepo->{$ver}->{os}/;
122 $bdir =~ s/~S/$distrepo->{$ver}->{repo}/;
123 $bdir =~ s/~s/$ver/;
124 $bdir =~ s/~C/$distrepo->{$ver}->{centos}/;
125 for my $arch ( @archs, 'SRPMS/' ) {
126 my $adir = $bdir;
127 if ( $arch eq 'SRPMS/' ) {
128 $adir =~ s/~A.*/$arch/ if $arch eq 'SRPMS/';
129 } else {
130 $adir =~ s/~A/$arch/;
131 }
132 opendir DIR, $adir or next;
133 next unless -d $adir;
134 process_rpm("$adir$_", $ver, $baserepo->{$dir}) foreach readdir DIR;
135 closedir DIR;
136 last unless $dir =~ m{~A};
137 }
138 }
139 find( { wanted => sub { process_rpm($_, $ver, 'builds'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$ver}->{'builds'} );
140 find( { wanted => sub { process_rpm($_, $ver, 'community'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$ver}->{'community'} ) if $distrepo->{$ver}->{'community'};
141
142 foreach my $base ( sort keys %$rpms ) {
143 next unless $rpms->{$base}->{rpms};
144 my %track = ();
145 my %seen = ();
146 my %counts = ();
147 my $acnt = ();
148 my $print = 0;
149 %latest = ();
150
151 foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) {
152 next if $pkg->{done};
153
154 my $tmp = $pkg->{svr};
155 SRC: {
156 $rpms->{$base}->{vers}->{$tmp} && last SRC;
157 ($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
158 ($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
159 ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
160 ($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.el5} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
161 ($tmp = $pkg->{svr}) =~ s{(\.el\d)\.rf$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
162 ($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
163 ($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
164 ($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d\.rf$}{$1.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
165 ($tmp = $pkg->{svr}) =~ s{\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
166 ($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
167 ($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
168 ($tmp = $pkg->{svr}) =~ s{\.el\d\.$disttag$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
169 }
170 if ( $rpms->{$base}->{vers}->{$tmp} ) {
171 foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) {
172 $tmp->{svr} = $pkg->{svr};
173 push @{$rpms->{$base}->{rpms}}, $tmp unless $tmp->{added};
174 $tmp->{added}++;
175 }
176 }
177
178 my %orig = ();
179 my %pkgs = ();
180 my %reposrc = ();
181 my $srpm = undef;
182 foreach my $cmp ( sort { $a->{src} <=> $b->{src} || $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} } @{$rpms->{$base}->{rpms}} ) {
183 next unless $cmp->{svr} eq $pkg->{svr};
184
185 if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) {
186 if ( $cmp->{src} ) {
187 if ( ! $track{repo} ) {
188 $cmp->{delete}++;
189 $cmp->{done}++;
190 next;
191 }
192 } else {
193 $track{repo} = $cmp->{repo};
194 $track{svr} = $cmp->{svr};
195 }
196 }
197 if ( $cmp->{svr} eq $track{svr} ) {
198 if ( $seen{$cmp->{nvra}} ) {
199 if ( $track{repo} ne $cmp->{repo} ) {
200 if ($repos->{$cmp->{repo}}->{stage} ) {
201 if ( $seen{$cmp->{nvra}}->{latest} ) {
202 $seen{$cmp->{nvra}}->{latest}++;
203 } else {
204 $cmp->{delete}++;
205 }
206 } elsif ( $repos->{$cmp->{repo}}->{orig}) {
207 $orig{$cmp->{nvra}}++;
208 unless ( $repos->{$cmp->{repo}}->{base} ) {
209 my $tag = sprintf '%s%s/%s-%s', $distrepo->{$ver}->{$cmp->{repo}}, $cmp->{name}, $cmp->{ver}, $cmp->{rel};
210 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
211 }
212 } elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
213 $reposrc{$cmp->{repo}}->{srpm} = $cmp;
214 } elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) {
215 $cmp->{delete}++;
216 }
217 }
218 } elsif ($repos->{$cmp->{repo}}->{stage} ) {
219 $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 unless ( $repos->{$cmp->{repo}}->{base} ) {
230 my $tag = sprintf '%s%s/%s-%s', $distrepo->{$ver}->{$cmp->{repo}}, $cmp->{name}, $cmp->{ver}, $cmp->{rel};
231 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
232 }
233 } elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
234 $reposrc{$cmp->{repo}}->{srpm} = $cmp;
235 } else {
236 $cmp->{delete}++;
237 }
238 $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
239 $cmp->{repo} = $dest;
240 if ( ! $cmp->{src} && $repos->{$dest}->{prio} > $repos->{$track{repo}}->{prio} ) {
241 $track{repo} = $dest;
242 $track{svr} = $cmp->{svr};
243 }
244 }
245 if ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
246 $reposrc{$cmp->{repo}}->{srpm} = $cmp;
247 }
248 }
249 } else {
250 if ( $track{repo} eq $cmp->{repo} ) {
251 if ( verrel($cmp, $cmp->{repo}, \%counts) ) {
252 $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
253 } elsif ( $cmp->{src} ) {
254 $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
255 } else {
256 $track{svr} = $cmp->{svr};
257 }
258 } elsif ( ! $repos->{$cmp->{repo}}->{base} ) {
259 if ( $repos->{$cmp->{repo}}->{orig} ) {
260 $srpm = $cmp if ! $srpm && $cmp->{src};
261 my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
262 $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
263 $dest = $devel1 if verrel($cmp, $dest, \%counts);
264 unless ( $cmp->{src} && ! $reposrc{$dest} ) {
265 if ( $repos->{$dest}->{prio} >= $repos->{$track{repo}}->{prio} && ! verrel($cmp, $dest, \%counts) ) {
266 unless ( $repos->{$cmp->{repo}}->{base} ) {
267 my $tag = sprintf '%s%s/%s-%s', $distrepo->{$ver}->{$cmp->{repo}}, $cmp->{name}, $cmp->{ver}, $cmp->{rel};
268 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
269 }
270 push @{$cmp->{repos}}, $dest;
271 $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
272 $cmp->{repo} = $dest;
273 $reposrc{$cmp->{repo}}->{srpm} = $cmp if $cmp->{src};
274 $orig{$cmp->{nvra}}++;
275 }
276 }
277 } else {
278 $cmp->{delete}++;
279 }
280 }
281 }
282 unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) {
283 $pkgs{$cmp->{nvra}}++;
284 $latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}};
285 $reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{src} || $repos->{$cmp->{repo}}->{stage};
286 unless ( $seen{$cmp->{nvra}} ) {
287 $seen{$cmp->{nvra}} = $cmp;
288 $cmp->{latest}++ if $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc};
289 }
290 push @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{$cmp->{src} ? 'src' : $cmp->{rpm}->arch}}, $cmp;
291 }
292 $cmp->{done}++;
293 }
294 if ( $srpm ) {
295 foreach my $r ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %reposrc ) {
296 unless ( $reposrc{$r}->{srpm} ) {
297 unshift @{$srpm->{repos}}, $r;
298 $srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo};
299 $srpm->{repo} = $r;
300 $reposrc{$r}->{srpm} = $srpm;
301 }
302 }
303 } elsif ( scalar keys %pkgs && $opts{s} ) {
304 print "\n * missing source ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n";
305 }
306 print "\n * missing originals ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs;
307 }
308
309 foreach my $r ( keys %$acnt ) {
310 foreach my $p ( keys %{$acnt->{$r}} ) {
311 foreach my $a ( keys %{$acnt->{$r}->{$p}} ) {
312 if ( $a eq 'noarch' ) {
313 my $p2 = ${$acnt->{$r}->{$p}->{$a}}[0];
314 if ( ! $p2->{repos} && scalar @{$acnt->{$r}->{$p}->{$a}} != scalar @archs ) {
315 $p2->{oldrepo} = $p2->{repo};
316 push @{$p2->{repos}}, $p2->{repo};
317 }
318 } elsif ( scalar @{$acnt->{$r}->{$p}->{$a}} != 1 ) {
319 print "\n * many packages ($r, $a, $p)\n";
320 }
321 }
322 }
323 }
324
325 foreach my $pkg ( sort { $a->{nvra} cmp $b->{nvra} } @{$rpms->{$base}->{rpms}} ) {
326 if ( $pkg->{latest} && $pkg->{latest} == 1 ) {
327 $pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo};
328 $pkg->{repo} = $stage;
329 push @{$pkg->{repos}}, $stage;
330 }
331 if ( ! $print && ($pkg->{delete} || $pkg->{repos} || $pkg->{nosig} ) ) {
332 print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
333 $print++;
334 }
335
336 my $src = $pkg->{rpm}->filename;
337 if ( $pkg->{nosig} ) {
338 print "sign package (", basename($pkg->{rpm}->filename), ")\n";
339 unless ( $opts{t} ) {
340 qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null);
341 if ($?) {
342 print " * failed to sign package\n";
343 next;
344 }
345 }
346 }
347
348 if ( $pkg->{repos} ) {
349 foreach my $repo ( @{$pkg->{repos}} ) {
350 if ( $pkg->{delete} ) {
351 print "move from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
352 $pkg->{delete} = 0;
353 $repochg{$pkg->{oldrepo}}++ unless $repos->{$pkg->{oldrepo}}->{base} || $repos->{$pkg->{oldrepo}}->{stage};
354 } elsif ( $pkg->{oldrepo} eq $repo ) {
355 print "distribute noarch in $repo (", basename($pkg->{rpm}->filename), ")\n";
356 } else {
357 print "copy from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
358 }
359 $repochg{$repo}++ unless $repos->{$repo}->{base} || $repos->{$repo}->{stage};
360 $pkg->{oldrepo} = $repo unless $pkg->{oldrepo} eq ${$pkg->{repos}}[0];
361
362 my @d = ();
363 my $head = $distrepo->{$ver}->{repo} . $repo . '/';
364 $head = $distrepo->{$ver}->{stage} if $repos->{$repo}->{stage};
365 my $tail = $repos->{$repo}->{os} ? "$osdir/" . $distrepo->{$ver}->{os} : 'RPMS/';
366 if ( $pkg->{src} ) {
367 push @d, "${head}SRPMS/" . basename($pkg->{rpm}->filename);
368 } elsif ( $pkg->{rpm}->arch eq 'noarch' ) {
369 push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @archs;
370 } elsif ( $pkg->{rpm}->arch =~ m{^(i[356]86)$} ) {
371 push @d, "${head}i386/$tail" . basename($pkg->{rpm}->filename);
372 } else {
373 push @d, $head . $pkg->{rpm}->arch . "/$tail" . basename($pkg->{rpm}->filename);
374 }
375 foreach my $dest ( @d ) {
376 qx(cp --preserve=timestamps $src $dest) unless $opts{t} || -f "$dest";
377 }
378
379 }
380 qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t};
381 } elsif ( $pkg->{delete} ) {
382 print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
383 qx(rm -f $src) unless $opts{t};
384 $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
385 if ( $repos->{$pkg->{repo}}->{orig} && ! $repos->{$pkg->{repo}}->{base} ) {
386 my $tag = sprintf '%s%s/%s-%s', $distrepo->{$ver}->{$pkg->{repo}}, $pkg->{name}, $pkg->{ver}, $pkg->{rel};
387 qx(rm -f $tag/PUSHED) if ! $opts{t} && -d $tag && -f "$tag/PUSHED";
388 }
389 }
390 }
391 }
392
393 if ( %repochg ) {
394 print "\nrebuild repo ($disttag$ver)\n", "=" x length("rebuild repo ($disttag$ver)"), "\n";
395 }
396 foreach my $repo ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %repochg ) {
397 next if $repos->{$repo}->{orig} || $repos->{$repo}->{stage};
398 foreach my $arch ( @archs ) {
399 my $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
400 $dir = qx(readlink -f $dir);
401 chomp $dir;
402 print "rebuild $repo/$arch\n";
403 unless ( $opts{t} ) {
404 if ( $dir =~ m{test/|-testing/} ) {
405 if ( -f "$dir/repodata/comps.xml" ) {
406 qx(createrepo --update --database --exclude *smeserver-release*.rpm --exclude *.src.rpm --exclude *-debuginfo-*.rpm --groupfile repodata/comps.xml $dir);
407 } else {
408 qx(createrepo --update --database --exclude *smeserver-release*.rpm --exclude *.src.rpm --exclude *-debuginfo-*.rpm $dir);
409 }
410 } else {
411 if ( -f "$dir/repodata/comps.xml" ) {
412 qx(createrepo --update --database --exclude *.src.rpm --exclude *-debuginfo-*.rpm --groupfile repodata/comps.xml $dir);
413 } else {
414 qx(createrepo --update --database --exclude *.src.rpm --exclude *-debuginfo-*.rpm $dir);
415 }
416 }
417 qx(repoview $dir);
418 qx(rm -rf $dir/.olddata) if -d "$dir/.olddata";
419 qx(rm -rf $dir/.repodata) if -d "$dir/.repodata";
420 }
421 }
422 }
423 unless ( $opts{t} ) {
424 finddepth(sub{rmdir}, $distrepo->{$ver}->{builds}) if -d "$distrepo->{$ver}->{builds}";
425 finddepth(sub{rmdir}, $distrepo->{$ver}->{community}) if -d "$distrepo->{$ver}->{community}";
426 }
427 }
428
429 sub verrel {
430 my $pkg = shift;
431 my $repo = shift;
432 my $counts = shift;
433
434 return 0 if $pkg->{src};
435 $counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++;
436 return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver};
437 return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel};
438 return 0;
439 }
440
441 sub pkgdest {
442 my $pkg = shift;
443 my $dest = shift;
444 my $hirepo = shift;
445 my $pkgs = shift;
446
447 foreach my $cmp ( @$pkgs ) {
448 next if $cmp->{src} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio};
449 next if $pkg->{name} ne ( $pkg->{src} ? $cmp->{base} : $cmp->{name} );
450 if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) {
451 $dest = $hirepo;
452 last;
453 } else {
454 $dest = $cmp->{repo};
455 }
456 }
457 return $dest;
458 }
459
460 sub process_rpm {
461 my $rpm = shift;
462 my $ver = shift;
463 my $repo = shift;
464 return unless $rpm =~ m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$};
465 my $base = $1;
466 return unless ! $opts{r} || $base =~ m[$opts{r}];
467 return unless $latest{$base} || $sources{$base} || ! $repos->{$repo}->{base};
468
469 my $pkg;
470 eval { $pkg = RPM2->open_package($rpm, $rpm_flags); };
471 if ($@) { print " * corrupt package ($rpm)\n"; return; }
472 eval { my $sig = $pkg->siggpg };
473 my $nosig = ! $@;
474
475 my $cmp = $latest{$pkg->name};
476 if ( $repos->{$repo}->{base} && ! $pkg->is_source_package ) {
477 return unless $cmp;
478 return if $repos->{$cmp->{repo}}->{base} && $repos->{$cmp->{repo}}->{prio} > $repos->{$repo}->{prio} && $pkg ge $cmp->{rpm};
479 }
480 my ($src, $version, $release) = ($pkg->is_source_package ? $pkg->filename : $pkg->sourcerpm) =~ m{(?:^|/)([^/]*)-([^-]+)-([^-]+)\.\w+\.rpm$};
481 return if $skippkg->{$ver}->{$repo} && ( $skippkg->{$ver}->{$repo}->{$src} || $skippkg->{$ver}->{$repo}->{$pkg->name} );
482 return if $repos->{$repo}->{base} && $nosig;
483 if ( $nosig && ! -f "$HOME/.rpmpass" ) { print " * missing signature (" .$pkg->filename . ")\n"; return; }
484 my $arch = 'unknown';
485 $arch = 'SRPMS' if $pkg->filename =~ m{[/-](SRPMS?|src|source)/};
486 $arch = 'x86_64' if $pkg->filename =~ m{[/-]x86_64/};
487 $arch = 'i386' if $pkg->filename =~ m{[/-](i[356]86)/};
488 $arch = 'noarch' if $pkg->filename =~ m{[/-]noarch/};
489
490 my $rpmhash = { base => $src,
491 name => $pkg->name,
492 repo => $repo,
493 nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ),
494 svr => $src.'-'.$version.'-'.$release,
495 src => $pkg->is_source_package,
496 arch => $arch,
497 ver => $version,
498 rel => $release,
499 rpm => $pkg,
500 nosig => $nosig,
501 };
502 if ( $pkg->is_source_package ) {
503 push @{$rpms->{$src}->{srpms}}, $rpmhash;
504 push @{$rpms->{$src}->{vers}->{$rpmhash->{svr}}}, $rpmhash;
505 } else {
506 push @{$rpms->{$src}->{rpms}}, $rpmhash;
507 }
508 $sources{$src}++;
509
510 return if $pkg->is_source_package || $repos->{$repo}->{stage};
511 if ( ! $repos->{$repo}->{base} ) {
512 if ( ! $cmp || $pkg gt $cmp->{rpm} ) {
513 $latest{$pkg->name} = $rpmhash;
514 }
515 } elsif ( ( $repos->{$repo}->{prio} >= $repos->{$cmp->{repo}}->{prio} || ! $repos->{$cmp->{repo}}->{base} ) && $pkg ge $cmp->{rpm} ) {
516 $latest{$pkg->name} = $rpmhash;
517 }
518 }

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed