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