/[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.89 - (hide annotations) (download)
Sat Apr 8 20:27:18 2017 UTC (7 years, 7 months ago) by unnilennium
Branch: MAIN
Changes since 1.88: +8 -6 lines
exclude atrpms SME9 libvorbis,libogg and epel SME10 clamav

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 unnilennium 1.89 my $distrepo = { '8' => { active => 0,
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 unnilennium 1.89 'centos' => { prio => 11, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
82     'remi' => { prio => 10, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 },
83 unnilennium 1.88 '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 unnilennium 1.89 # '/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 unnilennium 1.89 '9' => { 'atrpms' => { map { $_ => 1 } ( 'clamav', 'perl-Pod-Escapes', 'perl-Pod-Simple','libvorbis' , 'libogg' ) },
135 slords 1.76 '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 unnilennium 1.89 '10' => {
139     'centos' => { map { $_ => 1 } ( 'samba' ) },
140     'epel' => { map { $_ => 1 } ( 'clamav') },
141 slords 1.76 },
142     };
143 slords 1.20
144 unnilennium 1.88 # add here include only conditions
145     # for each version if a repo is listed here, only listed rpm will be considered
146     my $onlypkg = { '8' => {
147     'remi' => { },
148     'remisafe' => { },
149     },
150     '9' => {
151     'remi' => { },
152     },
153     '10' => {
154     'remi' => { map { $_ => 1 } ( 'php-pear' )},
155     },
156     };
157    
158 slords 1.30 my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos;
159 slords 1.20 my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos;
160     $devel2 ||= $devel1;
161    
162 slords 1.30 my ($rpms, %base, %latest, %sources);
163 slords 1.52 foreach my $ver ( sort { $a <=> $b } keys %$distrepo ) {
164     next unless $distrepo->{$ver}->{active};
165 slords 1.30 my %repochg = ();
166     $rpms = ();
167 slords 1.21 %latest = ();
168 slords 1.20 %sources = ();
169 slords 1.30 %base = ();
170 slords 1.20
171 unnilennium 1.79 @{$distrepo->{$ver}->{all_archs}} = ('noarch', @{$distrepo->{$ver}->{'archs'}});
172     if ( grep $_ eq 'i386', @{$distrepo->{$ver}->{'archs'}} ) {
173 slords 1.78 push @{$distrepo->{$ver}->{all_archs}}, ('i586', 'i686');
174     }
175    
176 slords 1.30 foreach my $dir ( sort { $repos->{$baserepo->{$b}}->{prio} <=> $repos->{$baserepo->{$a}}->{prio} || $a cmp $b } keys %$baserepo ) {
177 slords 1.76 my $bdir = $dir;
178     $bdir =~ s/~S/$distrepo->{$ver}->{repo}/;
179     $bdir =~ s/~s/$ver/;
180     $bdir =~ s/~C/$distrepo->{$ver}->{centos}/;
181 unnilennium 1.79 for my $arch ( @{$distrepo->{$ver}->{'archs'}}, 'SRPMS/' ) {
182 slords 1.76 my $adir = $bdir;
183     if ( $arch eq 'SRPMS/' ) {
184     $adir =~ s/~A.*//;
185     if ( -d "${adir}SRPMS" ) {
186     $adir .= "SRPMS/";
187     } elsif ( -d "${adir}Source/SPackages" ) {
188     $adir .= "Source/SPackages/";
189     }
190     } else {
191     $adir =~ s/~A/$arch/;
192     if ( -d "${adir}RPMS" ) {
193     $adir .= "RPMS/";
194     } elsif ( -d "${adir}Packages" ) {
195     $adir .= "Packages/";
196     } elsif ( -d "${adir}CentOS" ) {
197     $adir .= "CentOS/";
198     } elsif ( -d "${adir}$osdir" ) {
199     $adir .= "$osdir/";
200     }
201     }
202     next unless -d $adir;
203     opendir DIR, $adir or next;
204 unnilennium 1.81 my @txt = grep { /\.rpm$/ && -f "$adir/$_" } readdir DIR;
205 slords 1.76 closedir DIR;
206 unnilennium 1.81 if (scalar(@txt)) {
207     opendir DIR, $adir or next;
208     process_rpm("$adir$_", $ver, $baserepo->{$dir}) foreach readdir DIR;
209     closedir DIR;
210     } elsif ($baserepo->{$dir} eq 'epel') {
211     # EPEL 7 uses a structure with subfolders of first letter of package
212     find( { wanted => sub { process_rpm($_, $ver, $baserepo->{$dir}) if ($_ =~ m/\.rpm$/);}, no_chdir => 1, follow_fast => 1 }, $adir );
213     }
214 slords 1.76 last unless $dir =~ m{~A};
215     }
216 slords 1.20 }
217 unnilennium 1.79 find( { wanted => sub { process_rpm($_, $ver, 'builds'); }, no_chdir => 1, follow_fast => 1 }, "$_" ) foreach @{$distrepo->{$ver}->{'builds'}};
218     find( { wanted => sub { process_rpm($_, $ver, 'community'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$ver}->{'community'} ) if $distrepo->{$ver}->{'community'};
219 slords 1.20
220 slords 1.30 foreach my $base ( sort keys %$rpms ) {
221 slords 1.76 next unless $rpms->{$base}->{rpms};
222     my %track = ();
223     my %seen = ();
224     my %counts = ();
225     my $acnt = ();
226     my $print = 0;
227     %latest = ();
228    
229     foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) {
230     next if $pkg->{done};
231    
232     my $tmp = $pkg->{svr};
233     # srpm transformations to match up binary and source rpms
234     SRC: {
235     # Try to find the name the binary wants (no changes)
236     $rpms->{$base}->{vers}->{$tmp} && last SRC;
237    
238     # rpmforge (.el4.rf to .rf, with rf,rfb,rft,rfx endings)
239     ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf[btx]?)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
240     # rpmforge (.el4.rfx to .rf, rfb,rft,rfx switched to rf)
241     ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)[btx]$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
242     # rpmforge (.el4.rf to .rfx, rf,rfb,rft,rfx switched to rfx)
243     ($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)[btx]?$}{$1x} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
244     # rpmforge (.el4.rf to .el5) TODO: remove when no longer needed
245     ($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.el5} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
246     # rpmforge (.2.el4.rf to .rf, minor modification not pushed to source?) TODO: remove when no longer needed
247     ($tmp = $pkg->{svr}) =~ s{\.2\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
248    
249     # atrpms (remove .at)
250     ($tmp = $pkg->{svr}) =~ s{\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
251     # atrpms (remove .el4.at)
252     ($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
253     # atrpms (remove .el4)
254     ($tmp = $pkg->{svr}) =~ s{\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
255     # atrpms (remove .0.el5, minor modification not pushed to source?) TODO: remove when no longer needed
256     ($tmp = $pkg->{svr}) =~ s{\.0\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
257    
258     # Transformations that we hopefully won't have to use anymore TODO: remove if no issues
259     #($tmp = $pkg->{svr}) =~ s{(\.el\d)\.rf$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
260     #($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
261     #($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
262     #($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d\.rf$}{$1.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
263     #($tmp = $pkg->{svr}) =~ s{\.el\d_}{_} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
264     #($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
265     #($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
266     #($tmp = $pkg->{svr}) =~ s{\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC;
267     #($tmp = $pkg->{svr}) =~ s{\.el\d\.$disttag$}{ && $rpms->{$base}->{vers}->{$tmp} && last SRC;
268     }
269     if ( $rpms->{$base}->{vers}->{$tmp} ) {
270     foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) {
271     $tmp->{svr} = $pkg->{svr};
272     push @{$rpms->{$base}->{rpms}}, $tmp unless $tmp->{added};
273     $tmp->{added}++;
274     }
275     }
276    
277     my %orig = ();
278     my %pkgs = ();
279     my %reposrc = ();
280     my $srpm = undef;
281     foreach my $cmp ( sort { $a->{src} <=> $b->{src} || $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} } @{$rpms->{$base}->{rpms}} ) {
282     next unless $cmp->{svr} eq $pkg->{svr};
283    
284     if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) {
285     if ( $cmp->{src} ) {
286     if ( ! $track{repo} ) {
287     $cmp->{delete}++;
288     $cmp->{done}++;
289     next;
290     }
291     } else {
292     $track{repo} = $cmp->{repo};
293     $track{svr} = $cmp->{svr};
294     }
295     }
296     if ( $cmp->{svr} eq $track{svr} ) {
297     if ( $seen{$cmp->{nvra}} ) {
298     if ( $track{repo} ne $cmp->{repo} ) {
299     if ($repos->{$cmp->{repo}}->{stage} ) {
300     if ( $seen{$cmp->{nvra}}->{latest} ) {
301     $seen{$cmp->{nvra}}->{latest}++;
302     delete $cmp->{delete} if $cmp->{delete};
303     } else {
304     $cmp->{delete}++;
305     }
306     } elsif ( $repos->{$cmp->{repo}}->{orig} ) {
307     $orig{$cmp->{nvra}}++;
308     unless ( $repos->{$cmp->{repo}}->{base} ) {
309 slords 1.73 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
310 slords 1.76 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
311     }
312     } elsif ( $cmp->{src} ) {
313     if ( $cmp->{delete} && $cmp->{oldrepo} && $reposrc{$cmp->{oldrepo}}) {
314     $cmp->{repo} = $cmp->{oldrepo};
315     delete $cmp->{delete};
316     }
317     if ( $reposrc{$cmp->{repo}} ) {
318     $reposrc{$cmp->{repo}}->{srpm} = $cmp;
319     $srpm = $cmp if ! $srpm;
320     } elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} && ! $cmp->{done} ) {
321     $cmp->{delete}++;
322     }
323     } elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) {
324     $cmp->{delete}++;
325     }
326     } elsif ( $cmp->{src} ) {
327     if ( $reposrc{$cmp->{repo}} && $reposrc{$cmp->{repo}}->{srpm} && $reposrc{$cmp->{repo}}->{srpm}->{oldrepo} ne $cmp->{repo} ) {
328     $acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{src} = [
329     grep { $_ ne $reposrc{$cmp->{repo}}->{srpm} } @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{src}}
330     ];
331    
332     if ( @{$reposrc{$cmp->{repo}}->{srpm}->{repos}} == 1 ) {
333     $reposrc{$cmp->{repo}}->{srpm}->{repo} = $reposrc{$cmp->{repo}}->{srpm}->{oldrepo};
334     delete $reposrc{$cmp->{repo}}->{srpm}->{oldrepo};
335     delete $reposrc{$cmp->{repo}}->{srpm}->{delete};
336     delete $reposrc{$cmp->{repo}}->{srpm}->{repos};
337     delete $reposrc{$cmp->{repo}}->{srpm}->{done};
338     $seen{$cmp->{nvra}} = $cmp if $seen{$cmp->{nvra}} eq $reposrc{$cmp->{repo}}->{srpm};
339     } else {
340     warn "How did I get here??";
341     }
342     } else {
343     $seen{$cmp->{nvra}} = $cmp if $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo};
344     }
345     $srpm = $cmp if ! $srpm && $cmp->{src};
346     $reposrc{$cmp->{repo}}->{srpm} = $cmp if $reposrc{$cmp->{repo}};
347     }
348     } elsif ( $repos->{$cmp->{repo}}->{stage} ) {
349     $cmp->{delete}++;
350 slords 1.78 } elsif ( $cmp->{src} || grep $_ eq $cmp->{rpm}->arch, @{$distrepo->{$ver}->{all_archs}} ) {
351 slords 1.76 $srpm = $cmp if ! $srpm && $cmp->{src};
352     my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
353     $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
354     $dest = $devel1 if verrel($cmp, $dest, \%counts);
355     if ( $cmp->{repo} ne $dest ) {
356     push @{$cmp->{repos}}, $dest;
357     if ( $repos->{$cmp->{repo}}->{orig} ) {
358     $orig{$cmp->{nvra}}++;
359     unless ( $repos->{$cmp->{repo}}->{base} ) {
360 slords 1.73 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
361 slords 1.76 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
362     }
363     } elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
364     $reposrc{$cmp->{repo}}->{srpm} = $cmp;
365     } else {
366     $cmp->{delete}++;
367     }
368     $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
369     $cmp->{repo} = $dest;
370     if ( ! $cmp->{src} && $repos->{$dest}->{prio} > $repos->{$track{repo}}->{prio} ) {
371     $track{repo} = $dest;
372     $track{svr} = $cmp->{svr};
373     }
374     }
375     if ( $cmp->{src} && $reposrc{$cmp->{repo}} ) {
376     $reposrc{$cmp->{repo}}->{srpm} = $cmp;
377     }
378     }
379     } else {
380     if ( $track{repo} eq $cmp->{repo} ) {
381     if ( verrel($cmp, $cmp->{repo}, \%counts) ) {
382     $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
383     } elsif ( $cmp->{src} ) {
384     $cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base};
385     } else {
386     $track{svr} = $cmp->{svr};
387     }
388     } elsif ( ! $repos->{$cmp->{repo}}->{base} ) {
389     if ( $repos->{$cmp->{repo}}->{orig} ) {
390     $srpm = $cmp if ! $srpm && $cmp->{src};
391     my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2;
392     $dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms});
393     $dest = $devel1 if verrel($cmp, $dest, \%counts);
394     unless ( $cmp->{src} && ! $reposrc{$dest} ) {
395     if ( $repos->{$dest}->{prio} >= $repos->{$track{repo}}->{prio} && ! verrel($cmp, $dest, \%counts) ) {
396     unless ( $repos->{$cmp->{repo}}->{base} ) {
397 slords 1.73 my $tag = dirname(dirname($cmp->{rpm}->{filename}));
398 slords 1.76 qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED";
399     }
400     push @{$cmp->{repos}}, $dest;
401     $cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo};
402     $cmp->{repo} = $dest;
403     $reposrc{$cmp->{repo}}->{srpm} = $cmp if $cmp->{src};
404     $orig{$cmp->{nvra}}++;
405     }
406     }
407     } else {
408     $cmp->{delete}++;
409     }
410     }
411     }
412     unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) {
413     $pkgs{$cmp->{nvra}}++;
414     $latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}};
415     $reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{src} || $repos->{$cmp->{repo}}->{stage};
416     if ( $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc} ) {
417     $cmp->{latest}++ if ! $seen{$cmp->{nvra}} || $cmp->{src};
418     }
419     $seen{$cmp->{nvra}} = $cmp unless $seen{$cmp->{nvra}};
420     push @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{$cmp->{src} ? 'src' : $cmp->{rpm}->arch}}, $cmp unless $cmp->{done};
421     }
422     $cmp->{done}++;
423     }
424     if ( $srpm ) {
425     foreach my $r ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %reposrc ) {
426     unless ( $reposrc{$r}->{srpm} ) {
427     unshift @{$srpm->{repos}}, $r;
428     $srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo};
429     $srpm->{repo} = $r;
430     $reposrc{$r}->{srpm} = $srpm;
431     }
432     }
433     } elsif ( scalar keys %pkgs && $opts{s} ) {
434     print "\n * missing source ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n";
435     }
436     print "\n * missing originals ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs;
437     }
438    
439     foreach my $r ( keys %$acnt ) {
440     foreach my $p ( keys %{$acnt->{$r}} ) {
441     foreach my $a ( keys %{$acnt->{$r}->{$p}} ) {
442     if ( $a eq 'noarch' ) {
443     my $p2 = ${$acnt->{$r}->{$p}->{$a}}[0];
444 unnilennium 1.79 if ( ! $p2->{repos} && scalar @{$acnt->{$r}->{$p}->{$a}} != scalar @{$distrepo->{$ver}->{'archs'}} ) {
445 slords 1.76 $p2->{oldrepo} = $p2->{repo};
446     push @{$p2->{repos}}, $p2->{repo};
447     }
448     } elsif ( scalar @{$acnt->{$r}->{$p}->{$a}} != 1 ) {
449     print "\n * many packages ($r, $a, $p)\n" unless $p =~ m{^syslinux-nonlinux-[0-9]};
450     }
451     }
452     }
453     }
454    
455     foreach my $pkg ( sort { $a->{nvra} cmp $b->{nvra} } @{$rpms->{$base}->{rpms}} ) {
456     if ( $pkg->{latest} && $pkg->{latest} == 1 ) {
457     unless ( grep { $_->{nvra} eq $pkg->{nvra} && $_->{repo} eq $stage } @{$rpms->{$base}->{rpms}} ) {
458     $pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo};
459     $pkg->{repo} = $stage;
460     push @{$pkg->{repos}}, $stage;
461     }
462     }
463 slords 1.20
464 slords 1.73 if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) {
465     print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
466     $print++;
467     }
468    
469     my $src = $pkg->{rpm}->filename;
470     if ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) {
471     print "sign package (", basename($pkg->{rpm}->filename), ")\n";
472     unless ( $opts{t} ) {
473     qx(cat $HOME/.rpmpass | setsid rpm -D '_gpg_name $distrepo->{$ver}->{keyname}' --addsign $src >& /dev/null);
474     if ($?) {
475     print " * failed to sign package\n";
476     next;
477     }
478     }
479     }
480 slords 1.20
481 slords 1.76 if ( $pkg->{repos} ) {
482     foreach my $repo ( @{$pkg->{repos}} ) {
483     if ( $pkg->{delete} ) {
484     print "move from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
485     $pkg->{delete} = 0;
486     $repochg{$pkg->{oldrepo}}++ unless $repos->{$pkg->{oldrepo}}->{base} || $repos->{$pkg->{oldrepo}}->{stage};
487     } elsif ( $pkg->{oldrepo} eq $repo ) {
488     print "distribute noarch in $repo (", basename($pkg->{rpm}->filename), ")\n";
489     } else {
490     print "copy from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n";
491     }
492     $repochg{$repo}++ unless $repos->{$repo}->{base} || $repos->{$repo}->{stage};
493     $pkg->{oldrepo} = $repo unless $pkg->{oldrepo} eq ${$pkg->{repos}}[0];
494    
495     my @d = ();
496     my $head = $distrepo->{$ver}->{repo} . $repo . '/';
497     $head = $distrepo->{$ver}->{stage} if $repos->{$repo}->{stage};
498     my $tail = $repos->{$repo}->{os} ? "$osdir/" : 'RPMS/';
499     if ( $pkg->{src} ) {
500     push @d, "${head}SRPMS/" . basename($pkg->{rpm}->filename);
501     } elsif ( $pkg->{rpm}->arch eq 'noarch' ) {
502 unnilennium 1.79 push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @{$distrepo->{$ver}->{'archs'}};
503 unnilennium 1.80 } elsif ($ver>=10 && $pkg->{rpm}->arch =~ m{^(i[356]86)$} && $pkg->{arch} =~ m{^(x86_64)$} ) {
504     #add copy of i686 packages in x86_64 folder for SME>=10
505     push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @{$distrepo->{$ver}->{'archs'}};
506 slords 1.76 } elsif ( $pkg->{rpm}->arch =~ m{^(i[356]86)$} ) {
507     push @d, "${head}i386/$tail" . basename($pkg->{rpm}->filename);
508     } else {
509     push @d, $head . $pkg->{rpm}->arch . "/$tail" . basename($pkg->{rpm}->filename);
510     }
511     foreach my $dest ( @d ) {
512     qx(cp --preserve=timestamps $src $dest) unless $opts{t} || -f "$dest";
513     }
514    
515     }
516     qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t};
517     } elsif ( $pkg->{delete} ) {
518     print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
519     qx(rm -f $src) unless $opts{t};
520     $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
521     if ( $repos->{$pkg->{repo}}->{orig} && ! $repos->{$pkg->{repo}}->{base} ) {
522 slords 1.73 my $tag = dirname(dirname($pkg->{rpm}->{filename}));
523 slords 1.76 qx(rm -f $tag/PUSHED) if ! $opts{t} && -d $tag && -f "$tag/PUSHED";
524     }
525     }
526     }
527    
528     if ( $rpms->{$base}->{srpms} ) {
529     foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{srpms}} ) {
530     next if $pkg->{done} || $repos->{$pkg->{repo}}->{orig} || $repos->{$pkg->{repo}}->{base};
531     $pkg->{delete}++;
532     my $src = $pkg->{rpm}->filename;
533     if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) {
534     print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n";
535     $print++;
536     }
537     print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n";
538     qx(rm -f $src) unless $opts{t};
539     $repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage};
540     }
541     }
542 slords 1.30 }
543    
544     if ( %repochg ) {
545 slords 1.76 print "\nrebuild repo ($disttag$ver)\n", "=" x length("rebuild repo ($disttag$ver)"), "\n";
546 slords 1.30 }
547     foreach my $repo ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %repochg ) {
548 slords 1.76 next if $repos->{$repo}->{orig} || $repos->{$repo}->{stage};
549 unnilennium 1.79 foreach my $arch ( @{$distrepo->{$ver}->{'archs'}} ) {
550 slords 1.76 my $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
551     $dir = qx(readlink -f $dir);
552     if ( $dir ) {
553     chomp $dir;
554     } else {
555     $dir = $distrepo->{$ver}->{repo} . "$repo/$arch";
556     }
557     print "rebuild $repo/$arch\n";
558     unless ( $opts{t} ) {
559 slords 1.66 my $checksum = "--checksum $distrepo->{$ver}->{checksum}";
560    
561     my $exclude = "";
562 slords 1.71 $exclude .= " --exclude ${osdir}/*" if -d "$dir/Packages";
563 slords 1.72 $exclude .= " --exclude *smeserver-release*.rpm" if $dir =~ m{test/|-testing/};
564 slords 1.66
565     my $groupfile = "";
566 slords 1.72 $groupfile = "--simple-md-filenames --groupfile repodata/comps.xml" if -f "$dir/repodata/comps.xml";
567 slords 1.66
568     qx(createrepo --update --database --exclude *.src.rpm --exclude *-debuginfo-*.rpm $checksum $exclude $groupfile $dir);
569 slords 1.76 qx(repoview $dir);
570 slords 1.66
571 slords 1.76 qx(rm -rf $dir/.olddata) if -d "$dir/.olddata";
572     qx(rm -rf $dir/.repodata) if -d "$dir/.repodata";
573     qx(rm -rf $dir/repodata/index.html) if -f "$dir/repodata/index.html";
574     qx(rm -rf $dir/repodata/update-info) if -d "$dir/repodata/update-info";
575     qx(rm -rf $dir/repodata/repoview) if -d "$dir/repodata/repoview";
576     }
577     }
578 slords 1.20 }
579 slords 1.30 unless ( $opts{t} ) {
580 unnilennium 1.79 foreach (@{$distrepo->{$ver}->{'builds'}})
581 slords 1.71 {
582     finddepth(sub{rmdir}, "$_") if -d "$_";
583     }
584 unnilennium 1.79 finddepth(sub{rmdir}, $distrepo->{$ver}->{'community'}) if -d "$distrepo->{$ver}->{'community'}";
585 slords 1.30 }
586 slords 1.1 }
587    
588 slords 1.30 sub verrel {
589     my $pkg = shift;
590     my $repo = shift;
591     my $counts = shift;
592 slords 1.20
593 slords 1.31 return 0 if $pkg->{src};
594 slords 1.30 $counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++;
595     return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver};
596     return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel};
597     return 0;
598 slords 1.20 }
599    
600 slords 1.30 sub pkgdest {
601 slords 1.20 my $pkg = shift;
602 slords 1.30 my $dest = shift;
603     my $hirepo = shift;
604     my $pkgs = shift;
605    
606     foreach my $cmp ( @$pkgs ) {
607 slords 1.76 next if $cmp->{src} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio};
608     next if $pkg->{name} ne ( $pkg->{src} ? $cmp->{base} : $cmp->{name} );
609     if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) {
610     $dest = $hirepo;
611     last;
612     } else {
613     $dest = $cmp->{repo};
614     }
615 slords 1.20 }
616 slords 1.30 return $dest;
617 slords 1.20 }
618    
619 slords 1.30 sub process_rpm {
620     my $rpm = shift;
621 slords 1.52 my $ver = shift;
622 slords 1.30 my $repo = shift;
623     return unless $rpm =~ m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$};
624     my $base = $1;
625     return unless ! $opts{r} || $base =~ m[$opts{r}];
626     return unless $latest{$base} || $sources{$base} || ! $repos->{$repo}->{base};
627 slords 1.20
628     my $pkg;
629 slords 1.30 eval { $pkg = RPM2->open_package($rpm, $rpm_flags); };
630     if ($@) { print " * corrupt package ($rpm)\n"; return; }
631 slords 1.20 eval { my $sig = $pkg->siggpg };
632 slords 1.72
633     my $nosig = 1;
634     eval { my $sig = $pkg->dsaheader }; $nosig &= ! $@;
635     eval { my $sig = $pkg->rsaheader }; $nosig &= ! $@;
636     eval { my $sig = $pkg->siggpg }; $nosig &= ! $@;
637     eval { my $sig = $pkg->sigpgp }; $nosig &= ! $@;
638    
639 slords 1.30 my $cmp = $latest{$pkg->name};
640     if ( $repos->{$repo}->{base} && ! $pkg->is_source_package ) {
641 slords 1.76 return unless $cmp;
642     return if $repos->{$cmp->{repo}}->{base} && $repos->{$cmp->{repo}}->{prio} > $repos->{$repo}->{prio} && $pkg ge $cmp->{rpm};
643 slords 1.30 }
644     my ($src, $version, $release) = ($pkg->is_source_package ? $pkg->filename : $pkg->sourcerpm) =~ m{(?:^|/)([^/]*)-([^-]+)-([^-]+)\.\w+\.rpm$};
645 slords 1.52 return if $skippkg->{$ver}->{$repo} && ( $skippkg->{$ver}->{$repo}->{$src} || $skippkg->{$ver}->{$repo}->{$pkg->name} );
646 unnilennium 1.88 return if $onlypkg->{$ver}->{$repo} && !( $onlypkg->{$ver}->{$repo}->{$src} || $onlypkg->{$ver}->{$repo}->{$pkg->name} );
647 slords 1.71 return if $repos->{$repo}->{base} && $nosig && $baserepo->{$ver}->{sign};
648 slords 1.30 if ( $nosig && ! -f "$HOME/.rpmpass" ) { print " * missing signature (" .$pkg->filename . ")\n"; return; }
649 slords 1.34 my $arch = 'unknown';
650     $arch = 'SRPMS' if $pkg->filename =~ m{[/-](SRPMS?|src|source)/};
651     $arch = 'x86_64' if $pkg->filename =~ m{[/-]x86_64/};
652     $arch = 'i386' if $pkg->filename =~ m{[/-](i[356]86)/};
653     $arch = 'noarch' if $pkg->filename =~ m{[/-]noarch/};
654 slords 1.30
655     my $rpmhash = { base => $src,
656 slords 1.76 name => $pkg->name,
657     repo => $repo,
658     nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ),
659     svr => $src.'-'.$version.'-'.$release,
660     src => $pkg->is_source_package,
661     arch => $arch,
662     ver => $version,
663     rel => $release,
664     rpm => $pkg,
665     nosig => $nosig,
666     };
667 slords 1.30 if ( $pkg->is_source_package ) {
668 slords 1.76 push @{$rpms->{$src}->{srpms}}, $rpmhash;
669     push @{$rpms->{$src}->{vers}->{$rpmhash->{svr}}}, $rpmhash;
670 slords 1.30 } else {
671 slords 1.76 push @{$rpms->{$src}->{rpms}}, $rpmhash;
672 slords 1.26 }
673 slords 1.30 $sources{$src}++;
674 slords 1.20
675 slords 1.30 return if $pkg->is_source_package || $repos->{$repo}->{stage};
676     if ( ! $repos->{$repo}->{base} ) {
677 slords 1.76 if ( ! $cmp || $pkg gt $cmp->{rpm} ) {
678     $latest{$pkg->name} = $rpmhash;
679     }
680 slords 1.30 } elsif ( ( $repos->{$repo}->{prio} >= $repos->{$cmp->{repo}}->{prio} || ! $repos->{$cmp->{repo}}->{base} ) && $pkg ge $cmp->{rpm} ) {
681 slords 1.76 $latest{$pkg->name} = $rpmhash;
682 slords 1.20 }
683 slords 1.1 }

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