3 |
use strict; |
use strict; |
4 |
use warnings; |
use warnings; |
5 |
use RPM2; |
use RPM2; |
6 |
|
use File::Find; |
7 |
|
use File::Basename; |
8 |
|
use Getopt::Std; |
9 |
use Data::Dumper; |
use Data::Dumper; |
10 |
|
|
11 |
sub compare($$); |
delete $ENV{PATH}; |
12 |
|
my $HOME=$ENV{HOME}; |
13 |
my $releases = 2; |
umask 002; |
14 |
|
$| = 1; |
15 |
my $releasedir = '/releases'; |
|
16 |
my $smerel = '7'; |
my %opts; |
17 |
my $centosrel = '4'; |
getopts( 'osqtr:', \%opts ); |
18 |
my $fedorarel = '3'; |
$opts{r} ||= ''; |
19 |
my $builds = '/builds/rpms'; |
|
20 |
my $stagedir = '/builds'; |
my $rpm_flags = RPM2->vsf_nosha1header | RPM2->vsf_nomd5header | RPM2->vsf_nodsaheader | RPM2->vsf_norsaheader; |
21 |
my $arch = `uname -i`; |
$rpm_flags |= RPM2->vsf_nosha1 | RPM2->vsf_nomd5 | RPM2->vsf_nodsa | RPM2->vsf_norsa; |
22 |
chomp $arch; |
|
23 |
|
my @archs = ( 'i386', 'x86_64' ); |
24 |
my @repos = ( |
|
25 |
"$releasedir/$smerel/smeos/$arch/CentOS/RPMS", |
my $distrepo = { '7' => { active => 1, |
26 |
"$releasedir/$smerel/smeos/$arch/SME/RPMS", |
centos => 4, |
27 |
"$releasedir/$smerel/smeos/$arch/RPMS", |
fedora => 3, |
28 |
"$releasedir/$smerel/smeos/$arch/SME", |
repo => '/releases/7/', |
29 |
"$releasedir/$smerel/smeupdates/$arch/RPMS", |
os => 'RPMS/', |
30 |
"$releasedir/$smerel/smeupdates-testing/$arch/RPMS", |
builds => '/builds/smeserver-7-core/', |
31 |
"$releasedir/$smerel/smeextras/$arch/RPMS", |
contribs => '/builds/smeserver-7-contribs/', |
32 |
"$releasedir/$smerel/smeaddons/$arch/RPMS", |
stage => '/stage/7/', |
33 |
"$releasedir/$smerel/smecontribs/$arch/RPMS", |
}, |
34 |
"$releasedir/$smerel/smetest/$arch/RPMS", |
'8' => { active => 1, |
35 |
"$releasedir/$smerel/smedev/$arch/RPMS", |
centos => 5, |
36 |
"$builds/RPMS/$arch", |
fedora => 6, |
37 |
"$builds/RPMS/i586", |
repo => '/releases/testing/8/', |
38 |
"$builds/RPMS/i686", |
os => '', |
39 |
"$builds/RPMS/noarch", |
builds => '/builds/smeserver-8-core/', |
40 |
"$stagedir/RPMS", |
contribs => '/builds/smeserver-8-contribs/', |
41 |
); |
stage => '/stage/8/', |
42 |
|
}, |
43 |
my @srcrepos = ( |
}; |
44 |
"/mirrors/centos/$centosrel/fasttrack/SRPMS", |
|
45 |
"/mirrors/centos/$centosrel/updates/SRPMS", |
my $repos = { 'smeos' => { prio => 18, inc => 1, ver => 1, rel => 1, os => 1 }, |
46 |
"/mirrors/centos/$centosrel/os/SRPMS", |
'smeupdates' => { prio => 17, inc => 1, ver => 1, rel => 1 }, |
47 |
"/mirrors/centos/$centosrel/extras/SRPMS", |
'smeupdates-testing' => { prio => 16, inc => 1, ver => 1, rel => 1 }, |
48 |
"/mirrors/rpmforge/dag/source", |
'smeextras' => { prio => 15, inc => 0, ver => 1, rel => 1 }, |
49 |
"/mirrors/atrpms/src/el$centosrel-$arch/atrpms/stable", |
'smeaddons' => { prio => 14, inc => 0, ver => 1, rel => 1 }, |
50 |
"/mirrors/atrpms/src/el$centosrel-$arch/atrpms/testing", |
'smecontribs' => { prio => 13, inc => 0, ver => 1, rel => 1 }, |
51 |
"/mirrors/fedora/epel/$centosrel/SRPMS", |
'smetest' => { prio => 12, inc => 0, ver => 2, rel => 3, devel => 2 }, |
52 |
"/mirrors/fedora/core/updates/$fedorarel/SRPMS", |
'smedev' => { prio => 11, inc => 0, ver => 1, rel => 1, devel => 1 }, |
53 |
"/mirrors/fedora/core/$fedorarel/source/SRPMS", |
'centos' => { prio => 10, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
54 |
"/mirrors/fedora/extras/$fedorarel/SRPMS", |
'epel' => { prio => 9, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
55 |
"$builds/SRPMS", |
'fedora-extras' => { prio => 8, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
56 |
); |
'rpmforge' => { prio => 7, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
57 |
|
'atrpms' => { prio => 6, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
58 |
my $rpm_flags = RPM2->vsf_nodsaheader | RPM2->vsf_nodsa; |
'fedora' => { prio => 5, inc => 0, ver => 0, rel => 0, orig => 1, base => 1 }, |
59 |
|
'builds' => { prio => 4, inc => 0, ver => 0, rel => 0, orig => 1 }, |
60 |
my @rpms; |
'contribs' => { prio => 2, inc => 0, ver => 0, rel => 0, orig => 1 }, |
61 |
my %srpms; |
'stage' => { prio => 1, inc => 0, ver => 0, rel => 0, stage => 1, os => 1 }, |
62 |
my %sources; |
}; |
63 |
my %changed; |
|
64 |
my %copy; |
my $baserepo = { '~Ssmeos/~A/SME/~O' => 'smeos', |
65 |
|
'~Ssmeupdates/~A/RPMS/' => 'smeupdates', |
66 |
foreach my $repo ( @repos ) { |
'~Ssmeupdates-testing/~A/RPMS/' => 'smeupdates-testing', |
67 |
my $r = $repo; |
'~Ssmeextras/~A/RPMS/' => 'smeextras', |
68 |
if ( $repo =~ m{$stagedir/RPMS} ) { |
'~Ssmeaddons/~A/RPMS/' => 'smeaddons', |
69 |
$r = $stagedir; |
'~Ssmecontribs/~A/RPMS/' => 'smecontribs', |
70 |
} elsif ( $repo =~ m{$builds/RPMS} ) { |
'~Ssmetest/~A/RPMS/' => 'smetest', |
71 |
$r = 'builds'; |
'~Ssmedev/~A/RPMS/' => 'smedev', |
72 |
} elsif ( $repo =~ m{^($releasedir/$smerel/sme[^/]*)/} ) { |
'/stage/~s/~A/SME/~O' => 'stage', |
73 |
$r = $1; |
'/mirrors/centos/~C/fasttrack/~A/RPMS/' => 'centos', |
74 |
} |
'/mirrors/centos/~C/updates/~A/RPMS/' => 'centos', |
75 |
|
'/mirrors/centos/~C/os/~A/CentOS/~O' => 'centos', |
76 |
if ( $r ne 'builds' ) { |
'/mirrors/centos/~C/extras/~A/RPMS/' => 'centos', |
77 |
opendir SRPMS, "$r/SRPMS" or next; |
'/mirrors/fedora/epel/~C/~A/' => 'epel', |
78 |
foreach my $srpm ( grep { /\.rpm$/ } readdir SRPMS ) { |
'/mirrors/fedora/epel/testing/~C/~A/' => 'epel', |
79 |
$srpms{$r}{$srpm} = 0; |
'/mirrors/fedora/extras/~F/~A/' => 'fedora-extras', |
80 |
$sources{$srpm} = "$r/SRPMS"; |
'/mirrors/rpmforge/dag/redhat/el~C/en/~A/dag/RPMS/' => 'rpmforge', |
81 |
} |
'/mirrors/rpmforge/dag/source/' => 'rpmforge', |
82 |
closedir SRPMS; |
'/mirrors/atrpms/el~C-~A/atrpms/stable/' => 'atrpms', |
83 |
} |
'/mirrors/atrpms/el~C-~A/atrpms/testing/' => 'atrpms', |
84 |
|
'/mirrors/atrpms/src/el~C-~A/atrpms/stable/' => 'atrpms', |
85 |
opendir RPMS, $repo or next; |
'/mirrors/atrpms/src/el~C-~A/atrpms/testing/' => 'atrpms', |
86 |
foreach my $pkg ( reverse sort map { RPM2->open_package("$repo/$_", $rpm_flags); } grep { /\.rpm$/ } readdir RPMS ) { |
'/mirrors/fedora/core/~F/~A/os/Fedora/RPMS/' => 'fedora', |
87 |
my $rpm = { name => $pkg->tag("NAME"), |
'/mirrors/fedora/core/updates/~F/~A/' => 'fedora', |
88 |
filename => join("-", map { $pkg->tag($_) } qw/name version release/) . "." . $pkg->tag("ARCH"), |
}; |
89 |
version => $pkg->tag("VERSION"), |
|
90 |
release => $pkg->tag("RELEASE"), |
if ( $opts{q} ) { |
91 |
repo => $r, |
$baserepo->{'/mirrors/centos-qa/CentOS/~C/fasttrack/~A/RPMS/'} = 'centos'; |
92 |
rpm => $pkg, |
$baserepo->{'/mirrors/centos-qa/CentOS/~C/updates/~A/RPMS/'} = 'centos'; |
93 |
}; |
$baserepo->{'/mirrors/centos-qa/CentOS/~C/os/~A/CentOS/~O'} = 'centos'; |
94 |
my $source = $pkg->tag("SOURCERPM"); |
$baserepo->{'/mirrors/centos-qa/CentOS/~C/extras/~A/RPMS/'} = 'centos'; |
95 |
$source =~ s#-$rpm->{version}-$rpm->{release}.*##; |
} |
96 |
$rpm->{source} = $source; |
|
97 |
|
my $skippkg = { '7' => { 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3', 'vim' ) }, |
98 |
if ( $rpm->{repo} =~ m{^$releasedir/$smerel/} && $rpm->{repo} !~ m{/smedev$} ) { |
'epel' => { map { $_ => 1 } ( 'clamav', 'fping', 'perl-Razor-Agent', 'perl-Text-Iconv', 'proftpd' ) }, |
99 |
$rpm->{repo} = 'deleted' if grep { $_->{repo} ne $rpm->{repo} && $_->{name} eq $rpm->{name} && $_->{rpm} ge $rpm->{rpm} } @rpms; |
'rpmforge' => { map { $_ => 1 } ( 'perl-Test-Inline' ) }, |
100 |
$rpm->{repo} = 'deleted' if grep { $_->{repo} eq $rpm->{repo} && $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @rpms; |
'atrpms' => { map { $_ => 1 } ( 'check4updates', 'dovecot', 'trac', 'yum' ) }, |
101 |
$changed{$r}++ if $rpm->{repo} eq 'deleted'; |
}, |
102 |
} |
'8' => { 'centos' => { map { $_ => 1 } ( 'horde', 'imp-h3', 'ingo-h3', 'turba-h3' ) }, |
103 |
|
'fedora' => { map { $_ => 1 } ( 'kernel-xen' ) }, |
104 |
push @rpms, $rpm; |
'epel' => { map { $_ => 1 } ( 'clamav', 'perl-Razor-Agent', 'proftpd', 'smolt' ) }, |
105 |
|
'fedora-extras' => { map { $_ => 1 } ( 'dstat', 'gocr', 'horde', 'oidentd', 'perl-Test-Inline', 'perl-Razor-Agent', 'smolt' ) }, |
106 |
|
'rpmforge' => { map { $_ => 1 } ( 'perl-Test-Inline' ) }, |
107 |
|
}, |
108 |
|
}; |
109 |
|
|
110 |
|
my ($stage) = sort { $repos->{$a}->{stage} <=> $repos->{$b}->{stage} } grep { $repos->{$_}->{stage} } keys %$repos; |
111 |
|
my ($devel1, $devel2) = sort { $repos->{$a}->{devel} <=> $repos->{$b}->{devel} } grep { $repos->{$_}->{devel} } keys %$repos; |
112 |
|
$devel2 ||= $devel1; |
113 |
|
|
114 |
|
my ($rpms, %base, %latest, %sources); |
115 |
|
foreach my $smever ( sort { $a <=> $b } keys %$distrepo ) { |
116 |
|
next unless $distrepo->{$smever}->{active}; |
117 |
|
my %repochg = (); |
118 |
|
$rpms = (); |
119 |
|
%latest = (); |
120 |
|
%sources = (); |
121 |
|
%base = (); |
122 |
|
|
123 |
|
foreach my $dir ( sort { $repos->{$baserepo->{$b}}->{prio} <=> $repos->{$baserepo->{$a}}->{prio} || $a cmp $b } keys %$baserepo ) { |
124 |
|
my $bdir = $dir; |
125 |
|
$bdir =~ s/~O/$distrepo->{$smever}->{os}/; |
126 |
|
$bdir =~ s/~S/$distrepo->{$smever}->{repo}/; |
127 |
|
$bdir =~ s/~s/$smever/; |
128 |
|
$bdir =~ s/~C/$distrepo->{$smever}->{centos}/; |
129 |
|
$bdir =~ s/~F/$distrepo->{$smever}->{fedora}/; |
130 |
|
for my $arch ( @archs, 'SRPMS/' ) { |
131 |
|
my $adir = $bdir; |
132 |
|
if ( $arch eq 'SRPMS/' ) { |
133 |
|
$adir =~ s/~A.*/$arch/ if $arch eq 'SRPMS/'; |
134 |
|
} else { |
135 |
|
$adir =~ s/~A/$arch/; |
136 |
|
} |
137 |
|
opendir DIR, $adir or next; |
138 |
|
next unless -d $adir; |
139 |
|
process_rpm("$adir$_", $smever, $baserepo->{$dir}) foreach readdir DIR; |
140 |
|
closedir DIR; |
141 |
|
last unless $dir =~ m{~A}; |
142 |
} |
} |
143 |
closedir RPMS; |
} |
144 |
} |
find( { wanted => sub { process_rpm($_, $smever, 'builds'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$smever}->{'builds'} ); |
145 |
|
find( { wanted => sub { process_rpm($_, $smever, 'contribs'); }, no_chdir => 1, follow_fast => 1 }, $distrepo->{$smever}->{'contribs'} ); |
146 |
foreach my $repo ( reverse @srcrepos ) { |
|
147 |
my %temp_repo = map { $_ => $repo } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, $repo ); |
foreach my $base ( sort keys %$rpms ) { |
148 |
closedir SRPMS; |
next unless $rpms->{$base}->{rpms}; |
149 |
|
my %track = (); |
150 |
%sources = (%sources, %temp_repo); |
my %seen = (); |
151 |
} |
my %counts = (); |
152 |
|
my $acnt = (); |
153 |
|
my $print = 0; |
154 |
|
%latest = (); |
155 |
|
|
156 |
|
foreach my $pkg ( sort { $b->{rpm} cmp $a->{rpm} } @{$rpms->{$base}->{rpms}} ) { |
157 |
|
next if $pkg->{done}; |
158 |
|
|
159 |
|
my $tmp = $pkg->{svr}; |
160 |
|
SRC: { |
161 |
|
$rpms->{$base}->{vers}->{$tmp} && last SRC; |
162 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
163 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.at$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
164 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d(\.rf)$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
165 |
|
($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d(\.rf)$}{$1$2} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
166 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.rf$}{.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
167 |
|
($tmp = $pkg->{svr}) =~ s{(\d+)\.\d+\.el\d\.rf$}{$1.dag} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
168 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
169 |
|
($tmp = $pkg->{svr}) =~ s{(-\d+)\.\d+\.el\d$}{$1} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
170 |
|
($tmp = $pkg->{svr}) =~ s{\.centos\d$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
171 |
|
($tmp = $pkg->{svr}) =~ s{\.el\d\.sme$}{} && $rpms->{$base}->{vers}->{$tmp} && last SRC; |
172 |
|
} |
173 |
|
if ( $rpms->{$base}->{vers}->{$tmp} ) { |
174 |
|
foreach $tmp ( @{$rpms->{$base}->{vers}->{$tmp}} ) { |
175 |
|
$tmp->{svr} = $pkg->{svr}; |
176 |
|
push @{$rpms->{$base}->{rpms}}, $tmp unless $tmp->{added}; |
177 |
|
$tmp->{added}++; |
178 |
|
} |
179 |
|
} |
180 |
|
|
181 |
my @latest; |
my %orig = (); |
182 |
foreach my $rpm ( reverse grep { $_->{repo} =~ m{^$releasedir/$smerel/} && $_->{repo} !~ m{/sme(addons|contribs|dev|extras)$} } @rpms ) { |
my %pkgs = (); |
183 |
unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) { |
my %reposrc = (); |
184 |
push @latest, $rpm; |
my $srpm = undef; |
185 |
unless ( grep { $_->{repo} eq $stagedir && $_->{filename} eq $rpm->{filename} } @rpms ) { |
foreach my $cmp ( sort { $a->{src} <=> $b->{src} || $repos->{$b->{repo}}->{prio} <=> $repos->{$a->{repo}}->{prio} } @{$rpms->{$base}->{rpms}} ) { |
186 |
push @{$copy{"$stagedir/RPMS"}}, $rpm->{rpm}->filename; |
next unless $cmp->{svr} eq $pkg->{svr}; |
187 |
push @rpms, { name => $rpm->{name}, |
|
188 |
filename => $rpm->{filename}, |
if ( ! $track{repo} || $repos->{$cmp->{repo}}->{prio} > $repos->{$track{repo}}->{prio} ) { |
189 |
version => $rpm->{version}, |
if ( $cmp->{src} ) { |
190 |
release => $rpm->{release}, |
if ( ! $track{repo} ) { |
191 |
repo => $stagedir, |
$cmp->{delete}++; |
192 |
rpm => $rpm->{rpm}, |
$cmp->{done}++; |
193 |
source => $rpm->{source} |
next; |
194 |
}; |
} |
195 |
|
} else { |
196 |
|
$track{repo} = $cmp->{repo}; |
197 |
|
$track{svr} = $cmp->{svr}; |
198 |
|
} |
199 |
|
} |
200 |
|
if ( $cmp->{svr} eq $track{svr} ) { |
201 |
|
if ( $seen{$cmp->{nvra}} ) { |
202 |
|
if ( $track{repo} ne $cmp->{repo} ) { |
203 |
|
if ($repos->{$cmp->{repo}}->{stage} ) { |
204 |
|
if ( $seen{$cmp->{nvra}}->{latest} ) { |
205 |
|
$seen{$cmp->{nvra}}->{latest}++; |
206 |
|
} else { |
207 |
|
$cmp->{delete}++; |
208 |
|
} |
209 |
|
} elsif ( $repos->{$cmp->{repo}}->{orig}) { |
210 |
|
$orig{$cmp->{nvra}}++; |
211 |
|
unless ( $repos->{$cmp->{repo}}->{base} ) { |
212 |
|
my $tag = sprintf '%s%s/%s-%s', $distrepo->{$smever}->{$cmp->{repo}}, $cmp->{name}, $cmp->{ver}, $cmp->{rel}; |
213 |
|
qx(touch $tag/PUSHED) if -d $tag && ! -f "$tag/PUSHED"; |
214 |
|
} |
215 |
|
} elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) { |
216 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
217 |
|
} elsif ( $seen{$cmp->{nvra}}->{repo} ne $cmp->{repo} ) { |
218 |
|
$cmp->{delete}++; |
219 |
|
} |
220 |
|
} |
221 |
|
} elsif ($repos->{$cmp->{repo}}->{stage} ) { |
222 |
|
$cmp->{delete}++; |
223 |
|
} else { |
224 |
|
$srpm = $cmp if ! $srpm && $cmp->{src}; |
225 |
|
my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2; |
226 |
|
$dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms}); |
227 |
|
$dest = $devel1 if verrel($cmp, $dest, \%counts); |
228 |
|
if ( $cmp->{repo} ne $dest ) { |
229 |
|
push @{$cmp->{repos}}, $dest; |
230 |
|
if ( $repos->{$cmp->{repo}}->{orig} ) { |
231 |
|
$orig{$cmp->{nvra}}++; |
232 |
|
unless ( $repos->{$cmp->{repo}}->{base} ) { |
233 |
|
my $tag = sprintf '%s%s/%s-%s', $distrepo->{$smever}->{$cmp->{repo}}, $cmp->{name}, $cmp->{ver}, $cmp->{rel}; |
234 |
|
qx(touch $tag/PUSHED) if -d $tag && ! -f "$tag/PUSHED"; |
235 |
|
} |
236 |
|
} elsif ( $cmp->{src} && $reposrc{$cmp->{repo}} ) { |
237 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
238 |
|
} else { |
239 |
|
$cmp->{delete}++; |
240 |
|
} |
241 |
|
$cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo}; |
242 |
|
$cmp->{repo} = $dest; |
243 |
|
if ( ! $cmp->{src} && $repos->{$dest}->{prio} > $repos->{$track{repo}}->{prio} ) { |
244 |
|
$track{repo} = $dest; |
245 |
|
$track{svr} = $cmp->{svr}; |
246 |
|
} |
247 |
|
} |
248 |
|
if ( $cmp->{src} && $reposrc{$cmp->{repo}} ) { |
249 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp; |
250 |
|
} |
251 |
|
} |
252 |
|
} else { |
253 |
|
if ( $track{repo} eq $cmp->{repo} ) { |
254 |
|
if ( verrel($cmp, $cmp->{repo}, \%counts) ) { |
255 |
|
$cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base}; |
256 |
|
} elsif ( $cmp->{src} ) { |
257 |
|
$cmp->{delete}++ unless $repos->{$cmp->{repo}}->{base}; |
258 |
|
} else { |
259 |
|
$track{svr} = $cmp->{svr}; |
260 |
|
} |
261 |
|
} elsif ( ! $repos->{$cmp->{repo}}->{base} ) { |
262 |
|
if ( $repos->{$cmp->{repo}}->{orig} ) { |
263 |
|
$srpm = $cmp if ! $srpm && $cmp->{src}; |
264 |
|
my $dest = $repos->{$track{repo}}->{prio} > $repos->{$devel2}->{prio} ? $track{repo} : $devel2; |
265 |
|
$dest = pkgdest($cmp, $devel1, $dest, $rpms->{$base}->{rpms}); |
266 |
|
$dest = $devel1 if verrel($cmp, $dest, \%counts); |
267 |
|
if ( $cmp->{src} && ! $reposrc{$dest} ) { |
268 |
|
$cmp->{delete}++; |
269 |
|
} elsif ( $repos->{$dest}->{prio} >= $repos->{$track{repo}}->{prio} && ! verrel($cmp, $dest, \%counts) ) { |
270 |
|
push @{$cmp->{repos}}, $dest; |
271 |
|
$cmp->{oldrepo} = $cmp->{repo} unless $cmp->{oldrepo}; |
272 |
|
$cmp->{repo} = $dest; |
273 |
|
$reposrc{$cmp->{repo}}->{srpm} = $cmp if $cmp->{src}; |
274 |
|
|
275 |
|
$orig{$cmp->{nvra}}++; |
276 |
|
unless ( $repos->{$cmp->{repo}}->{base} ) { |
277 |
|
my $tag = sprintf '%s%s/%s-%s', $distrepo->{$smever}->{$cmp->{repo}}, $cmp->{name}, $cmp->{ver}, $cmp->{rel}; |
278 |
|
qx(touch $tag/PUSHED) if -d $tag && ! -f "$tag/PUSHED"; |
279 |
|
} |
280 |
|
} else { |
281 |
|
$cmp->{delete}++; |
282 |
|
} |
283 |
|
} else { |
284 |
|
$cmp->{delete}++; |
285 |
|
} |
286 |
|
} |
287 |
|
} |
288 |
|
unless ( $repos->{$cmp->{repo}}->{orig} || ( $cmp->{delete} && ! $cmp->{repos} ) ) { |
289 |
|
$pkgs{$cmp->{nvra}}++; |
290 |
|
$latest{$cmp->{base}} = $cmp->{svr} if $repos->{$cmp->{repo}}->{inc} && ! $latest{$cmp->{base}}; |
291 |
|
$reposrc{$cmp->{repo}} = $cmp unless $reposrc{$cmp->{repo}} || $cmp->{src} || $repos->{$cmp->{repo}}->{stage}; |
292 |
|
unless ( $seen{$cmp->{nvra}} ) { |
293 |
|
$seen{$cmp->{nvra}} = $cmp; |
294 |
|
$cmp->{latest}++ if $latest{$cmp->{base}} && $cmp->{svr} eq $latest{$cmp->{base}} && $repos->{$cmp->{repo}}->{inc}; |
295 |
|
} |
296 |
|
push @{$acnt->{$cmp->{repo}}->{$cmp->{rpm}->as_nvre}->{$cmp->{src} ? 'src' : $cmp->{rpm}->arch}}, $cmp; |
297 |
|
} |
298 |
|
$cmp->{done}++; |
299 |
|
} |
300 |
|
if ( $srpm ) { |
301 |
|
foreach my $r ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %reposrc ) { |
302 |
|
unless ( $reposrc{$r}->{srpm} ) { |
303 |
|
unshift @{$srpm->{repos}}, $r; |
304 |
|
$srpm->{oldrepo} = $srpm->{repo} unless $srpm->{oldrepo}; |
305 |
|
$srpm->{repo} = $r; |
306 |
|
$reposrc{$r}->{srpm} = $srpm; |
307 |
|
} |
308 |
} |
} |
309 |
|
} elsif ( scalar keys %pkgs && $opts{s} ) { |
310 |
|
print "\n * missing source (sme$smever, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n"; |
311 |
|
} |
312 |
|
print "\n * missing originals (sme$smever, ", $pkg->{repo}, ", ", $pkg->{svr}, ")\n" if $opts{o} && scalar keys %orig != scalar keys %pkgs; |
313 |
} |
} |
|
} |
|
|
|
|
|
foreach my $rpm ( grep { $_->{repo} eq $stagedir } @rpms ) { |
|
|
$rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @latest; |
|
|
} |
|
314 |
|
|
315 |
foreach my $rpm ( reverse grep { $_->{repo} =~ m{^$releasedir/$smerel/} && $_->{repo} =~ m{/sme(addons|contribs|extras)$} } @rpms ) { |
foreach my $r ( keys %$acnt ) { |
316 |
unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) { |
foreach my $p ( keys %{$acnt->{$r}} ) { |
317 |
push @latest, $rpm; |
foreach my $a ( keys %{$acnt->{$r}->{$p}} ) { |
318 |
|
if ( $a eq 'noarch' ) { |
319 |
|
my $p2 = ${$acnt->{$r}->{$p}->{$a}}[0]; |
320 |
|
if ( ! $p2->{repos} && scalar @{$acnt->{$r}->{$p}->{$a}} != scalar @archs ) { |
321 |
|
$p2->{oldrepo} = $p2->{repo}; |
322 |
|
push @{$p2->{repos}}, $p2->{repo}; |
323 |
|
} |
324 |
|
} elsif ( scalar @{$acnt->{$r}->{$p}->{$a}} != 1 ) { |
325 |
|
print "\n * many packages ($r, $a, $p)\n"; |
326 |
|
} |
327 |
|
} |
328 |
|
} |
329 |
} |
} |
|
} |
|
330 |
|
|
331 |
my @devel; |
foreach my $pkg ( sort { $a->{nvra} cmp $b->{nvra} } @{$rpms->{$base}->{rpms}} ) { |
332 |
my %versions; |
if ( $pkg->{latest} && $pkg->{latest} == 1 ) { |
333 |
foreach my $rpm ( grep { $_->{repo} eq 'builds' } @rpms ) { |
$pkg->{oldrepo} = $pkg->{repo} unless $pkg->{oldrepo}; |
334 |
next if grep { $_->{name} eq $rpm->{name} && $_->{rpm} ge $rpm->{rpm} } @latest; |
$pkg->{repo} = $stage; |
335 |
|
push @{$pkg->{repos}}, $stage; |
336 |
$versions{$rpm->{name}}{$rpm->{version}}++ unless grep { $_->{name} eq $rpm->{name} && $_->{rpm} eq $rpm->{rpm} } @devel; |
} |
337 |
next if $versions{$rpm->{name}}{$rpm->{version}} > $releases || scalar keys %{$versions{$rpm->{name}}} > $releases; |
if ( ! $print && ($pkg->{delete} || $pkg->{repos} || $pkg->{nosig} ) ) { |
338 |
print "Possible update " . $rpm->{rpm}->filename . "\n" if grep { $_->{name} eq $rpm->{name} } @latest; |
print "\n$base (sme$smever)\n", "=" x length("$base (sme$smever)"), "\n"; |
339 |
|
$print++; |
340 |
push @devel, $rpm; |
} |
341 |
unless ( grep { $_->{repo} =~ m{/smedev$} && $_->{filename} eq $rpm->{filename} } @rpms ) { |
|
342 |
push @{$copy{"$releasedir/$smerel/smedev/$arch/RPMS"}}, $rpm->{rpm}->filename; |
my $src = $pkg->{rpm}->filename; |
343 |
$changed{"$releasedir/$smerel/smedev"}++; |
if ( $pkg->{nosig} ) { |
344 |
push @rpms, { name => $rpm->{name}, |
print "sign package (", basename($pkg->{rpm}->filename), ")\n"; |
345 |
filename => $rpm->{filename}, |
unless ( $opts{t} ) { |
346 |
version => $rpm->{version}, |
qx(cat $HOME/.rpmpass | setsid rpm --addsign $src >& /dev/null); |
347 |
release => $rpm->{release}, |
if ($?) { |
348 |
repo => "$releasedir/$smerel/smedev", |
print " * failed to sign package\n"; |
349 |
rpm => $rpm->{rpm}, |
next; |
350 |
source => $rpm->{source} |
} |
351 |
}; |
} |
352 |
} |
} |
|
} |
|
353 |
|
|
354 |
foreach my $rpm ( grep { $_->{repo} =~ m{/smedev$} } @rpms ) { |
if ( $pkg->{repos} ) { |
355 |
$rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @devel; |
foreach my $repo ( @{$pkg->{repos}} ) { |
356 |
} |
if ( $pkg->{delete} ) { |
357 |
|
print "move from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n"; |
358 |
|
$pkg->{delete} = 0; |
359 |
|
$repochg{$pkg->{oldrepo}}++ unless $repos->{$pkg->{oldrepo}}->{base} || $repos->{$pkg->{oldrepo}}->{stage}; |
360 |
|
} elsif ( $pkg->{oldrepo} eq $repo ) { |
361 |
|
print "distribute noarch in $repo (", basename($pkg->{rpm}->filename), ")\n"; |
362 |
|
} else { |
363 |
|
print "copy from ", $pkg->{oldrepo}, " to $repo (", basename($pkg->{rpm}->filename), ")\n"; |
364 |
|
} |
365 |
|
$repochg{$repo}++ unless $repos->{$repo}->{base} || $repos->{$repo}->{stage}; |
366 |
|
$pkg->{oldrepo} = $repo unless $pkg->{oldrepo} eq ${$pkg->{repos}}[0]; |
367 |
|
|
368 |
|
my @d = (); |
369 |
|
my $head = $distrepo->{$smever}->{repo} . $repo . '/'; |
370 |
|
$head = $distrepo->{$smever}->{stage} if $repos->{$repo}->{stage}; |
371 |
|
my $tail = $repos->{$repo}->{os} ? 'SME/' . $distrepo->{$smever}->{os} : 'RPMS/'; |
372 |
|
if ( $pkg->{src} ) { |
373 |
|
push @d, "${head}SRPMS/" . basename($pkg->{rpm}->filename); |
374 |
|
} elsif ( $pkg->{rpm}->arch eq 'noarch' ) { |
375 |
|
push @d, map { "${head}$_/$tail" . basename($pkg->{rpm}->filename) } @archs; |
376 |
|
} elsif ( $pkg->{rpm}->arch =~ m{^(i[356]86)$} ) { |
377 |
|
push @d, "${head}i386/$tail" . basename($pkg->{rpm}->filename); |
378 |
|
} else { |
379 |
|
push @d, $head . $pkg->{rpm}->arch . "/$tail" . basename($pkg->{rpm}->filename); |
380 |
|
} |
381 |
|
foreach my $dest ( @d ) { |
382 |
|
qx(cp --preserve=timestamps $src $dest) unless $opts{t} || -f "$dest"; |
383 |
|
} |
384 |
|
|
|
print "\n"; |
|
|
foreach my $rpm ( grep { $_->{repo} !~ m{^(builds|deleted)$} } @rpms ) { |
|
|
my $src; |
|
|
my $srpm = $rpm->{rpm}->tag("SOURCERPM"); |
|
|
|
|
|
my @sources = (); |
|
|
push @sources, ($src = $srpm); |
|
|
push @sources, $src if (($src = $srpm) =~ s/\.el\d\.rf\./\.rf\./); |
|
|
push @sources, $src if (($src = $srpm) =~ s/\.[0-3]\.el\d+\.rf\./\.rf\./); |
|
|
push @sources, $src if (($src = $srpm) =~ s/\.(el|fc)\d\.at//); |
|
|
push @sources, $src if (($src = $srpm) =~ s/\.at//); |
|
|
push @sources, $src if (($src = $srpm) =~ s/\.(el|fc)\d//); |
|
|
push @sources, $src if (($src = $srpm) =~ s/\.\d+\.(el|fc)\d//); |
|
|
|
|
|
my $found = 0; |
|
|
my $repo = $rpm->{repo}; |
|
|
foreach my $source ( @sources ) { |
|
|
if ( $sources{$source} ) { |
|
|
unless ( -f "$repo/SRPMS/$source" ) { |
|
|
push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source"; |
|
|
$changed{$repo}++ unless $repo eq $stagedir; |
|
|
} |
|
|
$srpms{$repo}{$source}++; |
|
|
$found++; |
|
|
last; |
|
385 |
} |
} |
386 |
|
qx(rm -f $src) if exists $pkg->{delete} && ! $opts{t}; |
387 |
|
} elsif ( $pkg->{delete} ) { |
388 |
|
print "delete from ", $pkg->{repo}, " (", $pkg->{arch}, ", ", basename($pkg->{rpm}->filename), ")\n"; |
389 |
|
qx(rm -f $src) unless $opts{t}; |
390 |
|
$repochg{$pkg->{repo}}++ unless $repos->{$pkg->{repo}}->{base} || $repos->{$pkg->{repo}}->{stage}; |
391 |
|
if ( $repos->{$pkg->{repo}}->{orig} && ! $repos->{$pkg->{repo}}->{base} ) { |
392 |
|
my $tag = sprintf '%s%s/%s-%s', $distrepo->{$smever}->{$pkg->{repo}}, $pkg->{name}, $pkg->{ver}, $pkg->{rel}; |
393 |
|
qx(rm -f $tag/PUSHED) if -d $tag && -f "$tag/PUSHED"; |
394 |
|
} |
395 |
|
} |
396 |
} |
} |
397 |
print "Can't find source for ".$rpm->{rpm}->filename."\n" unless $found; |
} |
|
} |
|
398 |
|
|
399 |
my @remove; |
if ( %repochg ) { |
400 |
foreach my $repo ( keys %srpms ) { |
print "\nrebuild repo (sme$smever)\n", "=" x length("rebuild repo (sme$smever)"), "\n"; |
401 |
foreach my $rpm ( keys %{$srpms{$repo}} ) { |
} |
402 |
unless ( $srpms{$repo}{$rpm} ) { |
foreach my $repo ( sort { $repos->{$b}->{prio} <=> $repos->{$a}->{prio} } keys %repochg ) { |
403 |
push @remove, "$repo/SRPMS/$rpm"; |
next if $repos->{$repo}->{orig} || $repos->{$repo}->{stage}; |
404 |
$changed{$repo}++ unless $repo eq $stagedir; |
foreach my $arch ( @archs ) { |
405 |
|
my $dir = $distrepo->{$smever}->{repo} . "$repo/$arch"; |
406 |
|
$dir = qx(readlink -f $dir); |
407 |
|
chomp $dir; |
408 |
|
print "rebuild $repo/$arch\n"; |
409 |
|
unless ( $opts{t} ) { |
410 |
|
if ( -f "$dir/repodata/comps.xml" ) { |
411 |
|
qx(createrepo -g repodata/comps.xml $dir); |
412 |
|
} else { |
413 |
|
qx(createrepo $dir); |
414 |
} |
} |
415 |
|
qx(repoview $dir); |
416 |
|
qx(rm -rf $dir/.olddata) if -d "$dir/.olddata"; |
417 |
|
qx(rm -rf $dir/.repodata) if -d "$dir/.repodata"; |
418 |
|
} |
419 |
} |
} |
420 |
|
} |
421 |
|
unless ( $opts{t} ) { |
422 |
|
finddepth(sub{rmdir}, $distrepo->{$smever}->{$_}) foreach ('builds','contribs'); |
423 |
|
} |
424 |
|
} |
425 |
|
|
426 |
|
sub verrel { |
427 |
|
my $pkg = shift; |
428 |
|
my $repo = shift; |
429 |
|
my $counts = shift; |
430 |
|
|
431 |
|
return 0 if $pkg->{src}; |
432 |
|
$counts->{$repo}->{$pkg->{ver}}->{$pkg->{rel}}++; |
433 |
|
return 1 if $repos->{$repo}->{ver} && scalar keys %{$counts->{$repo}} > $repos->{$repo}->{ver}; |
434 |
|
return 1 if $repos->{$repo}->{rel} && scalar keys %{$counts->{$repo}->{$pkg->{ver}}} > $repos->{$repo}->{rel}; |
435 |
|
return 0; |
436 |
|
} |
437 |
|
|
438 |
|
sub pkgdest { |
439 |
|
my $pkg = shift; |
440 |
|
my $dest = shift; |
441 |
|
my $hirepo = shift; |
442 |
|
my $pkgs = shift; |
443 |
|
|
444 |
|
foreach my $cmp ( @$pkgs ) { |
445 |
|
next if $cmp->{src} || $repos->{$cmp->{repo}}->{prio} <= $repos->{$dest}->{prio}; |
446 |
|
next if $pkg->{name} ne ( $pkg->{src} ? $cmp->{base} : $cmp->{name} ); |
447 |
|
if ( $repos->{$cmp->{repo}}->{prio} > $repos->{$hirepo}->{prio} ) { |
448 |
|
$dest = $hirepo; |
449 |
|
last; |
450 |
|
} else { |
451 |
|
$dest = $cmp->{repo}; |
452 |
|
} |
453 |
|
} |
454 |
|
return $dest; |
455 |
} |
} |
456 |
|
|
457 |
print "\n"; |
sub process_rpm { |
458 |
foreach my $repo ( sort keys %copy ) { |
my $rpm = shift; |
459 |
foreach my $rpm ( keys %{{ map { $_ => 1 } @{$copy{$repo}} }} ) { |
my $smever = shift; |
460 |
print "copying $rpm to $repo/\n"; |
my $repo = shift; |
461 |
system(qw(cp --preserve=timestamps), $rpm, "$repo/"); |
return unless $rpm =~ m{/([^/]*)-[^-]+-[^-]+\.\w+\.rpm$}; |
462 |
} |
my $base = $1; |
463 |
} |
return unless ! $opts{r} || $base =~ m[$opts{r}]; |
464 |
|
return unless $latest{$base} || $sources{$base} || ! $repos->{$repo}->{base}; |
465 |
print "\n"; |
|
466 |
foreach my $rpm ( keys %{{ map { $_ => 1 } (@remove, map { $_->{rpm}->filename } grep { $_->{repo} eq 'deleted' } @rpms) }} ) { |
my $pkg; |
467 |
print "removing $rpm\n"; |
eval { $pkg = RPM2->open_package($rpm, $rpm_flags); }; |
468 |
unlink $rpm; |
if ($@) { print " * corrupt package ($rpm)\n"; return; } |
469 |
} |
eval { my $sig = $pkg->siggpg }; |
470 |
|
my $nosig = ! $@; |
471 |
print "\n"; |
|
472 |
foreach my $repo ( sort keys %changed ) { |
my $cmp = $latest{$pkg->name}; |
473 |
my $dir=`readlink -f $repo/$arch`; |
if ( $repos->{$repo}->{base} && ! $pkg->is_source_package ) { |
474 |
chomp $dir; |
return unless $cmp; |
475 |
print "rebuilding $dir...\n"; |
return if $repos->{$cmp->{repo}}->{base} && $repos->{$cmp->{repo}}->{prio} > $repos->{$repo}->{prio} && $pkg ge $cmp->{rpm}; |
476 |
system(qw(createrepo), "$dir"); |
} |
477 |
system(qw(rm -rf), "$dir/.olddata"); |
my ($src, $version, $release) = ($pkg->is_source_package ? $pkg->filename : $pkg->sourcerpm) =~ m{(?:^|/)([^/]*)-([^-]+)-([^-]+)\.\w+\.rpm$}; |
478 |
system(qw(repoview), "$dir"); |
return if $skippkg->{$smever}->{$repo} && ( $skippkg->{$smever}->{$repo}->{$src} || $skippkg->{$smever}->{$repo}->{$pkg->name} ); |
479 |
system(qw(rm -rf), "$dir/.repodata"); |
return if $repos->{$repo}->{base} && $nosig; |
480 |
|
if ( $nosig && ! -f "$HOME/.rpmpass" ) { print " * missing signature (" .$pkg->filename . ")\n"; return; } |
481 |
|
my $arch = 'unknown'; |
482 |
|
$arch = 'SRPMS' if $pkg->filename =~ m{[/-](SRPMS?|src|source)/}; |
483 |
|
$arch = 'x86_64' if $pkg->filename =~ m{[/-]x86_64/}; |
484 |
|
$arch = 'i386' if $pkg->filename =~ m{[/-](i[356]86)/}; |
485 |
|
$arch = 'noarch' if $pkg->filename =~ m{[/-]noarch/}; |
486 |
|
|
487 |
|
my $rpmhash = { base => $src, |
488 |
|
name => $pkg->name, |
489 |
|
repo => $repo, |
490 |
|
nvra => $pkg->name.'-'.$pkg->version.'-'.$pkg->release.'.'.( $pkg->is_source_package ? 'src' : $pkg->tag('ARCH') ), |
491 |
|
svr => $src.'-'.$version.'-'.$release, |
492 |
|
src => $pkg->is_source_package, |
493 |
|
arch => $arch, |
494 |
|
ver => $version, |
495 |
|
rel => $release, |
496 |
|
rpm => $pkg, |
497 |
|
nosig => $nosig, |
498 |
|
}; |
499 |
|
if ( $pkg->is_source_package ) { |
500 |
|
push @{$rpms->{$src}->{srpms}}, $rpmhash; |
501 |
|
push @{$rpms->{$src}->{vers}->{$rpmhash->{svr}}}, $rpmhash; |
502 |
|
} else { |
503 |
|
push @{$rpms->{$src}->{rpms}}, $rpmhash; |
504 |
|
} |
505 |
|
$sources{$src}++; |
506 |
|
|
507 |
|
return if $pkg->is_source_package || $repos->{$repo}->{stage}; |
508 |
|
if ( ! $repos->{$repo}->{base} ) { |
509 |
|
if ( ! $cmp || $pkg gt $cmp->{rpm} ) { |
510 |
|
$latest{$pkg->name} = $rpmhash; |
511 |
|
} |
512 |
|
} elsif ( ( $repos->{$repo}->{prio} >= $repos->{$cmp->{repo}}->{prio} || ! $repos->{$cmp->{repo}}->{base} ) && $pkg ge $cmp->{rpm} ) { |
513 |
|
$latest{$pkg->name} = $rpmhash; |
514 |
|
} |
515 |
} |
} |