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