/[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.88 - (hide annotations) (download)
Tue Feb 14 21:38:34 2017 UTC (7 years, 9 months ago) by unnilennium
Branch: MAIN
Changes since 1.87: +39 -1 lines
added include only option, added remi repo

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.73 getopts( 'ostr:', \%opts );
18 slords 1.30 $opts{r} ||= '';
19 unnilennium 1.88 #available options
20     #-o = verify we have originals of the packages in repos (not really used anymore)
21     #-s = verify every package has a source package (so we can rebuild if necessary)
22     #-t = test run (don't do anything just print out what would be done)
23     #-r {regex} = regex of packages to run the script against
24 slords 1.20
25 slords 1.72 my $rpm_flags = RPM2->vsf_nodsaheader | RPM2->vsf_norsaheader | RPM2->vsf_nodsa | RPM2->vsf_norsa;
26 slords 1.20
27 slords 1.52 my $osdir = 'SME';
28     my $disttag = 'sme';
29     my $repotag = 'sme';
30    
31 slords 1.73 my $distrepo = { '8' => { active => 1,
32 slords 1.76 centos => 5,
33     archs => [ 'i386', 'x86_64' ],
34     repo => '/build/smeserver/repo/8/',
35     builds => ['/build/builds/smeserver-8-core/'],
36     community => '/build/builds/smeserver-8-contribs/',
37     stage => '/build/smeserver/stage/8/',
38     sign => 1,
39     keyname => 'SME Server 7 signing key <bugteam@contribs.org>',
40     checksum => 'sha',
41     },
42     '9' => { active => 1,
43     centos => 6,
44     archs => [ 'i386', 'x86_64' ],
45     repo => '/build/smeserver/repo/9/',
46     builds => ['/build/builds/smeserver-9-core/'],
47     community => '/build/builds/smeserver-9-contribs/',
48     stage => '/build/smeserver/stage/9/',
49     sign => 1,
50 slords 1.73 keyname => 'SME Server 7 signing key <bugteam@contribs.org>',
51 slords 1.76 checksum => 'sha256',
52     },
53 unnilennium 1.82 '10' => { active => 1,
54 slords 1.76 centos => 7,
55     archs => [ 'x86_64' ],
56     repo => '/build/smeserver/repo/testing/10/',
57     builds => ['/build/builds/smeserver-10-core/'],
58     community => '/build/builds/smeserver-10-contribs/',
59     stage => '/build/smeserver/stage/10/',
60     sign => 1,
61 unnilennium 1.82 keyname => 'Koozali SME Server signing key (10) <bugteam@koozali.org>',
62 slords 1.76 checksum => 'sha256',
63     },
64     };
65 slords 1.20
66 unnilennium 1.88 # list here repo and priority
67     # prio: highest priority will hide lowest priority
68     # inc: include for iso ?
69     # ver:
70     # rel:
71     # orig:
72     # base, os, stage:
73 slords 1.67 my $repos = { "${repotag}os" => { prio => 19, inc => 1, ver => 1, rel => 1, os => 1 },
74 slords 1.76 "${repotag}updates" => { prio => 18, inc => 1, ver => 1, rel => 1 },
75     "${repotag}updates-testing" => { prio => 17, inc => 1, ver => 1, rel => 3 },
76     "${repotag}extras" => { prio => 16, inc => 0, ver => 1, rel => 1 },
77     "${repotag}addons" => { prio => 15, inc => 0, ver => 1, rel => 1 },
78     "${repotag}contribs" => { prio => 14, inc => 0, ver => 1, rel => 1 },
79     "${repotag}test" => { prio => 13, inc => 0, ver => 2, rel => 3, devel => 2 },
80     "${repotag}dev" => { prio => 12, inc => 0, ver => 1, rel => 1, devel => 1 },
81     'centos' => { prio => 10, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
82 unnilennium 1.88 'remi' => { prio => 9, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
83     'remisafe' => { prio => 9, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
84     'epel' => { prio => 8, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
85 slords 1.76 'rpmforge' => { prio => 7, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
86     'atrpms' => { prio => 6, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
87     'builds' => { prio => 4, inc => 0, ver => 0, rel => 0, orig => 1 },
88     'community' => { prio => 2, inc => 0, ver => 0, rel => 0, orig => 1 },
89     'stage' => { prio => 1, inc => 0, ver => 0, rel => 0, stage => 1, os => 1 },
90     };
91 slords 1.30
92 unnilennium 1.88 # list here the path on our local mirror to each upstream and our mirrors
93     # ~A will be expanded to architecture
94     # ~C will be expanded to Centos main version number, i.e. 7 for SME 10.
95 slords 1.71 my $baserepo = { "~S${repotag}os/~A/" => "${repotag}os",
96 slords 1.76 "~S${repotag}updates/~A/" => "${repotag}updates",
97     "~S${repotag}updates-testing/~A/" => "${repotag}updates-testing",
98     "~S${repotag}extras/~A/" => "${repotag}extras",
99     "~S${repotag}addons/~A/" => "${repotag}addons",
100     "~S${repotag}contribs/~A/" => "${repotag}contribs",
101     "~S${repotag}test/~A/" => "${repotag}test",
102     "~S${repotag}dev/~A/" => "${repotag}dev",
103     "/build/smeserver/stage/~s/~A/" => 'stage',
104     '/mirrors/centos/~C/fasttrack/~A/' => 'centos',
105     '/mirrors/centos/~C/updates/~A/' => 'centos',
106     '/mirrors/centos/~C/os/~A/' => 'centos',
107     '/mirrors/centos/~C/extras/~A/' => 'centos',
108     '/mirrors/centos-vault/~C/fasttrack/~A/' => 'centos',
109     '/mirrors/centos-vault/~C/updates/~A/' => 'centos',
110     '/mirrors/centos-vault/~C/os/~A/' => 'centos',
111     '/mirrors/centos-vault/~C/extras/~A/' => 'centos',
112     '/mirrors/fedora/epel/~C/~A/' => 'epel',
113     '/mirrors/fedora/epel/testing/~C/~A/' => 'epel',
114 unnilennium 1.88 '/mirrors/remi/enterprise/~C/remi/~A/' => 'remi',
115     '/mirrors/remi/SRPMS/' => 'remi',
116     '/mirrors/remi/enterprise/~C/safe/~A/' => 'remisafe',
117     '/mirrors/remi/SRPMS/' => 'remisafe',
118 slords 1.76 '/mirrors/rpmforge/redhat/el~C/en/~A/dag/' => 'rpmforge',
119     '/mirrors/rpmforge/redhat/el~C/en/~A/extras/' => 'rpmforge',
120     '/mirrors/rpmforge/source/' => 'rpmforge',
121     '/mirrors/atrpms/el~C-~A/atrpms/stable/' => 'atrpms',
122     '/mirrors/atrpms/el~C-~A/atrpms/testing/' => 'atrpms',
123     '/mirrors/atrpms/src/el~C-~A/atrpms/stable/' => 'atrpms',
124     '/mirrors/atrpms/src/el~C-~A/atrpms/testing/' => 'atrpms',
125     };
126    
127 unnilennium 1.88 # add here packages to exclude
128     # for each version, if a repo is listed and rpm are listed they will be ignored fromt his repo
129 slords 1.76 my $skippkg = { '8' => { 'atrpms' => { map { $_ => 1 } ( 'clamav', 'gnupg' ) },
130     'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3' ) },
131 unnilennium 1.87 'epel' => { map { $_ => 1 } ( 'clamav', 'cppunit', 'fping', 'html2ps', 'horde', 'libtalloc', 'libtdb', 'oidentd', 'perl-Compress-Bzip2', 'perl-Compress-Raw-Zlib', 'perl-Compress-Raw-Bzip2', 'perl-Crypt-OpenSSL-Bignum', 'perl-Crypt-OpenSSL-Random', 'perl-Crypt-OpenSSL-RSA', 'perl-Razor-Agent', 'smolt' ) },
132 unnilennium 1.86 'rpmforge' => { map { $_ => 1 } ( 'dovecot', 'libtalloc', 'mod_auth_tkt', 'perl-Test-Inline', 'spamassassin', 'lzo', 'perl-Convert-TNEF', 'perl-Mail-SPF', 'proftpd', 'erlang', 'perl-DateTime-Format-Mail', 'perl-DateTime-Format-W3CDTF', 'perl-Email-Abstract', 'perl-Email-MIME-Attachment-Stripper', 'perl-Email-Reply', 'perl-Font-AFM', 'perl-IPC-Run', 'rkhunter') },
133 slords 1.76 },
134     '9' => { 'atrpms' => { map { $_ => 1 } ( 'clamav', 'perl-Pod-Escapes', 'perl-Pod-Simple' ) },
135     'epel' => { map { $_ => 1 } ( 'oidentd', 'perl-Razor-Agent' ) },
136 unnilennium 1.84 'rpmforge' => { map { $_ => 1 } ( 'perl-CGI', 'perl-Compress-Raw-Zlib', 'perl-ExtUtils-ParseXS', 'perl-Pod-Escapes', 'perl-Pod-Simple', 'perl-Time-HiRes', 'perl-version', 'spamassassin', 'portreserve', 'perl-libwww-perl' , 'lzo', 'perl-BSD-Resource', 'perl-Convert-ASN1', 'perl-Devel-StackTrace', 'perl-Digest-SHA1', 'perl-MIME-tools', 'perl-MailTools', 'perl-PPI', 'perl-URI', 'perl-XML-NamespaceSupport', 'perl-XML-Parser', 'perl-XML-SAX-Writer', 'perl-YAML-Syck', 'proftpd', 'syslinux') },
137 slords 1.76 },
138     '10' => {
139     },
140     };
141 slords 1.20
142 unnilennium 1.88 # add here include only conditions
143     # for each version if a repo is listed here, only listed rpm will be considered
144     my $onlypkg = { '8' => {
145     'remi' => { },
146     'remisafe' => { },
147     },
148     '9' => {
149     'remi' => { },
150     },
151     '10' => {
152     'remi' => { map { $_ => 1 } ( 'php-pear' )},
153     },
154     };
155    
156 slords 1.30 my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos;
157 slords 1.20 my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos;
158     $devel2 ||= $devel1;
159    
160 slords 1.30 my ($rpms, %base, %latest, %sources);
161 slords 1.52 foreach my $ver ( sort { $a <=> $b } keys %$distrepo ) {
162     next unless $distrepo->{$ver}->{active};
163 slords 1.30 my %repochg = ();
164     $rpms = ();
165 slords 1.21 %latest = ();
166 slords 1.20 %sources = ();
167 slords 1.30 %base = ();
168 slords 1.20
169 unnilennium 1.79 @{$distrepo->{$ver}->{all_archs}} = ('noarch', @{$distrepo->{$ver}->{'archs'}});
170     if ( grep $_ eq 'i386', @{$distrepo->{$ver}->{'archs'}} ) {
171 slords 1.78 push @{$distrepo->{$ver}->{all_archs}}, ('i586', 'i686');
172     }
173    
174 slords 1.30 foreach my $dir ( sort { $repos->{$baserepo->{$b}}->{prio} <=> $repos->{$baserepo->{$a}}->{prio} || $a cmp $b } keys %$baserepo ) {
175 slords 1.76 my $bdir = $dir;
176     $bdir =~ s/~S/$distrepo->{$ver}->{repo}/;
177     $bdir =~ s/~s/$ver/;
178     $bdir =~ s/~C/$distrepo->{$ver}->{centos}/;
179 unnilennium 1.79 for my $arch ( @{$distrepo->{$ver}->{'archs'}}, 'SRPMS/' ) {
180 slords 1.76 my $adir = $bdir;
181     if ( $arch eq 'SRPMS/' ) {
182     $adir =~ s/~A.*//;
183     if ( -d "${adir}SRPMS" ) {
184     $adir .= "SRPMS/";
185     } elsif ( -d "${adir}Source/SPackages" ) {
186     $adir .= "Source/SPackages/";
187     }
188     } else {
189     $adir =~ s/~A/$arch/;
190     if ( -d "${adir}RPMS" ) {
191     $adir .= "RPMS/";
192     } elsif ( -d "${adir}Packages" ) {
193     $adir .= "Packages/";
194     } elsif ( -d "${adir}CentOS" ) {
195     $adir .= "CentOS/";
196     } elsif ( -d "${adir}$osdir" ) {
197     $adir .= "$osdir/";
198     }
199     }
200     next unless -d $adir;
201     opendir DIR, $adir or next;
202 unnilennium 1.81 my @txt = grep { /\.rpm$/ && -f "$adir/$_" } readdir DIR;
203 slords 1.76 closedir DIR;
204 unnilennium 1.81 if (scalar(@txt)) {
205     opendir DIR, $adir or next;
206     process_rpm("$adir$_", $ver, $baserepo->{$dir}) foreach readdir DIR;
207     closedir DIR;
208     } elsif ($baserepo->{$dir} eq 'epel') {
209     # EPEL 7 uses a structure with subfolders of first letter of package
210     find( { wanted => sub { process_rpm($_, $ver, $baserepo->{$dir}) if ($_ =~ m/\.rpm$/);}, no_chdir => 1, follow_fast => 1 }, $adir );
211     }
212 slords 1.76 last unless $dir =~ m{~A};
213     }
214 slords 1.20 }
215 unnilennium 1.79 find( { wanted => sub { process_rpm($_, $ver, 'builds'); }, no_chdir => 1, follow_fast => 1 }, "$_" ) foreach @{$distrepo->{$ver}->{'builds'}};
216     find( { wanted => sub { process_rpm($_, $ver, 'community'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$ver}->{'community'} ) if $distrepo->{$ver}->{'community'};
217 slords 1.20
218 slords 1.30 foreach my $base ( sort keys %$rpms ) {
219 slords 1.76 next unless $rpms->{$base}->{rpms};
220     my %track = ();
221     my %seen = ();
222     my %counts = ();
223     my $acnt = ();
224     my $print = 0;
225     %latest = ();
226    
227     foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) {
228     next if $pkg->{done};
229    
230     my $tmp = $pkg->{svr};
231     # srpm transformations to match up binary and source rpms
232     SRC: {
233     # Try to find the name the binary wants (no changes)
234     $rpms->{$base}->{vers}->{$tmp} && last SRC;
235    
236     # rpmforge (.el4.rf to .rf, with rf,rfb,rft,rfx endings)
237     ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf[btx]?)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
238     # rpmforge (.el4.rfx to .rf, rfb,rft,rfx switched to rf)
239     ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)[btx]$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
240     # rpmforge (.el4.rf to .rfx, rf,rfb,rft,rfx switched to rfx)
241     ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)[btx]?$}{$1x} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
242     # rpmforge (.el4.rf to .el5) TODO: remove when no longer needed
243     ($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.el5} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
244     # rpmforge (.2.el4.rf to .rf, minor modification not pushed to source?) TODO: remove when no longer needed
245     ($tmp = $pkg->{svr}) =~ s{\.2\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
246    
247     # atrpms (remove .at)
248     ($tmp = $pkg->{svr}) =~ s{\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
249     # atrpms (remove .el4.at)
250     ($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
251     # atrpms (remove .el4)
252     ($tmp = $pkg->{svr}) =~ s{\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
253     # atrpms (remove .0.el5, minor modification not pushed to source?) TODO: remove when no longer needed
254     ($tmp = $pkg->{svr}) =~ s{\.0\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
255    
256     # Transformations that we hopefully won't have to use anymore TODO: remove if no issues
257     #($tmp = $pkg->{svr}) =~ s{(\.el\d)\.rf$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
258     #($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
259     #($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
260     #($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d\.rf$}{$1.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
261     #($tmp = $pkg->{svr}) =~ s{\.el\d_}{_} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
262     #($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
263     #($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
264     #($tmp = $pkg->{svr}) =~ s{\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
265     #($tmp = $pkg->{svr}) =~ s{\.el\d\.$disttag$}{ && $rpms->{$base}->{vers}->{$tmp} && last SRC;
266     }
267     if ( $rpms->{$base}->{vers}->{$tmp} ) {
268     foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) {
269     $tmp->{svr} = $pkg->{svr};
270     push @{$rpms->{$base}->{rpms}}, $tmp unless $tmp->{added};
271     $tmp->{added}++;
272     }
273     }
274    
275     my %orig = ();
276     my %pkgs = ();
277     my %reposrc = ();
278     my $srpm = undef;
279     foreach my $cmp ( sort { $a->{src} <=> $b->{src} || $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} } @{$rpms->{$base}->{rpms}} ) {
280     next unless $cmp->{svr} eq $pkg->{svr};
281    
282     if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) {
283     if ( $cmp->{src} ) {
284     if ( ! $track{repo} ) {
285     $cmp->{delete}++;
286     $cmp->{done}++;
287     next;
288     }
289     } else {
290     $track{repo} = $cmp->{repo};
291     $track{svr} = $cmp->{svr};
292     }
293     }
294     if ( $cmp->{svr} eq $track{svr} ) {
295     if ( $seen{$cmp->{nvra}} ) {
296     if ( $track{repo} ne $cmp->{repo} ) {
297     if ($repos->{$cmp->{repo}}->{stage} ) {
298     if ( $seen{$cmp->{nvra}}->{latest} ) {
299     $seen{$cmp->{nvra}}->{latest}++;
300     delete $cmp->{delete} if $cmp->{delete};
301     } else {
302     $cmp->{delete}++;
303     }
304     } elsif ( $repos->{$cmp->{repo}}->{orig} ) {
305     $orig{$cmp->{nvra}}++;
306     unless ( $repos->{$cmp->{repo}}->{base} ) {
307 slords 1.73 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
308 slords 1.76 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
309     }
310     } elsif ( $cmp->{src} ) {
311     if ( $cmp->{delete} && $cmp->{oldrepo} && $reposrc{$cmp->{oldrepo}}) {
312     $cmp->{repo} = $cmp->{oldrepo};
313     delete $cmp->{delete};
314     }
315     if ( $reposrc{$cmp->{repo}} ) {
316     $reposrc{$cmp->{repo}}->{srpm} = $cmp;
317     $srpm = $cmp if ! $srpm;
318     } elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} && ! $cmp->{done} ) {
319     $cmp->{delete}++;
320     }
321     } elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) {
322     $cmp->{delete}++;
323     }
324     } elsif ( $cmp->{src} ) {
325     if ( $reposrc{$cmp->{repo}} && $reposrc{$cmp->{repo}}->{srpm} && $reposrc{$cmp->{repo}}->{srpm}->{oldrepo} ne $cmp->{repo} ) {
326     $acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{src} = [
327     grep { $_ ne $reposrc{$cmp->{repo}}->{srpm} } @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{src}}
328     ];
329    
330     if ( @{$reposrc{$cmp->{repo}}->{srpm}->{repos}} == 1 ) {
331     $reposrc{$cmp->{repo}}->{srpm}->{repo} = $reposrc{$cmp->{repo}}->{srpm}->{oldrepo};
332     delete $reposrc{$cmp->{repo}}->{srpm}->{oldrepo};
333     delete $reposrc{$cmp->{repo}}->{srpm}->{delete};
334     delete $reposrc{$cmp->{repo}}->{srpm}->{repos};
335     delete $reposrc{$cmp->{repo}}->{srpm}->{done};
336     $seen{$cmp->{nvra}} = $cmp if $seen{$cmp->{nvra}} eq $reposrc{$cmp->{repo}}->{srpm};
337     } else {
338     warn "How did I get here??";
339     }
340     } else {
341     $seen{$cmp->{nvra}} = $cmp if $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo};
342     }
343     $srpm = $cmp if ! $srpm && $cmp->{src};
344     $reposrc{$cmp->{repo}}->{srpm} = $cmp if $reposrc{$cmp->{repo}};
345     }
346     } elsif ( $repos->{$cmp->{repo}}->{stage} ) {
347     $cmp->{delete}++;
348 slords 1.78 } elsif ( $cmp->{src} || grep $_ eq $cmp->{rpm}->arch, @{$distrepo->{$ver}->{all_archs}} ) {
349 slords 1.76 $srpm = $cmp if ! $srpm && $cmp->{src};
350     my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
351     $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
352     $dest = $devel1 if verrel($cmp, $dest, \%counts);
353     if ( $cmp->{repo} ne $dest ) {
354     push @{$cmp->{repos}}, $dest;
355     if ( $repos->{$cmp->{repo}}->{orig} ) {
356     $orig{$cmp->{nvra}}++;
357     unless ( $repos->{$cmp->{repo}}->{base} ) {
358 slords 1.73 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
359 slords 1.76 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
360     }
361     } elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
362     $reposrc{$cmp->{repo}}->{srpm} = $cmp;
363     } else {
364     $cmp->{delete}++;
365     }
366     $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
367     $cmp->{repo} = $dest;
368     if ( ! $cmp->{src} && $repos->{$dest}->{prio} > $repos->{$track{repo}}->{prio} ) {
369     $track{repo} = $dest;
370     $track{svr} = $cmp->{svr};
371     }
372     }
373     if ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
374     $reposrc{$cmp->{repo}}->{srpm} = $cmp;
375     }
376     }
377     } else {
378     if ( $track{repo} eq $cmp->{repo} ) {
379     if ( verrel($cmp, $cmp->{repo}, \%counts) ) {
380     $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
381     } elsif ( $cmp->{src} ) {
382     $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
383     } else {
384     $track{svr} = $cmp->{svr};
385     }
386     } elsif ( ! $repos->{$cmp->{repo}}->{base} ) {
387     if ( $repos->{$cmp->{repo}}->{orig} ) {
388     $srpm = $cmp if ! $srpm && $cmp->{src};
389     my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
390     $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
391     $dest = $devel1 if verrel($cmp, $dest, \%counts);
392     unless ( $cmp->{src} && ! $reposrc{$dest} ) {
393     if ( $repos->{$dest}->{prio} >= $repos->{$track{repo}}->{prio} && ! verrel($cmp, $dest, \%counts) ) {
394     unless ( $repos->{$cmp->{repo}}->{base} ) {
395 slords 1.73 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
396 slords 1.76 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
397     }
398     push @{$cmp->{repos}}, $dest;
399     $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
400     $cmp->{repo} = $dest;
401     $reposrc{$cmp->{repo}}->{srpm} = $cmp if $cmp->{src};
402     $orig{$cmp->{nvra}}++;
403     }
404     }
405     } else {
406     $cmp->{delete}++;
407     }
408     }
409     }
410     unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) {
411     $pkgs{$cmp->{nvra}}++;
412     $latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}};
413     $reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{src} || $repos->{$cmp->{repo}}->{stage};
414     if ( $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc} ) {
415     $cmp->{latest}++ if ! $seen{$cmp->{nvra}} || $cmp->{src};
416     }
417     $seen{$cmp->{nvra}} = $cmp unless $seen{$cmp->{nvra}};
418     push @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{$cmp->{src} ? 'src' : $cmp->{rpm}->arch}}, $cmp unless $cmp->{done};
419     }
420     $cmp->{done}++;
421     }
422     if ( $srpm ) {
423     foreach my $r ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %reposrc ) {
424     unless ( $reposrc{$r}->{srpm} ) {
425     unshift @{$srpm->{repos}}, $r;
426     $srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo};
427     $srpm->{repo} = $r;
428     $reposrc{$r}->{srpm} = $srpm;
429     }
430     }
431     } elsif ( scalar keys %pkgs && $opts{s} ) {
432     print "\n * missing source ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n";
433     }
434     print "\n * missing originals ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs;
435     }
436    
437     foreach my $r ( keys %$acnt ) {
438     foreach my $p ( keys %{$acnt->{$r}} ) {
439     foreach my $a ( keys %{$acnt->{$r}->{$p}} ) {
440     if ( $a eq 'noarch' ) {
441     my $p2 = ${$acnt->{$r}->{$p}->{$a}}[0];
442 unnilennium 1.79 if ( ! $p2->{repos} && scalar @{$acnt->{$r}->{$p}->{$a}} != scalar @{$distrepo->{$ver}->{'archs'}} ) {
443 slords 1.76 $p2->{oldrepo} = $p2->{repo};
444     push @{$p2->{repos}}, $p2->{repo};
445     }
446     } elsif ( scalar @{$acnt->{$r}->{$p}->{$a}} != 1 ) {
447     print "\n * many packages ($r, $a, $p)\n" unless $p =~ m{^syslinux-nonlinux-[0-9]};
448     }
449     }
450     }
451     }
452    
453     foreach my $pkg ( sort { $a->{nvra} cmp $b->{nvra} } @{$rpms->{$base}->{rpms}} ) {
454     if ( $pkg->{latest} && $pkg->{latest} == 1 ) {
455     unless ( grep { $_->{nvra} eq $pkg->{nvra} && $_->{repo} eq $stage } @{$rpms->{$base}->{rpms}} ) {
456     $pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo};
457     $pkg->{repo} = $stage;
458     push @{$pkg->{repos}}, $stage;
459     }
460     }
461 slords 1.20
462 slords 1.73 if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) {
463     print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
464     $print++;
465     }
466    
467     my $src = $pkg->{rpm}->filename;
468     if ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) {
469     print "sign package (", basename($pkg->{rpm}->filename), ")\n";
470     unless ( $opts{t} ) {
471     qx(cat $HOME/.rpmpass | setsid rpm -D '_gpg_name $distrepo->{$ver}->{keyname}' --addsign $src >& /dev/null);
472     if ($?) {
473     print " * failed to sign package\n";
474     next;
475     }
476     }
477     }
478 slords 1.20
479 slords 1.76 if ( $pkg->{repos} ) {
480     foreach my $repo ( @{$pkg->{repos}} ) {
481     if ( $pkg->{delete} ) {
482     print "move from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
483     $pkg->{delete} = 0;
484     $repochg{$pkg->{oldrepo}}++ unless $repos->{$pkg->{oldrepo}}->{base} || $repos->{$pkg->{oldrepo}}->{stage};
485     } elsif ( $pkg->{oldrepo} eq $repo ) {
486     print "distribute noarch in $repo (", basename($pkg->{rpm}->filename), ")\n";
487     } else {
488     print "copy from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
489     }
490     $repochg{$repo}++ unless $repos->{$repo}->{base} || $repos->{$repo}->{stage};
491     $pkg->{oldrepo} = $repo unless $pkg->{oldrepo} eq ${$pkg->{repos}}[0];
492    
493     my @d = ();
494     my $head = $distrepo->{$ver}->{repo} . $repo . '/';
495     $head = $distrepo->{$ver}->{stage} if $repos->{$repo}->{stage};
496     my $tail = $repos->{$repo}->{os} ? "$osdir/" : 'RPMS/';
497     if ( $pkg->{src} ) {
498     push @d, "${head}SRPMS/" . basename($pkg->{rpm}->filename);
499     } elsif ( $pkg->{rpm}->arch eq 'noarch' ) {
500 unnilennium 1.79 push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @{$distrepo->{$ver}->{'archs'}};
501 unnilennium 1.80 } elsif ($ver>=10 && $pkg->{rpm}->arch =~ m{^(i[356]86)$} && $pkg->{arch} =~ m{^(x86_64)$} ) {
502     #add copy of i686 packages in x86_64 folder for SME>=10
503     push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @{$distrepo->{$ver}->{'archs'}};
504 slords 1.76 } elsif ( $pkg->{rpm}->arch =~ m{^(i[356]86)$} ) {
505     push @d, "${head}i386/$tail" . basename($pkg->{rpm}->filename);
506     } else {
507     push @d, $head . $pkg->{rpm}->arch . "/$tail" . basename($pkg->{rpm}->filename);
508     }
509     foreach my $dest ( @d ) {
510     qx(cp --preserve=timestamps $src $dest) unless $opts{t} || -f "$dest";
511     }
512    
513     }
514     qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t};
515     } elsif ( $pkg->{delete} ) {
516     print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
517     qx(rm -f $src) unless $opts{t};
518     $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
519     if ( $repos->{$pkg->{repo}}->{orig} && ! $repos->{$pkg->{repo}}->{base} ) {
520 slords 1.73 my $tag = dirname(dirname($pkg->{rpm}->{filename}));
521 slords 1.76 qx(rm -f $tag/PUSHED) if ! $opts{t} && -d $tag && -f "$tag/PUSHED";
522     }
523     }
524     }
525    
526     if ( $rpms->{$base}->{srpms} ) {
527     foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{srpms}} ) {
528     next if $pkg->{done} || $repos->{$pkg->{repo}}->{orig} || $repos->{$pkg->{repo}}->{base};
529     $pkg->{delete}++;
530     my $src = $pkg->{rpm}->filename;
531     if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) {
532     print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
533     $print++;
534     }
535     print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
536     qx(rm -f $src) unless $opts{t};
537     $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
538     }
539     }
540 slords 1.30 }
541    
542     if ( %repochg ) {
543 slords 1.76 print "\nrebuild repo ($disttag$ver)\n", "=" x length("rebuild repo ($disttag$ver)"), "\n";
544 slords 1.30 }
545     foreach my $repo ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %repochg ) {
546 slords 1.76 next if $repos->{$repo}->{orig} || $repos->{$repo}->{stage};
547 unnilennium 1.79 foreach my $arch ( @{$distrepo->{$ver}->{'archs'}} ) {
548 slords 1.76 my $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
549     $dir = qx(readlink -f $dir);
550     if ( $dir ) {
551     chomp $dir;
552     } else {
553     $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
554     }
555     print "rebuild $repo/$arch\n";
556     unless ( $opts{t} ) {
557 slords 1.66 my $checksum = "--checksum $distrepo->{$ver}->{checksum}";
558    
559     my $exclude = "";
560 slords 1.71 $exclude .= " --exclude ${osdir}/*" if -d "$dir/Packages";
561 slords 1.72 $exclude .= " --exclude *smeserver-release*.rpm" if $dir =~ m{test/|-testing/};
562 slords 1.66
563     my $groupfile = "";
564 slords 1.72 $groupfile = "--simple-md-filenames --groupfile repodata/comps.xml" if -f "$dir/repodata/comps.xml";
565 slords 1.66
566     qx(createrepo --update --database --exclude *.src.rpm --exclude *-debuginfo-*.rpm $checksum $exclude $groupfile $dir);
567 slords 1.76 qx(repoview $dir);
568 slords 1.66
569 slords 1.76 qx(rm -rf $dir/.olddata) if -d "$dir/.olddata";
570     qx(rm -rf $dir/.repodata) if -d "$dir/.repodata";
571     qx(rm -rf $dir/repodata/index.html) if -f "$dir/repodata/index.html";
572     qx(rm -rf $dir/repodata/update-info) if -d "$dir/repodata/update-info";
573     qx(rm -rf $dir/repodata/repoview) if -d "$dir/repodata/repoview";
574     }
575     }
576 slords 1.20 }
577 slords 1.30 unless ( $opts{t} ) {
578 unnilennium 1.79 foreach (@{$distrepo->{$ver}->{'builds'}})
579 slords 1.71 {
580     finddepth(sub{rmdir}, "$_") if -d "$_";
581     }
582 unnilennium 1.79 finddepth(sub{rmdir}, $distrepo->{$ver}->{'community'}) if -d "$distrepo->{$ver}->{'community'}";
583 slords 1.30 }
584 slords 1.1 }
585    
586 slords 1.30 sub verrel {
587     my $pkg = shift;
588     my $repo = shift;
589     my $counts = shift;
590 slords 1.20
591 slords 1.31 return 0 if $pkg->{src};
592 slords 1.30 $counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++;
593     return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver};
594     return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel};
595     return 0;
596 slords 1.20 }
597    
598 slords 1.30 sub pkgdest {
599 slords 1.20 my $pkg = shift;
600 slords 1.30 my $dest = shift;
601     my $hirepo = shift;
602     my $pkgs = shift;
603    
604     foreach my $cmp ( @$pkgs ) {
605 slords 1.76 next if $cmp->{src} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio};
606     next if $pkg->{name} ne ( $pkg->{src} ? $cmp->{base} : $cmp->{name} );
607     if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) {
608     $dest = $hirepo;
609     last;
610     } else {
611     $dest = $cmp->{repo};
612     }
613 slords 1.20 }
614 slords 1.30 return $dest;
615 slords 1.20 }
616    
617 slords 1.30 sub process_rpm {
618     my $rpm = shift;
619 slords 1.52 my $ver = shift;
620 slords 1.30 my $repo = shift;
621     return unless $rpm =~ m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$};
622     my $base = $1;
623     return unless ! $opts{r} || $base =~ m[$opts{r}];
624     return unless $latest{$base} || $sources{$base} || ! $repos->{$repo}->{base};
625 slords 1.20
626     my $pkg;
627 slords 1.30 eval { $pkg = RPM2->open_package($rpm, $rpm_flags); };
628     if ($@) { print " * corrupt package ($rpm)\n"; return; }
629 slords 1.20 eval { my $sig = $pkg->siggpg };
630 slords 1.72
631     my $nosig = 1;
632     eval { my $sig = $pkg->dsaheader }; $nosig &= ! $@;
633     eval { my $sig = $pkg->rsaheader }; $nosig &= ! $@;
634     eval { my $sig = $pkg->siggpg }; $nosig &= ! $@;
635     eval { my $sig = $pkg->sigpgp }; $nosig &= ! $@;
636    
637 slords 1.30 my $cmp = $latest{$pkg->name};
638     if ( $repos->{$repo}->{base} && ! $pkg->is_source_package ) {
639 slords 1.76 return unless $cmp;
640     return if $repos->{$cmp->{repo}}->{base} && $repos->{$cmp->{repo}}->{prio} > $repos->{$repo}->{prio} && $pkg ge $cmp->{rpm};
641 slords 1.30 }
642     my ($src, $version, $release) = ($pkg->is_source_package ? $pkg->filename : $pkg->sourcerpm) =~ m{(?:^|/)([^/]*)-([^-]+)-([^-]+)\.\w+\.rpm$};
643 slords 1.52 return if $skippkg->{$ver}->{$repo} && ( $skippkg->{$ver}->{$repo}->{$src} || $skippkg->{$ver}->{$repo}->{$pkg->name} );
644 unnilennium 1.88 return if $onlypkg->{$ver}->{$repo} && !( $onlypkg->{$ver}->{$repo}->{$src} || $onlypkg->{$ver}->{$repo}->{$pkg->name} );
645 slords 1.71 return if $repos->{$repo}->{base} && $nosig && $baserepo->{$ver}->{sign};
646 slords 1.30 if ( $nosig && ! -f "$HOME/.rpmpass" ) { print " * missing signature (" .$pkg->filename . ")\n"; return; }
647 slords 1.34 my $arch = 'unknown';
648     $arch = 'SRPMS' if $pkg->filename =~ m{[/-](SRPMS?|src|source)/};
649     $arch = 'x86_64' if $pkg->filename =~ m{[/-]x86_64/};
650     $arch = 'i386' if $pkg->filename =~ m{[/-](i[356]86)/};
651     $arch = 'noarch' if $pkg->filename =~ m{[/-]noarch/};
652 slords 1.30
653     my $rpmhash = { base => $src,
654 slords 1.76 name => $pkg->name,
655     repo => $repo,
656     nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ),
657     svr => $src.'-'.$version.'-'.$release,
658     src => $pkg->is_source_package,
659     arch => $arch,
660     ver => $version,
661     rel => $release,
662     rpm => $pkg,
663     nosig => $nosig,
664     };
665 slords 1.30 if ( $pkg->is_source_package ) {
666 slords 1.76 push @{$rpms->{$src}->{srpms}}, $rpmhash;
667     push @{$rpms->{$src}->{vers}->{$rpmhash->{svr}}}, $rpmhash;
668 slords 1.30 } else {
669 slords 1.76 push @{$rpms->{$src}->{rpms}}, $rpmhash;
670 slords 1.26 }
671 slords 1.30 $sources{$src}++;
672 slords 1.20
673 slords 1.30 return if $pkg->is_source_package || $repos->{$repo}->{stage};
674     if ( ! $repos->{$repo}->{base} ) {
675 slords 1.76 if ( ! $cmp || $pkg gt $cmp->{rpm} ) {
676     $latest{$pkg->name} = $rpmhash;
677     }
678 slords 1.30 } elsif ( ( $repos->{$repo}->{prio} >= $repos->{$cmp->{repo}}->{prio} || ! $repos->{$cmp->{repo}}->{base} ) && $pkg ge $cmp->{rpm} ) {
679 slords 1.76 $latest{$pkg->name} = $rpmhash;
680 slords 1.20 }
681 slords 1.1 }

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