/[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.54 - (hide annotations) (download)
Wed Feb 24 18:14:55 2010 UTC (14 years, 9 months ago) by slords
Branch: MAIN
Changes since 1.53: +0 -11 lines
Don't use obsolete fedora repos anymore

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

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