6 |
use File::Find; |
use File::Find; |
7 |
use File::Basename; |
use File::Basename; |
8 |
use Getopt::Std; |
use Getopt::Std; |
|
use Term::ANSIColor; |
|
9 |
use Data::Dumper; |
use Data::Dumper; |
10 |
|
|
11 |
delete $ENV{PATH}; |
delete $ENV{PATH}; |
12 |
my $HOME=$ENV{HOME}; |
my $HOME=$ENV{HOME}; |
13 |
umask 002; |
umask 002; |
|
|
|
|
my $rpm_flags = RPM2->vsf_nosha1header | RPM2->vsf_nomd5header | RPM2->vsf_nodsaheader | RPM2->vsf_norsaheader; |
|
|
$rpm_flags |= RPM2->vsf_nosha1 | RPM2->vsf_nomd5 | RPM2->vsf_nodsa | RPM2->vsf_norsa; |
|
|
|
|
|
$Term::ANSIColor::AUTORESET = 1; |
|
14 |
$| = 1; |
$| = 1; |
15 |
|
|
16 |
my @archs = ( 'i386', 'x86_64' ); |
my %opts; |
17 |
|
getopts( 'ostr:', \%opts ); |
18 |
my $repos = { 'smeos' => { prio => 17, inc => 1, ver => 1, rel => 1, os => 1 }, |
$opts{r} ||= ''; |
19 |
'smeupdates' => { prio => 16, inc => 1, ver => 1, rel => 1 }, |
#available options |
20 |
'smeupdates-testing' => { prio => 15, inc => 1, ver => 1, rel => 1 }, |
#-o = verify we have originals of the packages in repos (not really used anymore) |
21 |
'smeextras' => { prio => 14, inc => 0, ver => 1, rel => 1 }, |
#-s = verify every package has a source package (so we can rebuild if necessary) |
22 |
'smeaddons' => { prio => 13, inc => 0, ver => 1, rel => 1 }, |
#-t = test run (don't do anything just print out what would be done) |
23 |
'smecontribs' => { prio => 12, inc => 0, ver => 1, rel => 1 }, |
#-r {regex} = regex of packages to run the script against |
24 |
'smetest' => { prio => 11, inc => 1, ver => 2, rel => 2, devel => 2 }, |
|
25 |
'smedev' => { prio => 10, inc => 0, ver => 2, rel => 2, devel => 1 }, |
my $rpm_flags = RPM2->vsf_nodsaheader | RPM2->vsf_norsaheader | RPM2->vsf_nodsa | RPM2->vsf_norsa; |
26 |
'centos' => { prio => 9, inc => 0, ver => 0, rel => 0, base => 1 }, |
|
27 |
'fedora/epel' => { prio => 8, inc => 0, ver => 0, rel => 0, base => 1 }, |
my $osdir = 'Packages'; |
28 |
'fedora/extras' => { prio => 7, inc => 0, ver => 0, rel => 0, base => 1 }, |
my $disttag = 'sme'; |
29 |
'rpmforge' => { prio => 6, inc => 0, ver => 0, rel => 0, base => 1 }, |
my $repotag = 'sme'; |
30 |
'atrpms' => { prio => 5, inc => 0, ver => 0, rel => 0, base => 1 }, |
|
31 |
'fedora/core' => { prio => 4, inc => 0, ver => 0, rel => 0, base => 1 }, |
my $distrepo = { '8' => { active => 0, |
32 |
'base' => { prio => 3, inc => 0, ver => 0, rel => 0, base => 1 }, |
centos => 5, |
33 |
'builds' => { prio => 2, inc => 0, ver => 0, rel => 0, builds => 1 }, |
archs => [ 'i386', 'x86_64' ], |
34 |
'stage' => { prio => 1, inc => 0, ver => 0, rel => 0, stage => 1, os => 1 }, |
repo => '/build/smeserver/repo/8/', |
35 |
}; |
builds => ['/build/builds/smeserver-8-core/'], |
36 |
|
community => '/build/builds/smeserver-8-contribs/', |
37 |
my $distrepo = { '7' => { active => 1, |
stage => '/build/smeserver/stage/8/', |
38 |
centos => 4, |
sign => 1, |
39 |
fedora => 3, |
keyname => 'SME Server 7 signing key <bugteam@contribs.org>', |
40 |
repo => '/releases/7/', |
checksum => 'sha', |
41 |
os => 'SME/RPMS/', |
}, |
42 |
builds => '/builds/smeserver-7-core/', |
'9' => { active => 0, |
43 |
stage => '/stage/7/', |
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 |
|
keyname => 'SME Server 7 signing key <bugteam@contribs.org>', |
51 |
|
checksum => 'sha256', |
52 |
|
}, |
53 |
|
'10' => { active => 1, |
54 |
|
centos => 7, |
55 |
|
archs => [ 'x86_64' ], |
56 |
|
repo => '/build/smeserver/repo/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 |
|
keyname => 'Koozali SME Server signing key (10) <bugteam@koozali.org>', |
62 |
|
checksum => 'sha256', |
63 |
|
}, |
64 |
|
}; |
65 |
|
|
66 |
|
# 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 |
|
my $repos = { "${repotag}os" => { prio => 29, inc => 1, ver => 1, rel => 1, os => 1 }, |
74 |
|
"${repotag}updates" => { prio => 28, inc => 1, ver => 1, rel => 1 }, |
75 |
|
"${repotag}updates-testing" => { prio => 27, inc => 1, ver => 1, rel => 3 }, |
76 |
|
"${repotag}extras" => { prio => 26, inc => 0, ver => 1, rel => 1 }, |
77 |
|
"${repotag}addons" => { prio => 25, inc => 0, ver => 1, rel => 1 }, |
78 |
|
"${repotag}contribs" => { prio => 24, inc => 0, ver => 1, rel => 1 }, |
79 |
|
"${repotag}test" => { prio => 23, inc => 0, ver => 2, rel => 3, devel => 2 }, |
80 |
|
"${repotag}dev" => { prio => 22, inc => 0, ver => 1, rel => 1, devel => 1 }, |
81 |
|
'centos' => { prio => 21, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
82 |
|
'remisafe' => { prio => 12, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
83 |
|
'remi' => { prio => 11, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
84 |
|
'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 |
|
# ~s will be expanded to SME version |
99 |
|
# ~S expanded to repo root |
100 |
|
my $baserepo = { "~S${repotag}os/~A/" => "${repotag}os", |
101 |
|
"~S${repotag}updates/~A/" => "${repotag}updates", |
102 |
|
"~S${repotag}updates-testing/~A/" => "${repotag}updates-testing", |
103 |
|
"~S${repotag}extras/~A/" => "${repotag}extras", |
104 |
|
"~S${repotag}addons/~A/" => "${repotag}addons", |
105 |
|
"~S${repotag}contribs/~A/" => "${repotag}contribs", |
106 |
|
"~S${repotag}test/~A/" => "${repotag}test", |
107 |
|
"~S${repotag}dev/~A/" => "${repotag}dev", |
108 |
|
"/build/smeserver/stage/~s/~A/" => 'stage', |
109 |
|
'/mirrors/centos/~C/fasttrack/~A/' => 'centos', |
110 |
|
'/mirrors/centos/~C/updates/~A/' => 'centos', |
111 |
|
'/mirrors/centos/~C/os/~A/' => 'centos', |
112 |
|
'/mirrors/centos/~C/extras/~A/' => 'centos', |
113 |
|
'/mirrors/centos-vault/~C/fasttrack/~A/' => 'centos', |
114 |
|
'/mirrors/centos-vault/~C/updates/~A/' => 'centos', |
115 |
|
'/mirrors/centos-vault/~C/os/~A/' => 'centos', |
116 |
|
'/mirrors/centos-vault/~C/extras/~A/' => 'centos', |
117 |
|
'/mirrors/fedora/epel/~C/~A/' => 'epel', |
118 |
|
'/mirrors/fedora/epel/testing/~C/~A/' => 'epeltesting', |
119 |
|
'/mirrors/remi/enterprise/~C/remi/~A/' => 'remi', |
120 |
|
'/mirrors/remi/SRPMS/' => 'remi', |
121 |
|
'/mirrors/remi/enterprise/~C/safe/~A/' => 'remisafe', |
122 |
|
'/mirrors/rpmfusion/updates/~C/~A/' => 'rpmfusion', |
123 |
|
'/mirrors/rpmforge/redhat/el~C/en/~A/dag/' => 'rpmforge', |
124 |
|
'/mirrors/rpmforge/redhat/el~C/en/~A/extras/' => 'rpmforge', |
125 |
|
'/mirrors/rpmforge/source/' => 'rpmforge', |
126 |
|
'/mirrors/atrpms/el~C-~A/atrpms/stable/' => 'atrpms', |
127 |
|
'/mirrors/atrpms/el~C-~A/atrpms/testing/' => 'atrpms', |
128 |
|
'/mirrors/atrpms/src/el~C-~A/atrpms/stable/' => 'atrpms', |
129 |
|
'/mirrors/atrpms/src/el~C-~A/atrpms/testing/' => 'atrpms', |
130 |
|
'/mirrors/openfusion/centos~C-~A/' => 'openfusion', |
131 |
|
'/mirrors/openfusion/srpms/' => 'openfusion', |
132 |
|
}; |
133 |
|
|
134 |
|
# add here packages to exclude |
135 |
|
# for each version, if a repo is listed and rpm are listed they will be ignored fromt his repo |
136 |
|
my $skippkg = { '8' => { 'atrpms' => { map { $_ => 1 } ( 'clamav', 'gnupg' ) }, |
137 |
|
'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3' ) }, |
138 |
|
'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' ) }, |
139 |
|
'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' ) }, |
140 |
|
'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') }, |
141 |
|
}, |
142 |
|
'9' => { 'atrpms' => { map { $_ => 1 } ( 'clamav', 'perl-Pod-Escapes', 'perl-Pod-Simple','libvorbis' , 'libogg','iksemel' ) }, |
143 |
|
'epel' => { map { $_ => 1 } ( 'clamav', 'oidentd', 'perl-Razor-Agent' ) }, |
144 |
|
'epeltesting' => { map { $_ => 1 } ( 'clamav', 'oidentd', 'perl-Razor-Agent' ) }, |
145 |
|
'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') }, |
146 |
|
}, |
147 |
|
'10' => { |
148 |
|
#'epel' => { map { $_ => 1 } ( 'clamav') }, |
149 |
|
'epeltesting' => { map { $_ => 1 } ( 'clamav', 'tidy') }, |
150 |
|
'openfusion' => { map { $_ => 1 } ( 'daemontools-encore' , 'daemontool', 'daemontools', 'perl-Apache-AuthTkt', 'perl-Data-Validate-Domain', 'perl-HTML-Tabulate', 'perl-IP-Country', 'perl-Object-Accessor','perl-Archive-Tar', 'perl-Authen-SASL', 'perl-Business-ISBN', 'perl-Business-ISBN-Data', 'perl-Config-Tiny', 'perl-Convert-ASN1', 'perl-DBD-MySQL', 'perl-DB_File', 'perl-Data-Dumper', 'perl-Date-Manip', 'perl-Email-Address', 'perl-Encode', 'perl-ExtUtils-MakeMaker', 'perl-ExtUtils-Manifest', 'perl-ExtUtils-ParseXS', 'perl-File-ShareDir', 'perl-Getopt-Long', 'perl-HTML-Parser', 'perl-HTTP-Message', 'perl-IO-HTML', 'perl-IO-Socket-INET6', 'perl-MailTools', 'perl-Mozilla-CA', 'perl-Net-SSLeay', 'perl-NetAddr-IP', 'perl-PathTools', 'perl-Readonly', 'perl-Storable', 'perl-Test-Simple', 'perl-Text-Unidecode', 'perl-XML-Parser', 'perl-libwww-perl', 'perl-parent' ) }, |
151 |
|
}, |
152 |
|
}; |
153 |
|
|
154 |
|
# add here include only conditions |
155 |
|
# for each version if a repo is listed here, only listed rpm will be considered |
156 |
|
my $onlypkg = { '8' => { |
157 |
|
'openfusion' => { }, |
158 |
|
'remi' => { }, |
159 |
|
'remisafe' => { }, |
160 |
}, |
}, |
161 |
'8' => { active => 1, |
'9' => { |
162 |
centos => 5, |
'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 |
163 |
fedora => 6, |
'remi' => { }, |
|
repo => '/releases/testing/8/', |
|
|
os => 'SME/', |
|
|
builds => '/builds/smeserver-8-core/', |
|
|
stage => '/stage/8/', |
|
164 |
}, |
}, |
165 |
}; |
'10' => { |
166 |
|
'remi' => { map { $_ => 1 } ( 'php-pear' )}, |
167 |
my @baserepo = ( ( map { "/mirrors/centos/~C/$_/" } ('os','updates','fasttrack','extras') ), |
}, |
168 |
( map { "/mirrors/fedora/epel$_/~C/" } ('','/testing') ), |
}; |
|
'/mirrors/fedora/extras/~F/', |
|
|
'/mirrors/rpmforge/dag/redhat/el~C/en/~A/RPMS.dag/', |
|
|
'/mirrors/rpmforge/dag/source/', |
|
|
( map { "/mirrors/atrpms$_/el~C-~A/atrpms/stable/" } ('','/src') ), |
|
|
( map { "/mirrors/atrpms$_/el~C-~A/atrpms/testing/" } ('','/src') ), |
|
|
( map {"/mirrors/fedora/core$_/~F/" } ('','/updates') ), |
|
|
); |
|
|
|
|
|
my $skippkg = { '7' => { 'centos' => ['horde','imp-h3','ingo-h3','turba-h3','vim'], |
|
|
'fedora/epel' => ['perl-Razor-Agent'], |
|
|
'rpmforge' => ['perl-Test-Inline'], |
|
|
'atrpms' => ['dovecot','yum'], |
|
|
}, |
|
|
'8' => { 'centos' => ['horde','imp-h3','ingo-h3','turba-h3'], |
|
|
'fedora/epel' => ['perl-Razor-Agent','smolt'], |
|
|
'fedora/extras' => ['dstat','gocr','horde','oidentd','perl-Test-Inline','perl-Razor-Agent','smolt'], |
|
|
'rpmforge' => ['perl-Test-Inline'], |
|
|
'atrpms' => [], |
|
|
'fedora/core' => [], |
|
|
}, |
|
|
}; |
|
169 |
|
|
|
my %opts; |
|
|
getopts( 'dtvr:', \%opts ); |
|
|
$opts{r} ||= ''; |
|
170 |
|
|
171 |
|
my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos; |
172 |
my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos; |
my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos; |
173 |
$devel2 ||= $devel1; |
$devel2 ||= $devel1; |
|
my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos; |
|
174 |
|
|
175 |
my ($rel, @rpms, %latest, %sources, $archs, $rebuild, $newline); |
my ($rpms, %base, %latest, %sources); |
176 |
foreach my $smever ( sort { $a <=> $b } grep { $distrepo->{$_}->{active} } keys %$distrepo ) { |
foreach my $ver ( sort { $a <=> $b } keys %$distrepo ) { |
177 |
$rel = $smever; |
next unless $distrepo->{$ver}->{active}; |
178 |
|
my %repochg = (); |
179 |
|
$rpms = (); |
180 |
%latest = (); |
%latest = (); |
181 |
%sources = (); |
%sources = (); |
182 |
@rpms = (); |
%base = (); |
|
$rebuild = (); |
|
183 |
|
|
184 |
# Load distro packages |
@{$distrepo->{$ver}->{all_archs}} = ('noarch', @{$distrepo->{$ver}->{'archs'}}); |
185 |
find( { wanted => \&loadpkg, no_chdir => 1, follow_fast => 1 }, map { $distrepo->{$smever}->{$_} } ('repo','builds','stage') ); |
if ( grep $_ eq 'i386', @{$distrepo->{$ver}->{'archs'}} ) { |
186 |
printline('white', 0, "Distro (SME Server $rel) packages loaded.\n"); |
push @{$distrepo->{$ver}->{all_archs}}, ('i586', 'i686'); |
187 |
|
} |
188 |
# Load base packages |
|
189 |
foreach my $base ( @baserepo ) { |
foreach my $dir ( sort { $repos->{$baserepo->{$b}}->{prio} <=> $repos->{$baserepo->{$a}}->{prio} || $a cmp $b } keys %$baserepo ) { |
190 |
my $bdir = $base; |
my $bdir = $dir; |
191 |
$bdir =~ s/~C/$distrepo->{$smever}->{centos}/; |
$bdir =~ s/~S/$distrepo->{$ver}->{repo}/; |
192 |
$bdir =~ s/~F/$distrepo->{$smever}->{fedora}/; |
$bdir =~ s/~s/$ver/; |
193 |
if ( $bdir =~ m{~A} ) { |
$bdir =~ s/~C/$distrepo->{$ver}->{centos}/; |
194 |
for my $arch ( @archs ) { |
for my $arch ( @{$distrepo->{$ver}->{'archs'}}, 'SRPMS/' ) { |
195 |
my $basearch = $bdir; |
my $adir = $bdir; |
196 |
$basearch =~ s/~A/$arch/; |
if ( $arch eq 'SRPMS/' ) { |
197 |
find( { wanted => \&loadbase, no_chdir => 1, follow_fast => 1 }, $basearch ) if -r $basearch; |
$adir =~ s/~A.*//; |
198 |
} |
if ( -d "${adir}SRPMS" ) { |
199 |
} else { |
$adir .= "SRPMS/"; |
200 |
find( { wanted => \&loadbase, no_chdir => 1, follow_fast => 1 }, $bdir ) if -r $bdir; |
} elsif ( -d "${adir}Source/SPackages" ) { |
201 |
} |
$adir .= "Source/SPackages/"; |
202 |
|
} |
203 |
|
} else { |
204 |
|
$adir =~ s/~A/$arch/; |
205 |
|
if ( -d "${adir}RPMS" ) { |
206 |
|
$adir .= "RPMS/"; |
207 |
|
} elsif ( -d "${adir}Packages" ) { |
208 |
|
$adir .= "Packages/"; |
209 |
|
} elsif ( -d "${adir}CentOS" ) { |
210 |
|
$adir .= "CentOS/"; |
211 |
|
} elsif ( -d "${adir}$osdir" ) { |
212 |
|
$adir .= "$osdir/"; |
213 |
|
} |
214 |
|
} |
215 |
|
next unless -d $adir; |
216 |
|
opendir DIR, $adir or next; |
217 |
|
my @txt = grep { /\.rpm$/ && -f "$adir/$_" } readdir DIR; |
218 |
|
closedir DIR; |
219 |
|
if (scalar(@txt)) { |
220 |
|
opendir DIR, $adir or next; |
221 |
|
process_rpm("$adir$_", $ver, $baserepo->{$dir}) foreach readdir DIR; |
222 |
|
closedir DIR; |
223 |
|
} elsif ($baserepo->{$dir} eq 'epel') { |
224 |
|
# EPEL 7 uses a structure with subfolders of first letter of package |
225 |
|
find( { wanted => sub { process_rpm($_, $ver, $baserepo->{$dir}) if ($_ =~ m/\.rpm$/);}, no_chdir => 1, follow_fast => 1 }, $adir ); |
226 |
|
} |
227 |
|
last unless $dir =~ m{~A}; |
228 |
|
} |
229 |
|
} |
230 |
|
find( { wanted => sub { process_rpm($_, $ver, 'builds'); }, no_chdir => 1, follow_fast => 1 }, "$_" ) foreach @{$distrepo->{$ver}->{'builds'}}; |
231 |
|
find( { wanted => sub { process_rpm($_, $ver, 'community'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$ver}->{'community'} ) if $distrepo->{$ver}->{'community'}; |
232 |
|
|
233 |
|
foreach my $base ( sort keys %$rpms ) { |
234 |
|
next unless $rpms->{$base}->{rpms}; |
235 |
|
my %track = (); |
236 |
|
my %seen = (); |
237 |
|
my %counts = (); |
238 |
|
my $acnt = (); |
239 |
|
my $print = 0; |
240 |
|
%latest = (); |
241 |
|
|
242 |
|
foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) { |
243 |
|
next if $pkg->{done}; |
244 |
|
|
245 |
|
my $tmp = $pkg->{svr}; |
246 |
|
# srpm transformations to match up binary and source rpms |
247 |
|
SRC: { |
248 |
|
# Try to find the name the binary wants (no changes) |
249 |
|
$rpms->{$base}->{vers}->{$tmp} && last SRC; |
250 |
|
|
251 |
|
# rpmforge (.el4.rf to .rf, with rf,rfb,rft,rfx endings) |
252 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf[btx]?)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
253 |
|
# rpmforge (.el4.rfx to .rf, rfb,rft,rfx switched to rf) |
254 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)[btx]$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
255 |
|
# rpmforge (.el4.rf to .rfx, rf,rfb,rft,rfx switched to rfx) |
256 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)[btx]?$}{$1x} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
257 |
|
# rpmforge (.el4.rf to .el5) TODO: remove when no longer needed |
258 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.el5} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
259 |
|
# rpmforge (.2.el4.rf to .rf, minor modification not pushed to source?) TODO: remove when no longer needed |
260 |
|
($tmp = $pkg->{svr}) =~ s{\.2\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
261 |
|
|
262 |
|
# atrpms (remove .at) |
263 |
|
($tmp = $pkg->{svr}) =~ s{\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
264 |
|
# atrpms (remove .el4.at) |
265 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
266 |
|
# atrpms (remove .el4) |
267 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
268 |
|
# atrpms (remove .0.el5, minor modification not pushed to source?) TODO: remove when no longer needed |
269 |
|
($tmp = $pkg->{svr}) =~ s{\.0\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
270 |
|
|
271 |
|
# Transformations that we hopefully won't have to use anymore TODO: remove if no issues |
272 |
|
#($tmp = $pkg->{svr}) =~ s{(\.el\d)\.rf$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
273 |
|
#($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
274 |
|
#($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
275 |
|
#($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d\.rf$}{$1.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
276 |
|
#($tmp = $pkg->{svr}) =~ s{\.el\d_}{_} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
277 |
|
#($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
278 |
|
#($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
279 |
|
#($tmp = $pkg->{svr}) =~ s{\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
280 |
|
#($tmp = $pkg->{svr}) =~ s{\.el\d\.$disttag$}{ && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
281 |
|
} |
282 |
|
if ( $rpms->{$base}->{vers}->{$tmp} ) { |
283 |
|
foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) { |
284 |
|
$tmp->{svr} = $pkg->{svr}; |
285 |
|
push @{$rpms->{$base}->{rpms}}, $tmp unless $tmp->{added}; |
286 |
|
$tmp->{added}++; |
287 |
|
} |
288 |
|
} |
289 |
|
|
290 |
|
my %orig = (); |
291 |
|
my %pkgs = (); |
292 |
|
my %reposrc = (); |
293 |
|
my $srpm = undef; |
294 |
|
foreach my $cmp ( sort { $a->{src} <=> $b->{src} || $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} } @{$rpms->{$base}->{rpms}} ) { |
295 |
|
next unless $cmp->{svr} eq $pkg->{svr}; |
296 |
|
|
297 |
|
if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) { |
298 |
|
if ( $cmp->{src} ) { |
299 |
|
if ( ! $track{repo} ) { |
300 |
|
$cmp->{delete}++; |
301 |
|
$cmp->{done}++; |
302 |
|
next; |
303 |
|
} |
304 |
|
} else { |
305 |
|
$track{repo} = $cmp->{repo}; |
306 |
|
$track{svr} = $cmp->{svr}; |
307 |
|
} |
308 |
|
} |
309 |
|
if ( $cmp->{svr} eq $track{svr} ) { |
310 |
|
if ( $seen{$cmp->{nvra}} ) { |
311 |
|
if ( $track{repo} ne $cmp->{repo} ) { |
312 |
|
if ($repos->{$cmp->{repo}}->{stage} ) { |
313 |
|
if ( $seen{$cmp->{nvra}}->{latest} ) { |
314 |
|
$seen{$cmp->{nvra}}->{latest}++; |
315 |
|
delete $cmp->{delete} if $cmp->{delete}; |
316 |
|
} else { |
317 |
|
$cmp->{delete}++; |
318 |
|
} |
319 |
|
} elsif ( $repos->{$cmp->{repo}}->{orig} ) { |
320 |
|
$orig{$cmp->{nvra}}++; |
321 |
|
unless ( $repos->{$cmp->{repo}}->{base} ) { |
322 |
|
my $tag = dirname(dirname($cmp->{rpm}->{filename})); |
323 |
|
qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED"; |
324 |
|
} |
325 |
|
} elsif ( $cmp->{src} ) { |
326 |
|
if ( $cmp->{delete} && $cmp->{oldrepo} && $reposrc{$cmp->{oldrepo}}) { |
327 |
|
$cmp->{repo} = $cmp->{oldrepo}; |
328 |
|
delete $cmp->{delete}; |
329 |
|
} |
330 |
|
if ( $reposrc{$cmp->{repo}} ) { |
331 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
332 |
|
$srpm = $cmp if ! $srpm; |
333 |
|
} elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} && ! $cmp->{done} ) { |
334 |
|
$cmp->{delete}++; |
335 |
|
} |
336 |
|
} elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) { |
337 |
|
$cmp->{delete}++; |
338 |
|
} |
339 |
|
} elsif ( $cmp->{src} ) { |
340 |
|
if ( $reposrc{$cmp->{repo}} && $reposrc{$cmp->{repo}}->{srpm} && $reposrc{$cmp->{repo}}->{srpm}->{oldrepo} ne $cmp->{repo} ) { |
341 |
|
$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{src} = [ |
342 |
|
grep { $_ ne $reposrc{$cmp->{repo}}->{srpm} } @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{src}} |
343 |
|
]; |
344 |
|
|
345 |
|
if ( @{$reposrc{$cmp->{repo}}->{srpm}->{repos}} == 1 ) { |
346 |
|
$reposrc{$cmp->{repo}}->{srpm}->{repo} = $reposrc{$cmp->{repo}}->{srpm}->{oldrepo}; |
347 |
|
delete $reposrc{$cmp->{repo}}->{srpm}->{oldrepo}; |
348 |
|
delete $reposrc{$cmp->{repo}}->{srpm}->{delete}; |
349 |
|
delete $reposrc{$cmp->{repo}}->{srpm}->{repos}; |
350 |
|
delete $reposrc{$cmp->{repo}}->{srpm}->{done}; |
351 |
|
$seen{$cmp->{nvra}} = $cmp if $seen{$cmp->{nvra}} eq $reposrc{$cmp->{repo}}->{srpm}; |
352 |
|
} else { |
353 |
|
warn "How did I get here??"; |
354 |
|
} |
355 |
|
} else { |
356 |
|
$seen{$cmp->{nvra}} = $cmp if $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo}; |
357 |
|
} |
358 |
|
$srpm = $cmp if ! $srpm && $cmp->{src}; |
359 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp if $reposrc{$cmp->{repo}}; |
360 |
|
} |
361 |
|
} elsif ( $repos->{$cmp->{repo}}->{stage} ) { |
362 |
|
$cmp->{delete}++; |
363 |
|
} elsif ( $cmp->{src} || grep $_ eq $cmp->{rpm}->arch, @{$distrepo->{$ver}->{all_archs}} ) { |
364 |
|
$srpm = $cmp if ! $srpm && $cmp->{src}; |
365 |
|
my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2; |
366 |
|
$dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms}); |
367 |
|
$dest = $devel1 if verrel($cmp, $dest, \%counts); |
368 |
|
if ( $cmp->{repo} ne $dest ) { |
369 |
|
push @{$cmp->{repos}}, $dest; |
370 |
|
if ( $repos->{$cmp->{repo}}->{orig} ) { |
371 |
|
$orig{$cmp->{nvra}}++; |
372 |
|
unless ( $repos->{$cmp->{repo}}->{base} ) { |
373 |
|
my $tag = dirname(dirname($cmp->{rpm}->{filename})); |
374 |
|
qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED"; |
375 |
|
} |
376 |
|
} elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) { |
377 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
378 |
|
} else { |
379 |
|
$cmp->{delete}++; |
380 |
|
} |
381 |
|
$cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo}; |
382 |
|
$cmp->{repo} = $dest; |
383 |
|
if ( ! $cmp->{src} && $repos->{$dest}->{prio} > $repos->{$track{repo}}->{prio} ) { |
384 |
|
$track{repo} = $dest; |
385 |
|
$track{svr} = $cmp->{svr}; |
386 |
|
} |
387 |
|
} |
388 |
|
if ( $cmp->{src} && $reposrc{$cmp->{repo}} ) { |
389 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
390 |
|
} |
391 |
|
} |
392 |
|
} else { |
393 |
|
if ( $track{repo} eq $cmp->{repo} ) { |
394 |
|
if ( verrel($cmp, $cmp->{repo}, \%counts) ) { |
395 |
|
$cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base}; |
396 |
|
} elsif ( $cmp->{src} ) { |
397 |
|
$cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base}; |
398 |
|
} else { |
399 |
|
$track{svr} = $cmp->{svr}; |
400 |
|
} |
401 |
|
} elsif ( ! $repos->{$cmp->{repo}}->{base} ) { |
402 |
|
if ( $repos->{$cmp->{repo}}->{orig} ) { |
403 |
|
$srpm = $cmp if ! $srpm && $cmp->{src}; |
404 |
|
my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2; |
405 |
|
$dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms}); |
406 |
|
$dest = $devel1 if verrel($cmp, $dest, \%counts); |
407 |
|
unless ( $cmp->{src} && ! $reposrc{$dest} ) { |
408 |
|
if ( $repos->{$dest}->{prio} >= $repos->{$track{repo}}->{prio} && ! verrel($cmp, $dest, \%counts) ) { |
409 |
|
unless ( $repos->{$cmp->{repo}}->{base} ) { |
410 |
|
my $tag = dirname(dirname($cmp->{rpm}->{filename})); |
411 |
|
qx(touch $tag/PUSHED) if ! $opts{t} && -d $tag && ! -f "$tag/PUSHED"; |
412 |
|
} |
413 |
|
push @{$cmp->{repos}}, $dest; |
414 |
|
$cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo}; |
415 |
|
$cmp->{repo} = $dest; |
416 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp if $cmp->{src}; |
417 |
|
$orig{$cmp->{nvra}}++; |
418 |
|
} |
419 |
|
} |
420 |
|
} else { |
421 |
|
$cmp->{delete}++; |
422 |
|
} |
423 |
|
} |
424 |
|
} |
425 |
|
unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) { |
426 |
|
$pkgs{$cmp->{nvra}}++; |
427 |
|
$latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}}; |
428 |
|
$reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{src} || $repos->{$cmp->{repo}}->{stage}; |
429 |
|
if ( $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc} ) { |
430 |
|
$cmp->{latest}++ if ! $seen{$cmp->{nvra}} || $cmp->{src}; |
431 |
|
} |
432 |
|
$seen{$cmp->{nvra}} = $cmp unless $seen{$cmp->{nvra}}; |
433 |
|
push @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{$cmp->{src} ? 'src' : $cmp->{rpm}->arch}}, $cmp unless $cmp->{done}; |
434 |
|
} |
435 |
|
$cmp->{done}++; |
436 |
|
} |
437 |
|
if ( $srpm ) { |
438 |
|
foreach my $r ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %reposrc ) { |
439 |
|
unless ( $reposrc{$r}->{srpm} ) { |
440 |
|
unshift @{$srpm->{repos}}, $r; |
441 |
|
$srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo}; |
442 |
|
$srpm->{repo} = $r; |
443 |
|
$reposrc{$r}->{srpm} = $srpm; |
444 |
|
} |
445 |
|
} |
446 |
|
} elsif ( scalar keys %pkgs && $opts{s} ) { |
447 |
|
print "\n * missing source ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n"; |
448 |
|
} |
449 |
|
print "\n * missing originals ($disttag$ver, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs; |
450 |
|
} |
451 |
|
|
452 |
|
foreach my $r ( keys %$acnt ) { |
453 |
|
foreach my $p ( keys %{$acnt->{$r}} ) { |
454 |
|
foreach my $a ( keys %{$acnt->{$r}->{$p}} ) { |
455 |
|
if ( $a eq 'noarch' ) { |
456 |
|
my $p2 = ${$acnt->{$r}->{$p}->{$a}}[0]; |
457 |
|
if ( ! $p2->{repos} && scalar @{$acnt->{$r}->{$p}->{$a}} != scalar @{$distrepo->{$ver}->{'archs'}} ) { |
458 |
|
$p2->{oldrepo} = $p2->{repo}; |
459 |
|
push @{$p2->{repos}}, $p2->{repo}; |
460 |
|
} |
461 |
|
} elsif ( scalar @{$acnt->{$r}->{$p}->{$a}} != 1 ) { |
462 |
|
print "\n * many packages ($r, $a, $p)\n" unless ( ($p =~ m{^syslinux-nonlinux-[0-9]}) || ($p =~ m{^lib(mcrypt|webp)-[0-9]}) ) ; |
463 |
|
} |
464 |
|
} |
465 |
|
} |
466 |
|
} |
467 |
|
|
468 |
|
foreach my $pkg ( sort { $a->{nvra} cmp $b->{nvra} } @{$rpms->{$base}->{rpms}} ) { |
469 |
|
if ( $pkg->{latest} && $pkg->{latest} == 1 ) { |
470 |
|
unless ( grep { $_->{nvra} eq $pkg->{nvra} && $_->{repo} eq $stage } @{$rpms->{$base}->{rpms}} ) { |
471 |
|
$pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo}; |
472 |
|
$pkg->{repo} = $stage; |
473 |
|
push @{$pkg->{repos}}, $stage; |
474 |
|
} |
475 |
|
} |
476 |
|
|
477 |
|
if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) { |
478 |
|
print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n"; |
479 |
|
$print++; |
480 |
|
} |
481 |
|
|
482 |
|
my $src = $pkg->{rpm}->filename; |
483 |
|
if ( ! $repos->{$pkg->{repo}}->{base} && $pkg->{nosig} && $distrepo->{$ver}->{sign} ) { |
484 |
|
print "sign package (", basename($pkg->{rpm}->filename), ")\n"; |
485 |
|
unless ( $opts{t} ) { |
486 |
|
qx(cat $HOME/.rpmpass | setsid rpm -D '_gpg_name $distrepo->{$ver}->{keyname}' --addsign $src >& /dev/null); |
487 |
|
if ($?) { |
488 |
|
print " * failed to sign package\n"; |
489 |
|
next; |
490 |
|
} |
491 |
|
} |
492 |
|
} |
493 |
|
|
494 |
|
if ( $pkg->{repos} ) { |
495 |
|
foreach my $repo ( @{$pkg->{repos}} ) { |
496 |
|
if ( $pkg->{delete} ) { |
497 |
|
print "move from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n"; |
498 |
|
$pkg->{delete} = 0; |
499 |
|
$repochg{$pkg->{oldrepo}}++ unless $repos->{$pkg->{oldrepo}}->{base} || $repos->{$pkg->{oldrepo}}->{stage}; |
500 |
|
} elsif ( $pkg->{oldrepo} eq $repo ) { |
501 |
|
print "distribute noarch in $repo (", basename($pkg->{rpm}->filename), ")\n"; |
502 |
|
} else { |
503 |
|
print "copy from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n"; |
504 |
|
} |
505 |
|
$repochg{$repo}++ unless $repos->{$repo}->{base} || $repos->{$repo}->{stage}; |
506 |
|
$pkg->{oldrepo} = $repo unless $pkg->{oldrepo} eq ${$pkg->{repos}}[0]; |
507 |
|
|
508 |
|
my @d = (); |
509 |
|
my $head = $distrepo->{$ver}->{repo} . $repo . '/'; |
510 |
|
$head = $distrepo->{$ver}->{stage} if $repos->{$repo}->{stage}; |
511 |
|
my $tail = $repos->{$repo}->{os} ? "$osdir/" : 'RPMS/'; |
512 |
|
if ( $pkg->{src} ) { |
513 |
|
push @d, "${head}SRPMS/" . basename($pkg->{rpm}->filename); |
514 |
|
} elsif ( $pkg->{rpm}->arch eq 'noarch' ) { |
515 |
|
push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @{$distrepo->{$ver}->{'archs'}}; |
516 |
|
} elsif ($ver>=10 && $pkg->{rpm}->arch =~ m{^(i[356]86)$} && $pkg->{arch} =~ m{^(x86_64)$} ) { |
517 |
|
#add copy of i686 packages in x86_64 folder for SME>=10 |
518 |
|
push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @{$distrepo->{$ver}->{'archs'}}; |
519 |
|
} elsif ( $pkg->{rpm}->arch =~ m{^(i[356]86)$} ) { |
520 |
|
push @d, "${head}i386/$tail" . basename($pkg->{rpm}->filename); |
521 |
|
} else { |
522 |
|
push @d, $head . $pkg->{rpm}->arch . "/$tail" . basename($pkg->{rpm}->filename); |
523 |
|
} |
524 |
|
foreach my $dest ( @d ) { |
525 |
|
qx(cp --preserve=timestamps $src $dest) unless $opts{t} || -f "$dest"; |
526 |
|
} |
527 |
|
|
528 |
|
} |
529 |
|
qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t}; |
530 |
|
} elsif ( $pkg->{delete} ) { |
531 |
|
print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n"; |
532 |
|
qx(rm -f $src) unless $opts{t}; |
533 |
|
$repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage}; |
534 |
|
if ( $repos->{$pkg->{repo}}->{orig} && ! $repos->{$pkg->{repo}}->{base} ) { |
535 |
|
my $tag = dirname(dirname($pkg->{rpm}->{filename})); |
536 |
|
qx(rm -f $tag/PUSHED) if ! $opts{t} && -d $tag && -f "$tag/PUSHED"; |
537 |
|
} |
538 |
|
} |
539 |
|
} |
540 |
|
|
541 |
|
if ( $rpms->{$base}->{srpms} ) { |
542 |
|
foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{srpms}} ) { |
543 |
|
next if $pkg->{done} || $repos->{$pkg->{repo}}->{orig} || $repos->{$pkg->{repo}}->{base}; |
544 |
|
$pkg->{delete}++; |
545 |
|
my $src = $pkg->{rpm}->filename; |
546 |
|
if ( ! $print && ($pkg->{delete} || $pkg->{repos} || ( $pkg->{nosig} && $distrepo->{$ver}->{sign} ) ) ) { |
547 |
|
print "\n$base ($disttag$ver)\n", "=" x length("$base ($disttag$ver)"), "\n"; |
548 |
|
$print++; |
549 |
|
} |
550 |
|
print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n"; |
551 |
|
qx(rm -f $src) unless $opts{t}; |
552 |
|
$repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage}; |
553 |
|
} |
554 |
|
} |
555 |
|
} |
556 |
|
|
557 |
|
if ( %repochg ) { |
558 |
|
print "\nrebuild repo ($disttag$ver)\n", "=" x length("rebuild repo ($disttag$ver)"), "\n"; |
559 |
|
} |
560 |
|
foreach my $repo ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %repochg ) { |
561 |
|
next if $repos->{$repo}->{orig} || $repos->{$repo}->{stage}; |
562 |
|
foreach my $arch ( @{$distrepo->{$ver}->{'archs'}} ) { |
563 |
|
my $dir = $distrepo->{$ver}->{repo} . "$repo/$arch"; |
564 |
|
$dir = qx(readlink -f $dir); |
565 |
|
if ( $dir ) { |
566 |
|
chomp $dir; |
567 |
|
} else { |
568 |
|
$dir = $distrepo->{$ver}->{repo} . "$repo/$arch"; |
569 |
|
} |
570 |
|
print "rebuild $repo/$arch\n"; |
571 |
|
unless ( $opts{t} ) { |
572 |
|
my $checksum = "--checksum $distrepo->{$ver}->{checksum}"; |
573 |
|
|
574 |
|
my $exclude = ""; |
575 |
|
$exclude .= " --exclude ${osdir}/*" if ( -d "$dir/Packages" && ${osdir} ne "Packages" ); |
576 |
|
$exclude .= " --exclude *smeserver-release*.rpm" if $dir =~ m{test/|-testing/}; |
577 |
|
|
578 |
|
my $groupfile = ""; |
579 |
|
$groupfile = "--simple-md-filenames --groupfile repodata/comps.xml" if -f "$dir/repodata/comps.xml"; |
580 |
|
|
581 |
|
qx(createrepo --update --database --exclude *.src.rpm --exclude *-debuginfo-*.rpm $checksum $exclude $groupfile $dir); |
582 |
|
qx(repoview $dir); |
583 |
|
|
584 |
|
qx(rm -rf $dir/.olddata) if -d "$dir/.olddata"; |
585 |
|
qx(rm -rf $dir/.repodata) if -d "$dir/.repodata"; |
586 |
|
qx(rm -rf $dir/repodata/index.html) if -f "$dir/repodata/index.html"; |
587 |
|
qx(rm -rf $dir/repodata/update-info) if -d "$dir/repodata/update-info"; |
588 |
|
qx(rm -rf $dir/repodata/repoview) if -d "$dir/repodata/repoview"; |
589 |
|
} |
590 |
|
} |
591 |
|
} |
592 |
|
unless ( $opts{t} ) { |
593 |
|
foreach (@{$distrepo->{$ver}->{'builds'}}) |
594 |
|
{ |
595 |
|
finddepth(sub{rmdir}, "$_") if -d "$_"; |
596 |
|
} |
597 |
|
finddepth(sub{rmdir}, $distrepo->{$ver}->{'community'}) if -d "$distrepo->{$ver}->{'community'}"; |
598 |
} |
} |
|
printline('white', 0, 'Base (Centos: ', $distrepo->{$smever}->{centos}, ', Fedora: ', $distrepo->{$smever}->{fedora}, ") packages loaded.\n"); |
|
|
|
|
|
%latest = (); |
|
|
foreach my $name ( sort keys %{{ map { $_->{base} => 1 } @rpms }} ) { |
|
|
printline('white', 0, "Processing: $name"); |
|
|
my @pkgs = sort pkgsrt grep { $_->{base} eq $name } @rpms; |
|
|
my %seen = (); |
|
|
my $count = (); |
|
|
$archs = (); |
|
|
|
|
|
foreach my $pkg ( @pkgs ) { |
|
|
next if $pkg->{done} || $pkg->{obsolete} || $pkg->{rpm}->is_source_package || ! $repos->{$pkg->{repo}}; |
|
|
printline('bold black', 1, ' - ', $pkg->{rpm}->filename) if $opts{d}; |
|
|
my $orig = 0; |
|
|
|
|
|
# Find names of packages in same or higher repos |
|
|
my %names = names($pkg, @pkgs); |
|
|
|
|
|
# Stage packages should never be most current |
|
|
if ( rprop($pkg, 'stage') ) { |
|
|
tagpkg($pkg, 'obsolete'); |
|
|
next; |
|
|
} |
|
|
|
|
|
# Move packages from base/builds to correct area |
|
|
elsif ( rprop($pkg, 'base') || rprop($pkg, 'builds') ) { |
|
|
printline('dark blue', 1, ' - checking base/builds') if $opts{d}; |
|
|
my $repo = $names{$pkg->{name}} && $names{$pkg->{name}} > 1 ? $devel2 : $devel1; |
|
|
if ( $pkg->{nonbase} ) { |
|
|
foreach my $up ( @pkgs ) { |
|
|
next if rprop($up, 'builds') || rprop($up, 'base'); |
|
|
next if $up->{name} ne $pkg->{name} || ! $up->{obsolete} || $up->{rpm} ge $pkg->{rpm}; |
|
|
$repo = $up->{repo}; |
|
|
last; |
|
|
} |
|
|
} |
|
|
next if rprop($pkg, 'base') && $repo eq $devel1 && $devel1 ne $devel2; |
|
|
movepkg($pkg, $repo); |
|
|
%names = names($pkg, @pkgs); |
|
|
$seen{$pkg->{nvra}}++; |
|
|
$orig++; |
|
|
} |
|
|
|
|
|
# Check version/release counts |
|
|
unless ( $pkg->{nonbase} ) { |
|
|
printline('dark blue', 1, ' - checking version/release counts') if $opts{d}; |
|
|
$count->{$pkg->{repo}}->{$pkg->{version}}->{$pkg->{release}}++; |
|
|
if ( rprop($pkg, 'ver') && scalar keys %{$count->{$pkg->{repo}}} > rprop($pkg, 'ver') ) { |
|
|
movepkg($_, 'delete') foreach grep { $_->{rpm} eq $pkg->{rpm} } @pkgs; |
|
|
next; |
|
|
} |
|
|
if ( rprop($pkg, 'rel') && scalar keys %{$count->{$pkg->{repo}}->{$pkg->{version}}} > rprop($pkg, 'rel') ) { |
|
|
movepkg($_, 'delete') foreach grep { $_->{rpm} eq $pkg->{rpm} } @pkgs; |
|
|
next; |
|
|
} |
|
|
} |
|
|
|
|
|
foreach my $cmp ( grep { $_->{rpm}->is_source_package || ( ! $_->{done} && $_->{rpm} le $pkg->{rpm} && rprop($_, 'prio') <= rprop($pkg, 'prio') ) } @pkgs ) { |
|
|
printline('dark blue', 1, ' - ', $cmp->{rpm}->filename) if $opts{d}; |
|
|
if ( $cmp->{rpm}->is_source_package ) { |
|
|
if ( $cmp->{name} eq $pkg->{base} ) { |
|
|
if ( $cmp->{rpm} eq $pkg->{rpm} ) { |
|
|
if ( $pkg->{repo} eq $cmp->{repo} || ! $pkg->{srpm} || $pkg->{srpm}->{rpm} ne $pkg->{rpm} ) { |
|
|
delete $pkg->{srpm}->{latest} if $pkg->{latest} && $pkg->{srpm} && $pkg->{srpm}->{latest}; |
|
|
$pkg->{srpm} = $cmp; |
|
|
$pkg->{srpm}->{latest}++ if $pkg->{latest}; |
|
|
} |
|
|
if ( $pkg->{latest} && rprop($cmp, 'stage') ) { |
|
|
tagpkg($cmp, 'inuse'); |
|
|
$pkg->{srpm}->{latest}++; |
|
|
} |
|
|
tagpkg($cmp, 'inuse') if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds'); |
|
|
} |
|
|
next if $pkg->{srpm} && $pkg->{srpm}->{rpm} eq $pkg->{rpm}; |
|
|
|
|
|
my $src = $pkg->{rpm}->sourcerpm; |
|
|
my $source = basename $cmp->{rpm}->filename; |
|
|
SRC: { |
|
|
$src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d\.at(\.src)}{$1} && $src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d(\.rf\.src)}{$1} && $src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{(\d+)\.\d+\.el\d(\.rf\.src)}{$1$2} && $src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d\.rf(\.src)}{.dag$1} && $src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{(\d+)\.\d+\.el\d\.rf(\.src)}{$1.dag$2} && $src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d(\.src)}{$1} && $src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{(-\d+)\.\d+\.el\d(\.src)}{$1$2} && $src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{\.centos\d(\.src)}{$1} && $src eq $source && last SRC; |
|
|
($src = $pkg->{rpm}->sourcerpm) =~ s{\.el\d\.sme(\.src)}{$1} && $src eq $source && last SRC; |
|
|
$src = ''; |
|
|
} |
|
|
if ( $src eq $source && ( ! $pkg->{srpm} || $pkg->{srpm}->{rpm} eq $cmp->{rpm} ) ) { |
|
|
if ( ! $pkg->{srpm} || $pkg->{repo} eq $cmp->{repo} ) { |
|
|
delete $pkg->{srpm}->{latest} if $pkg->{latest} && $pkg->{srpm} && $pkg->{srpm}->{latest}; |
|
|
$pkg->{srpm} = $cmp; |
|
|
$pkg->{srpm}->{latest}++ if $pkg->{latest}; |
|
|
} |
|
|
if ( $pkg->{latest} && rprop($cmp, 'stage') ) { |
|
|
tagpkg($cmp, 'inuse'); |
|
|
$pkg->{srpm}->{latest}++; |
|
|
} |
|
|
tagpkg($cmp, 'inuse') if $pkg->{repo} eq $cmp->{repo} || rprop($cmp, 'base') || rprop($cmp, 'builds'); |
|
|
} |
|
|
} |
|
|
} elsif ( $cmp->{rpm} eq $pkg->{rpm} ) { |
|
|
if ( $names{$cmp->{name}} ) { |
|
|
if ( $pkg->{repo} eq $cmp->{repo} ) { |
|
|
tagpkg($cmp, 'correct', 1); |
|
|
$seen{$cmp->{nvra}}++; |
|
|
} elsif ( $seen{$cmp->{nvra}} && rprop($cmp, 'stage') && $pkg->{latest} ) { |
|
|
$_->{latest}++ foreach grep { $_->{nvra} eq $cmp->{nvra} && $_->{latest} && $_->{done} } @pkgs; |
|
|
tagpkg($cmp, 'correct', 1); |
|
|
} elsif ( $seen{$cmp->{nvra}} ) { |
|
|
$orig++ if rprop($cmp, 'base') || rprop($cmp, 'builds'); |
|
|
movepkg($cmp, 'delete', 1); |
|
|
} else { |
|
|
movepkg($cmp, $pkg->{repo}, 1, 1); |
|
|
$seen{$cmp->{nvra}}++; |
|
|
} |
|
|
} else { |
|
|
tagpkg($cmp, 'nonbase'); |
|
|
} |
|
|
} elsif ( rprop($cmp, 'prio') < rprop($pkg, 'prio') ) { |
|
|
tagpkg($cmp, 'obsolete'); |
|
|
} |
|
|
} |
|
|
printline('dark blue', 1, ' - checking source packages') if $opts{d}; |
|
|
if ( ! $pkg->{srpm} ) { |
|
|
printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (missing source ', $pkg->{rpm}->sourcerpm, ')'); |
|
|
} elsif ( $pkg->{srpm}->{repo} ne $pkg->{repo} ) { |
|
|
movepkg($pkg->{srpm}, $pkg->{repo}, 0); |
|
|
} |
|
|
unless ( $orig ) { |
|
|
foreach ( grep { $_->{base} eq $pkg->{base} && $_->{repo} eq $pkg->{repo} } @pkgs ) { |
|
|
printline('bold yellow on_red', 1, ' - ', $_->{rpm}->filename, ' (missing original)'); |
|
|
} |
|
|
} |
|
|
} |
|
|
printline('bold black', 1, ' - missing stage packages') if $opts{d}; |
|
|
movepkg($_, $stage, 0) foreach grep { $_->{latest} && $_->{latest} == 1 } @pkgs; |
|
|
|
|
|
printline('bold black', 1, ' - obsolete packages') if $opts{d}; |
|
|
movepkg($_, 'delete') foreach grep { ! rprop($_, 'base') && ! $_->{done} && ( $_->{obsolete} || ( $_->{rpm}->is_source_package && ! $_->{inuse} ) ) } @pkgs; |
|
|
|
|
|
printline('bold black', 1, ' - arch count check') if $opts{d}; |
|
|
foreach my $r ( keys %$archs ) { |
|
|
foreach my $p ( keys %{$archs->{$r}} ) { |
|
|
foreach my $a ( keys %{$archs->{$r}->{$p}} ) { |
|
|
my $p2 = ${$archs->{$r}->{$p}->{$a}}[0]; |
|
|
if ( $a eq 'noarch' ) { |
|
|
movepkg($p2, $p2->{repo}, 0) if ! $p2->{repos} && scalar @{$archs->{$r}->{$p}->{$a}} != scalar @archs; |
|
|
} elsif ( scalar @{$archs->{$r}->{$p}->{$a}} != 1 ) { |
|
|
printline('bold yellow on_red', 1, ' - ', $p2->{rpm}->filename, ' (many arch)'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
printline('white', 0, "Finished processing.\n"); |
|
|
|
|
|
unless ( $opts{t} || $opts{r} ) { |
|
|
my %repochg = (); |
|
|
# Move / Copy / Delete packages and tag repo for rebuild. |
|
|
foreach my $pkg ( grep { $_->{oldrepo} } @rpms ) { |
|
|
printline('white', 0, 'Copy/move: ', $pkg->{rpm}->filename); |
|
|
my $src = $pkg->{rpm}->filename; |
|
|
|
|
|
qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null) if $pkg->{nosig}; |
|
|
if ( $pkg->{repos} ) { |
|
|
foreach my $dest ( dest($pkg, @{$pkg->{repos}}) ) { |
|
|
qx(cp --preserve=timestamps $src $dest) unless -f "$dest"; |
|
|
} |
|
|
$repochg{$_}++ foreach @{$pkg->{repos}}; |
|
|
} |
|
|
if ( $pkg->{remove} ) { |
|
|
qx(rm -f $src); |
|
|
$repochg{$pkg->{oldrepo}}++; |
|
|
} |
|
|
} |
|
|
finddepth(sub{rmdir}, $distrepo->{$rel}->{builds}); |
|
|
printline('white', 0, "Finished copying/moving.\n"); |
|
|
|
|
|
foreach my $repo ( sort keys %repochg ) { |
|
|
next if ! $repos->{$repo} || $repos->{$repo}->{base} || $repos->{$repo}->{builds} || $repos->{$repo}->{stage}; |
|
|
foreach my $arch ( @archs ) { |
|
|
my $dir = $distrepo->{$rel}->{repo} . "$repo/$arch"; |
|
|
$dir = qx(readlink -f $dir); |
|
|
chomp $dir; |
|
|
printline('white', 0, "Createrepo: $repo/$arch"); |
|
|
qx(createrepo $dir); |
|
|
printline('white', 0, "Repoview: $repo/$arch"); |
|
|
qx(repoview $dir); |
|
|
qx(rm -rf $dir/.olddata) if -d "$dir/.olddata"; |
|
|
qx(rm -rf $dir/.repodata) if -d "$dir/.repodata"; |
|
|
} |
|
|
} |
|
|
printline('white', 0, "Finished rebuilding repos.\n"); |
|
|
} |
|
|
|
|
|
print "\n================================================================================\n\n"; |
|
|
} |
|
|
|
|
|
sub pkgsrt { |
|
|
return $a->{rpm}->is_source_package <=> $b->{rpm}->is_source_package || $b->{rpm} cmp $a->{rpm} || rprop($b, 'prio') <=> rprop($a, 'prio'); |
|
599 |
} |
} |
600 |
|
|
601 |
sub rprop { |
sub verrel { |
|
my ($pkg, $prop) = @_; |
|
|
return $repos->{$pkg->{repo}} ? $repos->{$pkg->{repo}}->{$prop} : 0; |
|
|
} |
|
|
|
|
|
sub names { |
|
602 |
my $pkg = shift; |
my $pkg = shift; |
603 |
my @rpms = @_; |
my $repo = shift; |
604 |
return map { $_->{name} => rprop($_, 'inc') ? 2 : 1 } grep { $_->{base} eq $pkg->{base} && |
my $counts = shift; |
|
rprop($_, 'prio') >= rprop($pkg, 'prio') && |
|
|
! rprop($_, 'base') && |
|
|
! rprop($_, 'builds') && |
|
|
! $_->{rpm}->is_source_package |
|
|
} @rpms; |
|
|
} |
|
605 |
|
|
606 |
sub dest { |
return 0 if $pkg->{src}; |
607 |
my ($pkg, @repos) = @_; |
$counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++; |
608 |
my @d = (); |
return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver}; |
609 |
foreach my $repo ( @repos ) { |
return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel}; |
610 |
my $base = $distrepo->{$rel}->{repo} . $repo; |
return 0; |
|
$base = $distrepo->{$rel}->{stage} if $repos->{$repo}->{stage}; |
|
|
if ( $pkg->{arch} eq 'noarch' ) { |
|
|
push @d, "$base/i386/" . |
|
|
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
|
|
basename $pkg->{rpm}->filename; |
|
|
push @d, "$base/x86_64/" . |
|
|
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
|
|
basename $pkg->{rpm}->filename; |
|
|
} elsif ( $pkg->{arch} =~ m{^(i[356]86)$} ) { |
|
|
push @d, "$base/i386/" . |
|
|
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
|
|
basename $pkg->{rpm}->filename; |
|
|
} elsif ( $pkg->{arch} eq 'x86_64' ) { |
|
|
push @d, "$base/x86_64/" . |
|
|
( $repos->{$repo}->{os} ? $distrepo->{$rel}->{os} : 'RPMS/' ) . |
|
|
basename $pkg->{rpm}->filename; |
|
|
} elsif ( $pkg->{arch} eq 'zsrc' ) { |
|
|
push @d, "$base/SRPMS/" . |
|
|
basename $pkg->{rpm}->filename; |
|
|
} else { |
|
|
printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (bad arch: ', $pkg->{arch}, ')'); |
|
|
} |
|
|
} |
|
|
return @d; |
|
611 |
} |
} |
612 |
|
|
613 |
sub movepkg { |
sub pkgdest { |
|
my ($pkg, $repo, $done, $remove) = @_; |
|
|
defined $done or $done = 2; |
|
|
defined $remove or $remove = 0; |
|
|
$remove = 0 if rprop($pkg, 'base') || rprop($pkg, 'builds'); |
|
|
$remove = 1 if $repo eq 'delete'; |
|
|
|
|
|
if ( $repo eq 'delete' && ( rprop($pkg, 'base') || ( rprop($pkg, 'builds') && $done == 1 ) ) ) { |
|
|
tagpkg($pkg, 'inuse', 1); |
|
|
} else { |
|
|
printline('bold magenta', 1, " - ($repo) ", $pkg->{rpm}->filename) if $opts{d}; |
|
|
my $color = 'bold white'; |
|
|
$color = 'bold yellow' if rprop($pkg, 'builds'); |
|
|
$color = 'dark green' if $repos->{$repo} && $repos->{$repo}->{devel}; |
|
|
$color = 'dark red' if $repo eq 'delete'; |
|
|
push @{$pkg->{repos}}, $repo unless $repo eq 'delete'; |
|
|
$pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo}; |
|
|
$pkg->{repo} = $repo; |
|
|
$pkg->{remove}++ if $remove; |
|
|
printline($color, 1, ' - ', $pkg->{rpm}->filename, ' (', $pkg->{oldrepo}, " to $repo)") if $opts{v} || $opts{d}; |
|
|
done($pkg) if $done; |
|
|
} |
|
|
} |
|
|
|
|
|
sub tagpkg { |
|
|
my ($pkg, $tag, $done) = @_; |
|
|
defined $done or $done = 0; |
|
|
|
|
|
printline('bold magenta', 1, " - ($tag) ", $pkg->{rpm}->filename) if $opts{d}; |
|
|
delete $pkg->{obsolete} if $pkg->{obsolete}; |
|
|
$pkg->{$tag}++; |
|
|
done($pkg) if $done; |
|
|
} |
|
|
|
|
|
sub done { |
|
614 |
my $pkg = shift; |
my $pkg = shift; |
615 |
printline('bold yellow on_red', 1, " - ", $pkg->{rpm}->filename, " (already processed)") if $pkg->{done}; |
my $dest = shift; |
616 |
$pkg->{done}++; |
my $hirepo = shift; |
617 |
delete $pkg->{obsolete} if $pkg->{obsolete}; |
my $pkgs = shift; |
618 |
|
|
619 |
if ( $repos->{$pkg->{repo}} && ! rprop($pkg, 'base') && ! rprop($pkg, 'builds') ) { |
foreach my $cmp ( @$pkgs ) { |
620 |
# FIXME: Nasty hack for comps package |
next if $cmp->{src} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio}; |
621 |
if ( $pkg->{name} eq 'comps' ) { |
next if $pkg->{name} ne ( $pkg->{src} ? $cmp->{base} : $cmp->{name} ); |
622 |
if ( ! $latest{$pkg->{name}.'.'.$pkg->{arch}} || $latest{$pkg->{name}.'.'.$pkg->{arch}}->{rpm} eq $pkg->{rpm} ) { |
if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) { |
623 |
if ( rprop($pkg, 'inc') && ! $pkg->{rpm}->is_source_package ) { |
$dest = $hirepo; |
624 |
$latest{$pkg->{name}.'.'.$pkg->{arch}} = $pkg if ! $latest{$pkg->{name}.'.'.$pkg->{arch}}; |
last; |
625 |
$pkg->{latest}++; |
} else { |
626 |
} |
$dest = $cmp->{repo}; |
627 |
} |
} |
628 |
} elsif ( ! $latest{$pkg->{name}} || $latest{$pkg->{name}}->{rpm} eq $pkg->{rpm} ) { |
} |
629 |
if ( rprop($pkg, 'inc') && ! $pkg->{rpm}->is_source_package ) { |
return $dest; |
630 |
$latest{$pkg->{name}} = $pkg if ! $latest{$pkg->{name}}; |
} |
631 |
$pkg->{latest}++; |
|
632 |
} |
sub process_rpm { |
633 |
} |
my $rpm = shift; |
634 |
unless ( $pkg->{oldrepo} ) { |
my $ver = shift; |
635 |
my $goodarch = 0; |
my $repo = shift; |
636 |
$goodarch++ if $pkg->{rpm}->filename =~ m{/(i386|x86_64)/.*\.noarch\.rpm$}; |
return unless $rpm =~ m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$}; |
637 |
$goodarch++ if $pkg->{rpm}->filename =~ m{/i386/.*\.(i[56]86)\.rpm$}; |
my $base = $1; |
638 |
$goodarch++ if $pkg->{rpm}->filename =~ m{/(noarch|i[356]86|x86_64)/.*\.\1\.rpm$}; |
return unless ! $opts{r} || $base =~ m[$opts{r}]; |
639 |
printline('bold yellow on_red', 1, ' - ', $pkg->{rpm}->filename, ' (wrong arch)') unless $goodarch; |
return unless $latest{$base} || $sources{$base} || ! $repos->{$repo}->{base}; |
|
} |
|
|
push @{$archs->{$pkg->{repo}}->{$pkg->{rpm}->as_nvre}->{$pkg->{rpm}->is_source_package ? 'src' : $pkg->{rpm}->arch}}, $pkg; |
|
|
} |
|
|
} |
|
|
|
|
|
sub printline { |
|
|
my $color = shift; |
|
|
my $nline = shift; |
|
|
my $string = join '', @_; |
|
|
|
|
|
if ( $nline ) { |
|
|
print "\n" unless $newline; |
|
|
$newline++; |
|
|
} else { |
|
|
$newline = 0; |
|
|
print "\r\e[0K"; |
|
|
} |
|
|
print color $color; |
|
|
print $string; |
|
|
print color 'reset'; |
|
|
print "\n" if $nline; |
|
|
} |
|
|
|
|
|
sub loadpkg { |
|
|
printline('white', 0, "Loading: $_") if -d _; |
|
|
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ( ! $opts{r} || $1 =~ m{$opts{r}} ); |
|
640 |
|
|
641 |
my $pkg; |
my $pkg; |
642 |
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
eval { $pkg = RPM2->open_package($rpm, $rpm_flags); }; |
643 |
if ($@) { printline('bold yellow on_red', 1, "Corrupt package $_"); return; } |
if ($@) { print " * corrupt package ($rpm)\n"; return; } |
644 |
eval { my $sig = $pkg->siggpg }; |
eval { my $sig = $pkg->siggpg }; |
|
my $nosig = ! $@; |
|
|
if ( $nosig && ! -f "$HOME/.rpmpass" ) { |
|
|
printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); |
|
|
return; |
|
|
} |
|
|
|
|
|
my ($srcname, $version, $release) = ($pkg->is_source_package ? basename $pkg->filename : $pkg->sourcerpm) =~ m{^([^/]*)-([^-]+)-([^-]+)\.\w+.rpm}; |
|
|
foreach my $repo ( keys %{$skippkg->{$rel}} ) { return if (dirname $pkg->filename) =~ m{/$repo/} && grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; } |
|
|
my $reponame = 'unknown'; |
|
|
if ( substr($_, 0, length($distrepo->{$rel}->{builds})) eq $distrepo->{$rel}->{builds} ) { |
|
|
$reponame = 'builds'; |
|
|
} elsif ( substr($_, 0, length($distrepo->{$rel}->{stage})) eq $distrepo->{$rel}->{stage} ) { |
|
|
$reponame = 'stage'; |
|
|
} elsif ( (dirname $pkg->filename) =~ m{\d/(sme[^/]+)/} ) { |
|
|
$reponame = $1; |
|
|
} |
|
|
|
|
|
push @rpms, { base => $srcname, |
|
|
name => $pkg->name, |
|
|
repo => $reponame, |
|
|
nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ), |
|
|
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
|
|
version => $version, |
|
|
release => $release, |
|
|
rpm => $pkg, |
|
|
nosig => $nosig, |
|
|
}; |
|
|
$sources{$srcname}++; |
|
|
$latest{$pkg->name} = $rpms[$#rpms] if ! $pkg->is_source_package && ( ! $latest{$pkg->name} || $pkg gt $latest{$pkg->name}->{rpm} ); |
|
|
} |
|
645 |
|
|
646 |
sub loadbase { |
my $nosig = 1; |
647 |
printline('white', 0, "Loading: $_") if -d _; |
eval { my $sig = $pkg->dsaheader }; $nosig &= ! $@; |
648 |
return unless m{/([^/]*)-[^-]+-[^-]+\.\w+.rpm} && ($latest{$1} || $sources{$1}); |
eval { my $sig = $pkg->rsaheader }; $nosig &= ! $@; |
649 |
|
eval { my $sig = $pkg->siggpg }; $nosig &= ! $@; |
650 |
my $pkg; |
eval { my $sig = $pkg->sigpgp }; $nosig &= ! $@; |
|
eval { $pkg = RPM2->open_package($_, $rpm_flags); }; |
|
|
if ($@) { printline('bold yellow on_red', 1, "Corrupt package $_"); return; } |
|
|
eval { my $sig = $pkg->siggpg }; |
|
|
unless ($@) { printline('bold yellow on_red', 1, ' - ', $pkg->filename, ' (missing signature)'); return; } |
|
651 |
|
|
652 |
my $cmp = $latest{$pkg->name}; |
my $cmp = $latest{$pkg->name}; |
653 |
my ($srcname, $version, $release) = ($pkg->is_source_package ? basename $pkg->filename : $pkg->sourcerpm) =~ m{^([^/]*)-([^-]+)-([^-]+)\.\w+.rpm}; |
if ( $repos->{$repo}->{base} && ! $pkg->is_source_package ) { |
654 |
my $pkgrepo = 'base'; |
return unless $cmp; |
655 |
foreach my $repo ( keys %{$skippkg->{$rel}} ) { |
return if $repos->{$cmp->{repo}}->{base} && $repos->{$cmp->{repo}}->{prio} > $repos->{$repo}->{prio} && $pkg ge $cmp->{rpm}; |
656 |
if ( (dirname $pkg->filename) =~ m{/$repo/} ) { |
} |
657 |
return if grep { $_ eq $srcname } @{$skippkg->{$rel}->{$repo}}; |
my ($src, $version, $release) = ($pkg->is_source_package ? $pkg->filename : $pkg->sourcerpm) =~ m{(?:^|/)([^/]*)-([^-]+)-([^-]+)\.\w+\.rpm$}; |
658 |
$pkgrepo = $repo; |
return if $skippkg->{$ver}->{$repo} && ( $skippkg->{$ver}->{$repo}->{$src} || $skippkg->{$ver}->{$repo}->{$pkg->name} ); |
659 |
return unless $pkg->is_source_package || $cmp; |
return if $onlypkg->{$ver}->{$repo} && !( $onlypkg->{$ver}->{$repo}->{$src} || $onlypkg->{$ver}->{$repo}->{$pkg->name} ); |
660 |
return if ! $pkg->is_source_package && $pkg gt $cmp->{rpm} && rprop($cmp, 'base') && rprop($cmp, 'prio') > $repos->{$pkgrepo}->{prio}; |
return if $repos->{$repo}->{base} && $nosig && $baserepo->{$ver}->{sign}; |
661 |
last; |
if ( $nosig && ! -f "$HOME/.rpmpass" ) { print " * missing signature (" .$pkg->filename . ")\n"; return; } |
662 |
} |
my $arch = 'unknown'; |
663 |
|
$arch = 'SRPMS' if $pkg->filename =~ m{[/-](SRPMS?|src|source)/}; |
664 |
|
$arch = 'x86_64' if $pkg->filename =~ m{[/-]x86_64/}; |
665 |
|
$arch = 'i386' if $pkg->filename =~ m{[/-](i[356]86)/}; |
666 |
|
$arch = 'noarch' if $pkg->filename =~ m{[/-]noarch/}; |
667 |
|
|
668 |
|
my $rpmhash = { base => $src, |
669 |
|
name => $pkg->name, |
670 |
|
repo => $repo, |
671 |
|
nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ), |
672 |
|
svr => $src.'-'.$version.'-'.$release, |
673 |
|
src => $pkg->is_source_package, |
674 |
|
arch => $arch, |
675 |
|
ver => $version, |
676 |
|
rel => $release, |
677 |
|
rpm => $pkg, |
678 |
|
nosig => $nosig, |
679 |
|
}; |
680 |
|
if ( $pkg->is_source_package ) { |
681 |
|
push @{$rpms->{$src}->{srpms}}, $rpmhash; |
682 |
|
push @{$rpms->{$src}->{vers}->{$rpmhash->{svr}}}, $rpmhash; |
683 |
|
} else { |
684 |
|
push @{$rpms->{$src}->{rpms}}, $rpmhash; |
685 |
} |
} |
686 |
|
$sources{$src}++; |
687 |
|
|
688 |
push @rpms, { base => $srcname, |
return if $pkg->is_source_package || $repos->{$repo}->{stage}; |
689 |
name => $pkg->name, |
if ( ! $repos->{$repo}->{base} ) { |
690 |
repo => $pkgrepo, |
if ( ! $cmp || $pkg gt $cmp->{rpm} ) { |
691 |
nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ), |
$latest{$pkg->name} = $rpmhash; |
692 |
arch => $pkg->is_source_package ? 'zsrc' : $pkg->tag('ARCH'), |
} |
693 |
version => $version, |
} elsif ( ( $repos->{$repo}->{prio} >= $repos->{$cmp->{repo}}->{prio} || ! $repos->{$cmp->{repo}}->{base} ) && $pkg ge $cmp->{rpm} ) { |
694 |
release => $release, |
$latest{$pkg->name} = $rpmhash; |
|
rpm => $pkg, |
|
|
nosig => 0, |
|
|
}; |
|
|
if ( ! $pkg->is_source_package && $pkg ge $cmp->{rpm} && ( $repos->{$pkgrepo}->{prio} >= rprop($cmp, 'prio') || ! rprop($cmp, 'base') ) ) { |
|
|
$latest{$pkg->name} = $rpms[$#rpms]; |
|
695 |
} |
} |
696 |
} |
} |
|
|
|