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