/[smeserver]/builds_bin/update_repos
ViewVC logotype

Annotation of /builds_bin/update_repos

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


Revision 1.53 - (hide annotations) (download)
Fri Feb 12 18:52:06 2010 UTC (14 years, 9 months ago) by slords
Branch: MAIN
Changes since 1.52: +22 -20 lines
Tools update

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

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