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