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