/[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.77 - (show annotations) (download)
Fri Oct 10 15:46:43 2014 UTC (10 years, 1 month ago) by slords
Branch: MAIN
Changes since 1.76: +2 -1 lines
More arch updates for 10

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 } elsif ( $cmp->{src} || ( $cmp->{rpm}->arch =~ m{^(i[356]86)$} && grep $_ eq 'i386', @{$distrepo->{$ver}->{'archs'}} ) ||
299 grep $_ eq $cmp->{rpm}->arch, @{$distrepo->{$ver}->{'archs'}} ) {
300 $srpm = $cmp if ! $srpm && $cmp->{src};
301 my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
302 $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
303 $dest = $devel1 if verrel($cmp, $dest, \%counts);
304 if ( $cmp->{repo} ne $dest ) {
305 push @{$cmp->{repos}}, $dest;
306 if ( $repos->{$cmp->{repo}}->{orig} ) {
307 $orig{$cmp->{nvra}}++;
308 unless ( $repos->{$cmp->{repo}}->{base} ) {
309 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
310 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
311 }
312 } elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
313 $reposrc{$cmp->{repo}}->{srpm} = $cmp;
314 } else {
315 $cmp->{delete}++;
316 }
317 $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
318 $cmp->{repo} = $dest;
319 if ( ! $cmp->{src} && $repos->{$dest}->{prio} > $repos->{$track{repo}}->{prio} ) {
320 $track{repo} = $dest;
321 $track{svr} = $cmp->{svr};
322 }
323 }
324 if ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
325 $reposrc{$cmp->{repo}}->{srpm} = $cmp;
326 }
327 }
328 } else {
329 if ( $track{repo} eq $cmp->{repo} ) {
330 if ( verrel($cmp, $cmp->{repo}, \%counts) ) {
331 $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
332 } elsif ( $cmp->{src} ) {
333 $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
334 } else {
335 $track{svr} = $cmp->{svr};
336 }
337 } elsif ( ! $repos->{$cmp->{repo}}->{base} ) {
338 if ( $repos->{$cmp->{repo}}->{orig} ) {
339 $srpm = $cmp if ! $srpm && $cmp->{src};
340 my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
341 $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
342 $dest = $devel1 if verrel($cmp, $dest, \%counts);
343 unless ( $cmp->{src} && ! $reposrc{$dest} ) {
344 if ( $repos->{$dest}->{prio} >= $repos->{$track{repo}}->{prio} && ! verrel($cmp, $dest, \%counts) ) {
345 unless ( $repos->{$cmp->{repo}}->{base} ) {
346 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
347 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
348 }
349 push @{$cmp->{repos}}, $dest;
350 $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
351 $cmp->{repo} = $dest;
352 $reposrc{$cmp->{repo}}->{srpm} = $cmp if $cmp->{src};
353 $orig{$cmp->{nvra}}++;
354 }
355 }
356 } else {
357 $cmp->{delete}++;
358 }
359 }
360 }
361 unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) {
362 $pkgs{$cmp->{nvra}}++;
363 $latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}};
364 $reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{src} || $repos->{$cmp->{repo}}->{stage};
365 if ( $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc} ) {
366 $cmp->{latest}++ if ! $seen{$cmp->{nvra}} || $cmp->{src};
367 }
368 $seen{$cmp->{nvra}} = $cmp unless $seen{$cmp->{nvra}};
369 push @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{$cmp->{src} ? 'src' : $cmp->{rpm}->arch}}, $cmp unless $cmp->{done};
370 }
371 $cmp->{done}++;
372 }
373 if ( $srpm ) {
374 foreach my $r ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %reposrc ) {
375 unless ( $reposrc{$r}->{srpm} ) {
376 unshift @{$srpm->{repos}}, $r;
377 $srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo};
378 $srpm->{repo} = $r;
379 $reposrc{$r}->{srpm} = $srpm;
380 }
381 }
382 } elsif ( scalar keys %pkgs && $opts{s} ) {
383 print "\n * missing source ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n";
384 }
385 print "\n * missing originals ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs;
386 }
387
388 foreach my $r ( keys %$acnt ) {
389 foreach my $p ( keys %{$acnt->{$r}} ) {
390 foreach my $a ( keys %{$acnt->{$r}->{$p}} ) {
391 if ( $a eq 'noarch' ) {
392 my $p2 = ${$acnt->{$r}->{$p}->{$a}}[0];
393 if ( ! $p2->{repos} && scalar @{$acnt->{$r}->{$p}->{$a}} != scalar @{$distrepo->{$ver}->{'archs'}} ) {
394 $p2->{oldrepo} = $p2->{repo};
395 push @{$p2->{repos}}, $p2->{repo};
396 }
397 } elsif ( scalar @{$acnt->{$r}->{$p}->{$a}} != 1 ) {
398 print "\n * many packages ($r, $a, $p)\n" unless $p =~ m{^syslinux-nonlinux-[0-9]};
399 }
400 }
401 }
402 }
403
404 foreach my $pkg ( sort { $a->{nvra} cmp $b->{nvra} } @{$rpms->{$base}->{rpms}} ) {
405 if ( $pkg->{latest} && $pkg->{latest} == 1 ) {
406 unless ( grep { $_->{nvra} eq $pkg->{nvra} && $_->{repo} eq $stage } @{$rpms->{$base}->{rpms}} ) {
407 $pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo};
408 $pkg->{repo} = $stage;
409 push @{$pkg->{repos}}, $stage;
410 }
411 }
412
413 if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) {
414 print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
415 $print++;
416 }
417
418 my $src = $pkg->{rpm}->filename;
419 if ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) {
420 print "sign package (", basename($pkg->{rpm}->filename), ")\n";
421 unless ( $opts{t} ) {
422 qx(cat $HOME/.rpmpass | setsid rpm -D '_gpg_name $distrepo->{$ver}->{keyname}' --addsign $src >& /dev/null);
423 if ($?) {
424 print " * failed to sign package\n";
425 next;
426 }
427 }
428 }
429
430 if ( $pkg->{repos} ) {
431 foreach my $repo ( @{$pkg->{repos}} ) {
432 if ( $pkg->{delete} ) {
433 print "move from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
434 $pkg->{delete} = 0;
435 $repochg{$pkg->{oldrepo}}++ unless $repos->{$pkg->{oldrepo}}->{base} || $repos->{$pkg->{oldrepo}}->{stage};
436 } elsif ( $pkg->{oldrepo} eq $repo ) {
437 print "distribute noarch in $repo (", basename($pkg->{rpm}->filename), ")\n";
438 } else {
439 print "copy from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
440 }
441 $repochg{$repo}++ unless $repos->{$repo}->{base} || $repos->{$repo}->{stage};
442 $pkg->{oldrepo} = $repo unless $pkg->{oldrepo} eq ${$pkg->{repos}}[0];
443
444 my @d = ();
445 my $head = $distrepo->{$ver}->{repo} . $repo . '/';
446 $head = $distrepo->{$ver}->{stage} if $repos->{$repo}->{stage};
447 my $tail = $repos->{$repo}->{os} ? "$osdir/" : 'RPMS/';
448 if ( $pkg->{src} ) {
449 push @d, "${head}SRPMS/" . basename($pkg->{rpm}->filename);
450 } elsif ( $pkg->{rpm}->arch eq 'noarch' ) {
451 push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @{$distrepo->{$ver}->{'archs'}};
452 } elsif ( $pkg->{rpm}->arch =~ m{^(i[356]86)$} ) {
453 push @d, "${head}i386/$tail" . basename($pkg->{rpm}->filename);
454 } else {
455 push @d, $head . $pkg->{rpm}->arch . "/$tail" . basename($pkg->{rpm}->filename);
456 }
457 foreach my $dest ( @d ) {
458 qx(cp --preserve=timestamps $src $dest) unless $opts{t} || -f "$dest";
459 }
460
461 }
462 qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t};
463 } elsif ( $pkg->{delete} ) {
464 print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
465 qx(rm -f $src) unless $opts{t};
466 $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
467 if ( $repos->{$pkg->{repo}}->{orig} && ! $repos->{$pkg->{repo}}->{base} ) {
468 my $tag = dirname(dirname($pkg->{rpm}->{filename}));
469 qx(rm -f $tag/PUSHED) if ! $opts{t} && -d $tag && -f "$tag/PUSHED";
470 }
471 }
472 }
473
474 if ( $rpms->{$base}->{srpms} ) {
475 foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{srpms}} ) {
476 next if $pkg->{done} || $repos->{$pkg->{repo}}->{orig} || $repos->{$pkg->{repo}}->{base};
477 $pkg->{delete}++;
478 my $src = $pkg->{rpm}->filename;
479 if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) {
480 print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
481 $print++;
482 }
483 print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
484 qx(rm -f $src) unless $opts{t};
485 $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
486 }
487 }
488 }
489
490 if ( %repochg ) {
491 print "\nrebuild repo ($disttag$ver)\n", "=" x length("rebuild repo ($disttag$ver)"), "\n";
492 }
493 foreach my $repo ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %repochg ) {
494 next if $repos->{$repo}->{orig} || $repos->{$repo}->{stage};
495 foreach my $arch ( @{$distrepo->{$ver}->{'archs'}} ) {
496 my $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
497 $dir = qx(readlink -f $dir);
498 if ( $dir ) {
499 chomp $dir;
500 } else {
501 $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
502 }
503 print "rebuild $repo/$arch\n";
504 unless ( $opts{t} ) {
505 my $checksum = "--checksum $distrepo->{$ver}->{checksum}";
506
507 my $exclude = "";
508 $exclude .= " --exclude ${osdir}/*" if -d "$dir/Packages";
509 $exclude .= " --exclude *smeserver-release*.rpm" if $dir =~ m{test/|-testing/};
510
511 my $groupfile = "";
512 $groupfile = "--simple-md-filenames --groupfile repodata/comps.xml" if -f "$dir/repodata/comps.xml";
513
514 qx(createrepo --update --database --exclude *.src.rpm --exclude *-debuginfo-*.rpm $checksum $exclude $groupfile $dir);
515 qx(repoview $dir);
516
517 qx(rm -rf $dir/.olddata) if -d "$dir/.olddata";
518 qx(rm -rf $dir/.repodata) if -d "$dir/.repodata";
519 qx(rm -rf $dir/repodata/index.html) if -f "$dir/repodata/index.html";
520 qx(rm -rf $dir/repodata/update-info) if -d "$dir/repodata/update-info";
521 qx(rm -rf $dir/repodata/repoview) if -d "$dir/repodata/repoview";
522 }
523 }
524 }
525 unless ( $opts{t} ) {
526 foreach (@{$distrepo->{$ver}->{builds}})
527 {
528 finddepth(sub{rmdir}, "$_") if -d "$_";
529 }
530 finddepth(sub{rmdir}, $distrepo->{$ver}->{community}) if -d "$distrepo->{$ver}->{community}";
531 }
532 }
533
534 sub verrel {
535 my $pkg = shift;
536 my $repo = shift;
537 my $counts = shift;
538
539 return 0 if $pkg->{src};
540 $counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++;
541 return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver};
542 return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel};
543 return 0;
544 }
545
546 sub pkgdest {
547 my $pkg = shift;
548 my $dest = shift;
549 my $hirepo = shift;
550 my $pkgs = shift;
551
552 foreach my $cmp ( @$pkgs ) {
553 next if $cmp->{src} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio};
554 next if $pkg->{name} ne ( $pkg->{src} ? $cmp->{base} : $cmp->{name} );
555 if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) {
556 $dest = $hirepo;
557 last;
558 } else {
559 $dest = $cmp->{repo};
560 }
561 }
562 return $dest;
563 }
564
565 sub process_rpm {
566 my $rpm = shift;
567 my $ver = shift;
568 my $repo = shift;
569 return unless $rpm =~ m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$};
570 my $base = $1;
571 return unless ! $opts{r} || $base =~ m[$opts{r}];
572 return unless $latest{$base} || $sources{$base} || ! $repos->{$repo}->{base};
573
574 my $pkg;
575 eval { $pkg = RPM2->open_package($rpm, $rpm_flags); };
576 if ($@) { print " * corrupt package ($rpm)\n"; return; }
577 eval { my $sig = $pkg->siggpg };
578
579 my $nosig = 1;
580 eval { my $sig = $pkg->dsaheader }; $nosig &= ! $@;
581 eval { my $sig = $pkg->rsaheader }; $nosig &= ! $@;
582 eval { my $sig = $pkg->siggpg }; $nosig &= ! $@;
583 eval { my $sig = $pkg->sigpgp }; $nosig &= ! $@;
584
585 my $cmp = $latest{$pkg->name};
586 if ( $repos->{$repo}->{base} && ! $pkg->is_source_package ) {
587 return unless $cmp;
588 return if $repos->{$cmp->{repo}}->{base} && $repos->{$cmp->{repo}}->{prio} > $repos->{$repo}->{prio} && $pkg ge $cmp->{rpm};
589 }
590 my ($src, $version, $release) = ($pkg->is_source_package ? $pkg->filename : $pkg->sourcerpm) =~ m{(?:^|/)([^/]*)-([^-]+)-([^-]+)\.\w+\.rpm$};
591 return if $skippkg->{$ver}->{$repo} && ( $skippkg->{$ver}->{$repo}->{$src} || $skippkg->{$ver}->{$repo}->{$pkg->name} );
592 return if $repos->{$repo}->{base} && $nosig && $baserepo->{$ver}->{sign};
593 if ( $nosig && ! -f "$HOME/.rpmpass" ) { print " * missing signature (" .$pkg->filename . ")\n"; return; }
594 my $arch = 'unknown';
595 $arch = 'SRPMS' if $pkg->filename =~ m{[/-](SRPMS?|src|source)/};
596 $arch = 'x86_64' if $pkg->filename =~ m{[/-]x86_64/};
597 $arch = 'i386' if $pkg->filename =~ m{[/-](i[356]86)/};
598 $arch = 'noarch' if $pkg->filename =~ m{[/-]noarch/};
599
600 my $rpmhash = { base => $src,
601 name => $pkg->name,
602 repo => $repo,
603 nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ),
604 svr => $src.'-'.$version.'-'.$release,
605 src => $pkg->is_source_package,
606 arch => $arch,
607 ver => $version,
608 rel => $release,
609 rpm => $pkg,
610 nosig => $nosig,
611 };
612 if ( $pkg->is_source_package ) {
613 push @{$rpms->{$src}->{srpms}}, $rpmhash;
614 push @{$rpms->{$src}->{vers}->{$rpmhash->{svr}}}, $rpmhash;
615 } else {
616 push @{$rpms->{$src}->{rpms}}, $rpmhash;
617 }
618 $sources{$src}++;
619
620 return if $pkg->is_source_package || $repos->{$repo}->{stage};
621 if ( ! $repos->{$repo}->{base} ) {
622 if ( ! $cmp || $pkg gt $cmp->{rpm} ) {
623 $latest{$pkg->name} = $rpmhash;
624 }
625 } elsif ( ( $repos->{$repo}->{prio} >= $repos->{$cmp->{repo}}->{prio} || ! $repos->{$cmp->{repo}}->{base} ) && $pkg ge $cmp->{rpm} ) {
626 $latest{$pkg->name} = $rpmhash;
627 }
628 }

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