/[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.35 - (hide annotations) (download)
Sun Dec 23 22:24:41 2007 UTC (16 years, 10 months ago) by slords
Branch: MAIN
Changes since 1.34: +4 -3 lines
updates

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

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