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