/[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.76 - (show annotations) (download)
Fri Oct 10 14:07:52 2014 UTC (10 years, 1 month ago) by slords
Branch: MAIN
Changes since 1.75: +461 -448 lines
Prep for 10 (centos7) by moving arch into hash

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( 'ostr:', \%opts );
18 $opts{r} ||= '';
19
20 my $rpm_flags = RPM2->vsf_nodsaheader | RPM2->vsf_norsaheader | RPM2->vsf_nodsa | RPM2->vsf_norsa;
21
22 my $osdir = 'SME';
23 my $disttag = 'sme';
24 my $repotag = 'sme';
25
26 my $distrepo = { '8' => { active => 1,
27 centos => 5,
28 archs => [ 'i386', 'x86_64' ],
29 repo => '/build/smeserver/repo/8/',
30 builds => ['/build/builds/smeserver-8-core/'],
31 community => '/build/builds/smeserver-8-contribs/',
32 stage => '/build/smeserver/stage/8/',
33 sign => 1,
34 keyname => 'SME Server 7 signing key <bugteam@contribs.org>',
35 checksum => 'sha',
36 },
37 '9' => { active => 1,
38 centos => 6,
39 archs => [ 'i386', 'x86_64' ],
40 repo => '/build/smeserver/repo/9/',
41 builds => ['/build/builds/smeserver-9-core/'],
42 community => '/build/builds/smeserver-9-contribs/',
43 stage => '/build/smeserver/stage/9/',
44 sign => 1,
45 keyname => 'SME Server 7 signing key <bugteam@contribs.org>',
46 checksum => 'sha256',
47 },
48 '10' => { active => 0,
49 centos => 7,
50 archs => [ 'x86_64' ],
51 repo => '/build/smeserver/repo/testing/10/',
52 builds => ['/build/builds/smeserver-10-core/'],
53 community => '/build/builds/smeserver-10-contribs/',
54 stage => '/build/smeserver/stage/10/',
55 sign => 1,
56 keyname => 'SME Server 7 signing key <bugteam@contribs.org>',
57 checksum => 'sha256',
58 },
59 };
60
61 my $repos = { "${repotag}os" => { prio => 19, inc => 1, ver => 1, rel => 1, os => 1 },
62 "${repotag}updates" => { prio => 18, inc => 1, ver => 1, rel => 1 },
63 "${repotag}updates-testing" => { prio => 17, inc => 1, ver => 1, rel => 3 },
64 "${repotag}extras" => { prio => 16, inc => 0, ver => 1, rel => 1 },
65 "${repotag}addons" => { prio => 15, inc => 0, ver => 1, rel => 1 },
66 "${repotag}contribs" => { prio => 14, inc => 0, ver => 1, rel => 1 },
67 "${repotag}test" => { prio => 13, inc => 0, ver => 2, rel => 3, devel => 2 },
68 "${repotag}dev" => { prio => 12, inc => 0, ver => 1, rel => 1, devel => 1 },
69 'centos' => { prio => 10, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
70 'epel' => { prio => 9, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
71 'rpmforge' => { prio => 7, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
72 'atrpms' => { prio => 6, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
73 'builds' => { prio => 4, inc => 0, ver => 0, rel => 0, orig => 1 },
74 'community' => { prio => 2, inc => 0, ver => 0, rel => 0, orig => 1 },
75 'stage' => { prio => 1, inc => 0, ver => 0, rel => 0, stage => 1, os => 1 },
76 };
77
78 my $baserepo = { "~S${repotag}os/~A/" => "${repotag}os",
79 "~S${repotag}updates/~A/" => "${repotag}updates",
80 "~S${repotag}updates-testing/~A/" => "${repotag}updates-testing",
81 "~S${repotag}extras/~A/" => "${repotag}extras",
82 "~S${repotag}addons/~A/" => "${repotag}addons",
83 "~S${repotag}contribs/~A/" => "${repotag}contribs",
84 "~S${repotag}test/~A/" => "${repotag}test",
85 "~S${repotag}dev/~A/" => "${repotag}dev",
86 "/build/smeserver/stage/~s/~A/" => 'stage',
87 '/mirrors/centos/~C/fasttrack/~A/' => 'centos',
88 '/mirrors/centos/~C/updates/~A/' => 'centos',
89 '/mirrors/centos/~C/os/~A/' => 'centos',
90 '/mirrors/centos/~C/extras/~A/' => 'centos',
91 '/mirrors/centos-vault/~C/fasttrack/~A/' => 'centos',
92 '/mirrors/centos-vault/~C/updates/~A/' => 'centos',
93 '/mirrors/centos-vault/~C/os/~A/' => 'centos',
94 '/mirrors/centos-vault/~C/extras/~A/' => 'centos',
95 '/mirrors/fedora/epel/~C/~A/' => 'epel',
96 '/mirrors/fedora/epel/testing/~C/~A/' => 'epel',
97 '/mirrors/rpmforge/redhat/el~C/en/~A/dag/' => 'rpmforge',
98 '/mirrors/rpmforge/redhat/el~C/en/~A/extras/' => 'rpmforge',
99 '/mirrors/rpmforge/source/' => 'rpmforge',
100 '/mirrors/atrpms/el~C-~A/atrpms/stable/' => 'atrpms',
101 '/mirrors/atrpms/el~C-~A/atrpms/testing/' => 'atrpms',
102 '/mirrors/atrpms/src/el~C-~A/atrpms/stable/' => 'atrpms',
103 '/mirrors/atrpms/src/el~C-~A/atrpms/testing/' => 'atrpms',
104 };
105
106 my $skippkg = { '8' => { 'atrpms' => { map { $_ => 1 } ( 'clamav', 'gnupg' ) },
107 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3' ) },
108 'epel' => { map { $_ => 1 } ( 'clamav', 'fping', 'html2ps', 'horde', 'libtalloc', 'libtdb', 'oidentd', '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', 'smolt' ) },
109 'rpmforge' => { map { $_ => 1 } ( 'dovecot', 'libtalloc', 'mod_auth_tkt', 'perl-Test-Inline', 'spamassassin' ) },
110 },
111 '9' => { 'atrpms' => { map { $_ => 1 } ( 'clamav', 'perl-Pod-Escapes', 'perl-Pod-Simple' ) },
112 'epel' => { map { $_ => 1 } ( 'oidentd', 'perl-Razor-Agent' ) },
113 'rpmforge' => { map { $_ => 1 } ( 'perl-CGI', 'perl-Compress-Raw-Zlib', 'perl-ExtUtils-ParseXS', 'perl-Pod-Escapes', 'perl-Pod-Simple', 'perl-Time-HiRes', 'perl-version', 'spamassassin' ) },
114 },
115 '10' => {
116 },
117 };
118
119 my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos;
120 my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos;
121 $devel2 ||= $devel1;
122
123 my ($rpms, %base, %latest, %sources);
124 foreach my $ver ( sort { $a <=> $b } keys %$distrepo ) {
125 next unless $distrepo->{$ver}->{active};
126 my %repochg = ();
127 $rpms = ();
128 %latest = ();
129 %sources = ();
130 %base = ();
131
132 foreach my $dir ( sort { $repos->{$baserepo->{$b}}->{prio} <=> $repos->{$baserepo->{$a}}->{prio} || $a cmp $b } keys %$baserepo ) {
133 my $bdir = $dir;
134 $bdir =~ s/~S/$distrepo->{$ver}->{repo}/;
135 $bdir =~ s/~s/$ver/;
136 $bdir =~ s/~C/$distrepo->{$ver}->{centos}/;
137 for my $arch ( @{$distrepo->{$ver}->{'archs'}}, 'SRPMS/' ) {
138 my $adir = $bdir;
139 if ( $arch eq 'SRPMS/' ) {
140 $adir =~ s/~A.*//;
141 if ( -d "${adir}SRPMS" ) {
142 $adir .= "SRPMS/";
143 } elsif ( -d "${adir}Source/SPackages" ) {
144 $adir .= "Source/SPackages/";
145 }
146 } else {
147 $adir =~ s/~A/$arch/;
148 if ( -d "${adir}RPMS" ) {
149 $adir .= "RPMS/";
150 } elsif ( -d "${adir}Packages" ) {
151 $adir .= "Packages/";
152 } elsif ( -d "${adir}CentOS" ) {
153 $adir .= "CentOS/";
154 } elsif ( -d "${adir}$osdir" ) {
155 $adir .= "$osdir/";
156 }
157 }
158 next unless -d $adir;
159 opendir DIR, $adir or next;
160 process_rpm("$adir$_", $ver, $baserepo->{$dir}) foreach readdir DIR;
161 closedir DIR;
162 last unless $dir =~ m{~A};
163 }
164 }
165 find( { wanted => sub { process_rpm($_, $ver, 'builds'); }, no_chdir => 1, follow_fast => 1 }, "$_" ) foreach @{$distrepo->{$ver}->{'builds'}};
166 find( { wanted => sub { process_rpm($_, $ver, 'community'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$ver}->{'community'} ) if $distrepo->{$ver}->{'community'};
167
168 foreach my $base ( sort keys %$rpms ) {
169 next unless $rpms->{$base}->{rpms};
170 my %track = ();
171 my %seen = ();
172 my %counts = ();
173 my $acnt = ();
174 my $print = 0;
175 %latest = ();
176
177 foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) {
178 next if $pkg->{done};
179
180 my $tmp = $pkg->{svr};
181 # srpm transformations to match up binary and source rpms
182 SRC: {
183 # Try to find the name the binary wants (no changes)
184 $rpms->{$base}->{vers}->{$tmp} && last SRC;
185
186 # rpmforge (.el4.rf to .rf, with rf,rfb,rft,rfx endings)
187 ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf[btx]?)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
188 # rpmforge (.el4.rfx to .rf, rfb,rft,rfx switched to rf)
189 ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)[btx]$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
190 # rpmforge (.el4.rf to .rfx, rf,rfb,rft,rfx switched to rfx)
191 ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)[btx]?$}{$1x} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
192 # rpmforge (.el4.rf to .el5) TODO: remove when no longer needed
193 ($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.el5} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
194 # rpmforge (.2.el4.rf to .rf, minor modification not pushed to source?) TODO: remove when no longer needed
195 ($tmp = $pkg->{svr}) =~ s{\.2\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
196
197 # atrpms (remove .at)
198 ($tmp = $pkg->{svr}) =~ s{\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
199 # atrpms (remove .el4.at)
200 ($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
201 # atrpms (remove .el4)
202 ($tmp = $pkg->{svr}) =~ s{\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
203 # atrpms (remove .0.el5, minor modification not pushed to source?) TODO: remove when no longer needed
204 ($tmp = $pkg->{svr}) =~ s{\.0\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
205
206 # Transformations that we hopefully won't have to use anymore TODO: remove if no issues
207 #($tmp = $pkg->{svr}) =~ s{(\.el\d)\.rf$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
208 #($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
209 #($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
210 #($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d\.rf$}{$1.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
211 #($tmp = $pkg->{svr}) =~ s{\.el\d_}{_} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
212 #($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
213 #($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
214 #($tmp = $pkg->{svr}) =~ s{\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
215 #($tmp = $pkg->{svr}) =~ s{\.el\d\.$disttag$}{ && $rpms->{$base}->{vers}->{$tmp} && last SRC;
216 }
217 if ( $rpms->{$base}->{vers}->{$tmp} ) {
218 foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) {
219 $tmp->{svr} = $pkg->{svr};
220 push @{$rpms->{$base}->{rpms}}, $tmp unless $tmp->{added};
221 $tmp->{added}++;
222 }
223 }
224
225 my %orig = ();
226 my %pkgs = ();
227 my %reposrc = ();
228 my $srpm = undef;
229 foreach my $cmp ( sort { $a->{src} <=> $b->{src} || $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} } @{$rpms->{$base}->{rpms}} ) {
230 next unless $cmp->{svr} eq $pkg->{svr};
231
232 if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) {
233 if ( $cmp->{src} ) {
234 if ( ! $track{repo} ) {
235 $cmp->{delete}++;
236 $cmp->{done}++;
237 next;
238 }
239 } else {
240 $track{repo} = $cmp->{repo};
241 $track{svr} = $cmp->{svr};
242 }
243 }
244 if ( $cmp->{svr} eq $track{svr} ) {
245 if ( $seen{$cmp->{nvra}} ) {
246 if ( $track{repo} ne $cmp->{repo} ) {
247 if ($repos->{$cmp->{repo}}->{stage} ) {
248 if ( $seen{$cmp->{nvra}}->{latest} ) {
249 $seen{$cmp->{nvra}}->{latest}++;
250 delete $cmp->{delete} if $cmp->{delete};
251 } else {
252 $cmp->{delete}++;
253 }
254 } elsif ( $repos->{$cmp->{repo}}->{orig} ) {
255 $orig{$cmp->{nvra}}++;
256 unless ( $repos->{$cmp->{repo}}->{base} ) {
257 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
258 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
259 }
260 } elsif ( $cmp->{src} ) {
261 if ( $cmp->{delete} && $cmp->{oldrepo} && $reposrc{$cmp->{oldrepo}}) {
262 $cmp->{repo} = $cmp->{oldrepo};
263 delete $cmp->{delete};
264 }
265 if ( $reposrc{$cmp->{repo}} ) {
266 $reposrc{$cmp->{repo}}->{srpm} = $cmp;
267 $srpm = $cmp if ! $srpm;
268 } elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} && ! $cmp->{done} ) {
269 $cmp->{delete}++;
270 }
271 } elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) {
272 $cmp->{delete}++;
273 }
274 } elsif ( $cmp->{src} ) {
275 if ( $reposrc{$cmp->{repo}} && $reposrc{$cmp->{repo}}->{srpm} && $reposrc{$cmp->{repo}}->{srpm}->{oldrepo} ne $cmp->{repo} ) {
276 $acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{src} = [
277 grep { $_ ne $reposrc{$cmp->{repo}}->{srpm} } @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{src}}
278 ];
279
280 if ( @{$reposrc{$cmp->{repo}}->{srpm}->{repos}} == 1 ) {
281 $reposrc{$cmp->{repo}}->{srpm}->{repo} = $reposrc{$cmp->{repo}}->{srpm}->{oldrepo};
282 delete $reposrc{$cmp->{repo}}->{srpm}->{oldrepo};
283 delete $reposrc{$cmp->{repo}}->{srpm}->{delete};
284 delete $reposrc{$cmp->{repo}}->{srpm}->{repos};
285 delete $reposrc{$cmp->{repo}}->{srpm}->{done};
286 $seen{$cmp->{nvra}} = $cmp if $seen{$cmp->{nvra}} eq $reposrc{$cmp->{repo}}->{srpm};
287 } else {
288 warn "How did I get here??";
289 }
290 } else {
291 $seen{$cmp->{nvra}} = $cmp if $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo};
292 }
293 $srpm = $cmp if ! $srpm && $cmp->{src};
294 $reposrc{$cmp->{repo}}->{srpm} = $cmp if $reposrc{$cmp->{repo}};
295 }
296 } elsif ( $repos->{$cmp->{repo}}->{stage} ) {
297 $cmp->{delete}++;
298 } else {
299 $srpm = $cmp if ! $srpm && $cmp->{src};
300 my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
301 $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
302 $dest = $devel1 if verrel($cmp, $dest, \%counts);
303 if ( $cmp->{repo} ne $dest ) {
304 push @{$cmp->{repos}}, $dest;
305 if ( $repos->{$cmp->{repo}}->{orig} ) {
306 $orig{$cmp->{nvra}}++;
307 unless ( $repos->{$cmp->{repo}}->{base} ) {
308 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
309 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
310 }
311 } elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
312 $reposrc{$cmp->{repo}}->{srpm} = $cmp;
313 } else {
314 $cmp->{delete}++;
315 }
316 $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
317 $cmp->{repo} = $dest;
318 if ( ! $cmp->{src} && $repos->{$dest}->{prio} > $repos->{$track{repo}}->{prio} ) {
319 $track{repo} = $dest;
320 $track{svr} = $cmp->{svr};
321 }
322 }
323 if ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
324 $reposrc{$cmp->{repo}}->{srpm} = $cmp;
325 }
326 }
327 } else {
328 if ( $track{repo} eq $cmp->{repo} ) {
329 if ( verrel($cmp, $cmp->{repo}, \%counts) ) {
330 $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
331 } elsif ( $cmp->{src} ) {
332 $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
333 } else {
334 $track{svr} = $cmp->{svr};
335 }
336 } elsif ( ! $repos->{$cmp->{repo}}->{base} ) {
337 if ( $repos->{$cmp->{repo}}->{orig} ) {
338 $srpm = $cmp if ! $srpm && $cmp->{src};
339 my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
340 $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
341 $dest = $devel1 if verrel($cmp, $dest, \%counts);
342 unless ( $cmp->{src} && ! $reposrc{$dest} ) {
343 if ( $repos->{$dest}->{prio} >= $repos->{$track{repo}}->{prio} && ! verrel($cmp, $dest, \%counts) ) {
344 unless ( $repos->{$cmp->{repo}}->{base} ) {
345 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
346 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
347 }
348 push @{$cmp->{repos}}, $dest;
349 $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
350 $cmp->{repo} = $dest;
351 $reposrc{$cmp->{repo}}->{srpm} = $cmp if $cmp->{src};
352 $orig{$cmp->{nvra}}++;
353 }
354 }
355 } else {
356 $cmp->{delete}++;
357 }
358 }
359 }
360 unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) {
361 $pkgs{$cmp->{nvra}}++;
362 $latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}};
363 $reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{src} || $repos->{$cmp->{repo}}->{stage};
364 if ( $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc} ) {
365 $cmp->{latest}++ if ! $seen{$cmp->{nvra}} || $cmp->{src};
366 }
367 $seen{$cmp->{nvra}} = $cmp unless $seen{$cmp->{nvra}};
368 push @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{$cmp->{src} ? 'src' : $cmp->{rpm}->arch}}, $cmp unless $cmp->{done};
369 }
370 $cmp->{done}++;
371 }
372 if ( $srpm ) {
373 foreach my $r ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %reposrc ) {
374 unless ( $reposrc{$r}->{srpm} ) {
375 unshift @{$srpm->{repos}}, $r;
376 $srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo};
377 $srpm->{repo} = $r;
378 $reposrc{$r}->{srpm} = $srpm;
379 }
380 }
381 } elsif ( scalar keys %pkgs && $opts{s} ) {
382 print "\n * missing source ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n";
383 }
384 print "\n * missing originals ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs;
385 }
386
387 foreach my $r ( keys %$acnt ) {
388 foreach my $p ( keys %{$acnt->{$r}} ) {
389 foreach my $a ( keys %{$acnt->{$r}->{$p}} ) {
390 if ( $a eq 'noarch' ) {
391 my $p2 = ${$acnt->{$r}->{$p}->{$a}}[0];
392 if ( ! $p2->{repos} && scalar @{$acnt->{$r}->{$p}->{$a}} != scalar @{$distrepo->{$ver}->{'archs'}} ) {
393 $p2->{oldrepo} = $p2->{repo};
394 push @{$p2->{repos}}, $p2->{repo};
395 }
396 } elsif ( scalar @{$acnt->{$r}->{$p}->{$a}} != 1 ) {
397 print "\n * many packages ($r, $a, $p)\n" unless $p =~ m{^syslinux-nonlinux-[0-9]};
398 }
399 }
400 }
401 }
402
403 foreach my $pkg ( sort { $a->{nvra} cmp $b->{nvra} } @{$rpms->{$base}->{rpms}} ) {
404 if ( $pkg->{latest} && $pkg->{latest} == 1 ) {
405 unless ( grep { $_->{nvra} eq $pkg->{nvra} && $_->{repo} eq $stage } @{$rpms->{$base}->{rpms}} ) {
406 $pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo};
407 $pkg->{repo} = $stage;
408 push @{$pkg->{repos}}, $stage;
409 }
410 }
411
412 if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) {
413 print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
414 $print++;
415 }
416
417 my $src = $pkg->{rpm}->filename;
418 if ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) {
419 print "sign package (", basename($pkg->{rpm}->filename), ")\n";
420 unless ( $opts{t} ) {
421 qx(cat $HOME/.rpmpass | setsid rpm -D '_gpg_name $distrepo->{$ver}->{keyname}' --addsign $src >& /dev/null);
422 if ($?) {
423 print " * failed to sign package\n";
424 next;
425 }
426 }
427 }
428
429 if ( $pkg->{repos} ) {
430 foreach my $repo ( @{$pkg->{repos}} ) {
431 if ( $pkg->{delete} ) {
432 print "move from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
433 $pkg->{delete} = 0;
434 $repochg{$pkg->{oldrepo}}++ unless $repos->{$pkg->{oldrepo}}->{base} || $repos->{$pkg->{oldrepo}}->{stage};
435 } elsif ( $pkg->{oldrepo} eq $repo ) {
436 print "distribute noarch in $repo (", basename($pkg->{rpm}->filename), ")\n";
437 } else {
438 print "copy from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
439 }
440 $repochg{$repo}++ unless $repos->{$repo}->{base} || $repos->{$repo}->{stage};
441 $pkg->{oldrepo} = $repo unless $pkg->{oldrepo} eq ${$pkg->{repos}}[0];
442
443 my @d = ();
444 my $head = $distrepo->{$ver}->{repo} . $repo . '/';
445 $head = $distrepo->{$ver}->{stage} if $repos->{$repo}->{stage};
446 my $tail = $repos->{$repo}->{os} ? "$osdir/" : 'RPMS/';
447 if ( $pkg->{src} ) {
448 push @d, "${head}SRPMS/" . basename($pkg->{rpm}->filename);
449 } elsif ( $pkg->{rpm}->arch eq 'noarch' ) {
450 push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @{$distrepo->{$ver}->{'archs'}};
451 } elsif ( $pkg->{rpm}->arch =~ m{^(i[356]86)$} ) {
452 push @d, "${head}i386/$tail" . basename($pkg->{rpm}->filename);
453 } else {
454 push @d, $head . $pkg->{rpm}->arch . "/$tail" . basename($pkg->{rpm}->filename);
455 }
456 foreach my $dest ( @d ) {
457 qx(cp --preserve=timestamps $src $dest) unless $opts{t} || -f "$dest";
458 }
459
460 }
461 qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t};
462 } elsif ( $pkg->{delete} ) {
463 print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
464 qx(rm -f $src) unless $opts{t};
465 $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
466 if ( $repos->{$pkg->{repo}}->{orig} && ! $repos->{$pkg->{repo}}->{base} ) {
467 my $tag = dirname(dirname($pkg->{rpm}->{filename}));
468 qx(rm -f $tag/PUSHED) if ! $opts{t} && -d $tag && -f "$tag/PUSHED";
469 }
470 }
471 }
472
473 if ( $rpms->{$base}->{srpms} ) {
474 foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{srpms}} ) {
475 next if $pkg->{done} || $repos->{$pkg->{repo}}->{orig} || $repos->{$pkg->{repo}}->{base};
476 $pkg->{delete}++;
477 my $src = $pkg->{rpm}->filename;
478 if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) {
479 print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
480 $print++;
481 }
482 print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
483 qx(rm -f $src) unless $opts{t};
484 $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
485 }
486 }
487 }
488
489 if ( %repochg ) {
490 print "\nrebuild repo ($disttag$ver)\n", "=" x length("rebuild repo ($disttag$ver)"), "\n";
491 }
492 foreach my $repo ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %repochg ) {
493 next if $repos->{$repo}->{orig} || $repos->{$repo}->{stage};
494 foreach my $arch ( @{$distrepo->{$ver}->{'archs'}} ) {
495 my $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
496 $dir = qx(readlink -f $dir);
497 if ( $dir ) {
498 chomp $dir;
499 } else {
500 $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
501 }
502 print "rebuild $repo/$arch\n";
503 unless ( $opts{t} ) {
504 my $checksum = "--checksum $distrepo->{$ver}->{checksum}";
505
506 my $exclude = "";
507 $exclude .= " --exclude ${osdir}/*" if -d "$dir/Packages";
508 $exclude .= " --exclude *smeserver-release*.rpm" if $dir =~ m{test/|-testing/};
509
510 my $groupfile = "";
511 $groupfile = "--simple-md-filenames --groupfile repodata/comps.xml" if -f "$dir/repodata/comps.xml";
512
513 qx(createrepo --update --database --exclude *.src.rpm --exclude *-debuginfo-*.rpm $checksum $exclude $groupfile $dir);
514 qx(repoview $dir);
515
516 qx(rm -rf $dir/.olddata) if -d "$dir/.olddata";
517 qx(rm -rf $dir/.repodata) if -d "$dir/.repodata";
518 qx(rm -rf $dir/repodata/index.html) if -f "$dir/repodata/index.html";
519 qx(rm -rf $dir/repodata/update-info) if -d "$dir/repodata/update-info";
520 qx(rm -rf $dir/repodata/repoview) if -d "$dir/repodata/repoview";
521 }
522 }
523 }
524 unless ( $opts{t} ) {
525 foreach (@{$distrepo->{$ver}->{builds}})
526 {
527 finddepth(sub{rmdir}, "$_") if -d "$_";
528 }
529 finddepth(sub{rmdir}, $distrepo->{$ver}->{community}) if -d "$distrepo->{$ver}->{community}";
530 }
531 }
532
533 sub verrel {
534 my $pkg = shift;
535 my $repo = shift;
536 my $counts = shift;
537
538 return 0 if $pkg->{src};
539 $counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++;
540 return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver};
541 return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel};
542 return 0;
543 }
544
545 sub pkgdest {
546 my $pkg = shift;
547 my $dest = shift;
548 my $hirepo = shift;
549 my $pkgs = shift;
550
551 foreach my $cmp ( @$pkgs ) {
552 next if $cmp->{src} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio};
553 next if $pkg->{name} ne ( $pkg->{src} ? $cmp->{base} : $cmp->{name} );
554 if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) {
555 $dest = $hirepo;
556 last;
557 } else {
558 $dest = $cmp->{repo};
559 }
560 }
561 return $dest;
562 }
563
564 sub process_rpm {
565 my $rpm = shift;
566 my $ver = shift;
567 my $repo = shift;
568 return unless $rpm =~ m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$};
569 my $base = $1;
570 return unless ! $opts{r} || $base =~ m[$opts{r}];
571 return unless $latest{$base} || $sources{$base} || ! $repos->{$repo}->{base};
572
573 my $pkg;
574 eval { $pkg = RPM2->open_package($rpm, $rpm_flags); };
575 if ($@) { print " * corrupt package ($rpm)\n"; return; }
576 eval { my $sig = $pkg->siggpg };
577
578 my $nosig = 1;
579 eval { my $sig = $pkg->dsaheader }; $nosig &= ! $@;
580 eval { my $sig = $pkg->rsaheader }; $nosig &= ! $@;
581 eval { my $sig = $pkg->siggpg }; $nosig &= ! $@;
582 eval { my $sig = $pkg->sigpgp }; $nosig &= ! $@;
583
584 my $cmp = $latest{$pkg->name};
585 if ( $repos->{$repo}->{base} && ! $pkg->is_source_package ) {
586 return unless $cmp;
587 return if $repos->{$cmp->{repo}}->{base} && $repos->{$cmp->{repo}}->{prio} > $repos->{$repo}->{prio} && $pkg ge $cmp->{rpm};
588 }
589 my ($src, $version, $release) = ($pkg->is_source_package ? $pkg->filename : $pkg->sourcerpm) =~ m{(?:^|/)([^/]*)-([^-]+)-([^-]+)\.\w+\.rpm$};
590 return if $skippkg->{$ver}->{$repo} && ( $skippkg->{$ver}->{$repo}->{$src} || $skippkg->{$ver}->{$repo}->{$pkg->name} );
591 return if $repos->{$repo}->{base} && $nosig && $baserepo->{$ver}->{sign};
592 if ( $nosig && ! -f "$HOME/.rpmpass" ) { print " * missing signature (" .$pkg->filename . ")\n"; return; }
593 my $arch = 'unknown';
594 $arch = 'SRPMS' if $pkg->filename =~ m{[/-](SRPMS?|src|source)/};
595 $arch = 'x86_64' if $pkg->filename =~ m{[/-]x86_64/};
596 $arch = 'i386' if $pkg->filename =~ m{[/-](i[356]86)/};
597 $arch = 'noarch' if $pkg->filename =~ m{[/-]noarch/};
598
599 my $rpmhash = { base => $src,
600 name => $pkg->name,
601 repo => $repo,
602 nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ),
603 svr => $src.'-'.$version.'-'.$release,
604 src => $pkg->is_source_package,
605 arch => $arch,
606 ver => $version,
607 rel => $release,
608 rpm => $pkg,
609 nosig => $nosig,
610 };
611 if ( $pkg->is_source_package ) {
612 push @{$rpms->{$src}->{srpms}}, $rpmhash;
613 push @{$rpms->{$src}->{vers}->{$rpmhash->{svr}}}, $rpmhash;
614 } else {
615 push @{$rpms->{$src}->{rpms}}, $rpmhash;
616 }
617 $sources{$src}++;
618
619 return if $pkg->is_source_package || $repos->{$repo}->{stage};
620 if ( ! $repos->{$repo}->{base} ) {
621 if ( ! $cmp || $pkg gt $cmp->{rpm} ) {
622 $latest{$pkg->name} = $rpmhash;
623 }
624 } elsif ( ( $repos->{$repo}->{prio} >= $repos->{$cmp->{repo}}->{prio} || ! $repos->{$cmp->{repo}}->{base} ) && $pkg ge $cmp->{rpm} ) {
625 $latest{$pkg->name} = $rpmhash;
626 }
627 }

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