/[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.48 - (hide annotations) (download)
Mon Sep 8 18:04:13 2008 UTC (16 years, 2 months ago) by slords
Branch: MAIN
Changes since 1.47: +4 -3 lines
createrepo fixes

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

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