9 |
|
|
10 |
my $releases = 2; |
my $releases = 2; |
11 |
|
|
12 |
my $rpm_flags = RPM2->vsf_nodsa; |
my $releasedir = '/releases'; |
13 |
my $repodir = '/releases/7'; |
my $smerel = '7'; |
14 |
|
my $arch = 'i386'; |
15 |
|
my $centosrel = '4'; |
16 |
|
my $fedorarel = '3'; |
17 |
|
my $builds = '/builds/rpms'; |
18 |
my $stagedir = '/builds'; |
my $stagedir = '/builds'; |
19 |
my @repos = qw( |
|
20 |
/releases/7/smeos/i386/CentOS/RPMS |
my @repos = ( |
21 |
/releases/7/smeupdates/i386/RPMS |
"$releasedir/$smerel/smeos/$arch/CentOS/RPMS", |
22 |
/releases/7/smeupdates-testing/i386/RPMS |
"$releasedir/$smerel/smeos/$arch/SME/RPMS", |
23 |
/releases/7/smeextras/i386/RPMS |
"$releasedir/$smerel/smeos/$arch/RPMS", |
24 |
/releases/7/smeaddons/i386/RPMS |
"$releasedir/$smerel/smeos/$arch/SME", |
25 |
/releases/7/smetest/i386/RPMS |
"$releasedir/$smerel/smeupdates/$arch/RPMS", |
26 |
/releases/7/smedev/i386/RPMS |
"$releasedir/$smerel/smeupdates-testing/$arch/RPMS", |
27 |
/builds/rpms/RPMS/i386 |
"$releasedir/$smerel/smeextras/$arch/RPMS", |
28 |
/builds/rpms/RPMS/i586 |
"$releasedir/$smerel/smeaddons/$arch/RPMS", |
29 |
/builds/rpms/RPMS/i686 |
"$releasedir/$smerel/smetest/$arch/RPMS", |
30 |
/builds/rpms/RPMS/noarch |
"$releasedir/$smerel/smedev/$arch/RPMS", |
31 |
/builds/RPMS |
"$builds/RPMS/$arch", |
32 |
); |
"$builds/RPMS/i586", |
33 |
my $devrepo = (grep { m{/sme} } reverse @repos)[0]; |
"$builds/RPMS/i686", |
34 |
|
"$builds/RPMS/noarch", |
35 |
my @srcrepos = qw( |
"$stagedir/RPMS", |
36 |
/mirrors/centos/4/fasttrack/SRPMS |
); |
37 |
/mirrors/centos/4/updates/SRPMS |
|
38 |
/mirrors/centos/4/os/SRPMS |
my @srcrepos = ( |
39 |
/mirrors/centos/4/extras/SRPMS |
"/mirrors/centos/$centosrel/fasttrack/SRPMS", |
40 |
/mirrors/rpmforge/dag/source |
"/mirrors/centos/$centosrel/updates/SRPMS", |
41 |
/mirrors/atrpms/src/el4-i386/atrpms/stable |
"/mirrors/centos/$centosrel/os/SRPMS", |
42 |
/builds/rpms/SRPMS |
"/mirrors/centos/$centosrel/extras/SRPMS", |
43 |
); |
"/mirrors/rpmforge/dag/source", |
44 |
|
"/mirrors/atrpms/src/el$centosrel-$arch/atrpms/stable", |
45 |
|
"/mirrors/fedora/epel/$centosrel/SRPMS", |
46 |
|
"/mirrors/fedora/core/updates/$fedorarel/SRPMS", |
47 |
|
"/mirrors/fedora/core/$fedorarel/source/SRPMS", |
48 |
|
"/mirrors/fedora/extras/$fedorarel/SRPMS", |
49 |
|
"$builds/SRPMS", |
50 |
|
); |
51 |
|
|
52 |
my %repohash; |
my %repohash; |
53 |
my %srcrepohash; |
my %srcrepohash; |
55 |
my %copy; |
my %copy; |
56 |
my @remove; |
my @remove; |
57 |
|
|
58 |
|
my $rpm_flags = RPM2->vsf_nodsaheader | RPM2->vsf_nodsa; |
59 |
|
|
60 |
%{$srcrepohash{$stagedir}} = map { $_ => 0 } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, "$stagedir/SRPMS" ); |
%{$srcrepohash{$stagedir}} = map { $_ => 0 } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, "$stagedir/SRPMS" ); |
61 |
closedir SRPMS; |
closedir SRPMS; |
62 |
|
|
|
print "\n"; |
|
63 |
foreach my $repo ( @repos ) { |
foreach my $repo ( @repos ) { |
64 |
if ( $repo =~ m{^(.*/[0-9]+/sme[^/]*)/} ) { |
if ( $repo =~ m{^($releasedir/$smerel/sme[^/]*)/} ) { |
65 |
my $srcrepo = $1; |
my $srcrepo = $1; |
66 |
|
|
67 |
%{$srcrepohash{$srcrepo}} = map { $_ => 0 } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, "$srcrepo/SRPMS" ); |
%{$srcrepohash{$srcrepo}} = map { $_ => 0 } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, "$srcrepo/SRPMS" ); |
68 |
closedir SRPMS; |
closedir SRPMS; |
69 |
} |
} |
70 |
|
|
71 |
opendir RPMS, $repo; |
opendir RPMS, $repo; |
72 |
foreach my $rpm ( grep { m{\.rpm} } readdir RPMS ) { |
foreach my $rpm ( grep { m{\.rpm} } readdir RPMS ) { |
73 |
my $header = RPM2->open_package("$repo/$rpm", $rpm_flags); |
my $header = RPM2->open_package("$repo/$rpm", $rpm_flags); |
74 |
my $pkg = $header->tag("NAME").".".$header->tag("ARCH"); |
my $pkg = $header->tag("NAME").".".$header->tag("ARCH"); |
75 |
if ( $repo =~ m{/builds/RPMS} ) { |
if ( $repo =~ m{$stagedir/RPMS} ) { |
76 |
push @{$repohash{$pkg}{$stagedir}}, $header; |
push @{$repohash{$pkg}{$stagedir}}, $header; |
77 |
} elsif ( $repo =~ m{/builds/} ) { |
} elsif ( $repo =~ m{$builds/RPMS} ) { |
78 |
push @{$repohash{$pkg}{builds}}, $header; |
push @{$repohash{$pkg}{builds}}, $header; |
79 |
} elsif ( $repo =~ m{^(.*/[0-9]+/sme[^/]*)/} ) { |
} elsif ( $repo =~ m{^($releasedir/$smerel/sme[^/]*)/} ) { |
80 |
my $pos = $1; |
my $pos = $1; |
81 |
push @{$repohash{$pkg}{$pos}}, $header; |
push @{$repohash{$pkg}{$pos}}, $header; |
82 |
} |
} |
83 |
} |
} |
84 |
closedir RPMS; |
closedir RPMS; |
85 |
} |
} |
86 |
|
|
87 |
my %sources; |
my %sources; |
88 |
foreach my $repo ( reverse @srcrepos ) { |
foreach my $repo ( reverse @srcrepos ) { |
89 |
my %temp_repo = map { $_ => $repo } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, $repo ); |
my %temp_repo = map { $_ => $repo } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, $repo ); |
90 |
closedir SRPMS; |
closedir SRPMS; |
91 |
|
|
92 |
%sources = (%sources, %temp_repo); |
%sources = (%sources, %temp_repo); |
93 |
} |
} |
94 |
|
|
95 |
foreach my $pkg ( keys %repohash ) { |
foreach my $pkg ( keys %repohash ) { |
96 |
foreach my $repo ( @repos ) { |
foreach my $repo ( @repos ) { |
97 |
if ( $repo =~ m{/builds/RPMS} ) { |
if ( $repo =~ m{$stagedir/RPMS} ) { |
98 |
next unless $repohash{$pkg}{latest} || $repohash{$pkg}{$stagedir}; |
next unless $repohash{$pkg}; |
99 |
my ($latest, @rest) = sort { $b cmp $a } @{$repohash{$pkg}{$stagedir}}; |
if ( $repohash{$pkg}{$stagedir} ) { |
100 |
delete $repohash{$pkg}{$stagedir}; |
my ($latest, @rest) = sort { $b cmp $a } @{$repohash{$pkg}{$stagedir}}; |
101 |
push @remove, map { $_->filename } @rest if @rest; |
delete $repohash{$pkg}{$stagedir}; |
102 |
if ( $repohash{$pkg}{latest} ) { |
push @remove, map { $_->filename } @rest if @rest; |
103 |
if ($repohash{$pkg}{latest} ne $latest ) { |
if ( $repohash{$pkg}{latest} ) { |
104 |
push @remove, $latest->filename; |
if ($repohash{$pkg}{latest} ne $latest ) { |
105 |
push @{$copy{"$stagedir/RPMS"}}, $repohash{$pkg}{latest}->filename; |
push @remove, $latest->filename; |
106 |
$repohash{$pkg}{$stagedir} = $repohash{$pkg}{latest}; |
push @{$copy{"$stagedir/RPMS"}}, $repohash{$pkg}{latest}->filename; |
107 |
} else { |
$repohash{$pkg}{$stagedir} = $repohash{$pkg}{latest}; |
108 |
$repohash{$pkg}{$stagedir} = $latest; |
} else { |
109 |
} |
$repohash{$pkg}{$stagedir} = $latest; |
110 |
} else { |
} |
111 |
push @remove, $latest->filename; |
} else { |
112 |
} |
push @remove, $latest->filename; |
113 |
} elsif ( $repo =~ m{^(.*/[0-9]+/sme[^/]*)/} ) { |
} |
114 |
my $pos = $1; |
} elsif ( $repohash{$pkg}{latest} ) { |
115 |
next unless $repohash{$pkg}{$pos}; |
push @{$copy{"$stagedir/RPMS"}}, $repohash{$pkg}{latest}->filename; |
116 |
if ( $pos =~ m{/smedev$} ) { |
$repohash{$pkg}{$stagedir} = $repohash{$pkg}{latest}; |
117 |
next unless $repohash{$pkg}{latest}; |
} |
118 |
my @rest = grep { $_ le $repohash{$pkg}{latest} } @{$repohash{$pkg}{$pos}}; |
} elsif ( $repo =~ m{^($releasedir/$smerel/sme[^/]*)/} ) { |
119 |
if ( @rest ) { |
my $pos = $1; |
120 |
push @remove, map { $_->filename } @rest; |
next unless $repohash{$pkg}{$pos}; |
121 |
$changed{$pos}++; |
if ( $pos =~ m{/smedev$} ) { |
122 |
@{$repohash{$pkg}{$pos}} = grep { $_ gt $repohash{$pkg}{latest} } @{$repohash{$pkg}{$pos}}; |
next unless $repohash{$pkg}{latest}; |
123 |
delete $repohash{$pkg}{$pos}; |
my @rest = grep { $_ le $repohash{$pkg}{latest} } @{$repohash{$pkg}{$pos}}; |
124 |
} |
if ( @rest ) { |
125 |
} else { |
push @remove, map { $_->filename } @rest; |
126 |
my ($latest, @rest) = sort { $b cmp $a } @{$repohash{$pkg}{$pos}}; |
$changed{$pos}++; |
127 |
delete $repohash{$pkg}{$pos}; |
@{$repohash{$pkg}{$pos}} = grep { $_ gt $repohash{$pkg}{latest} } @{$repohash{$pkg}{$pos}}; |
128 |
if ( $repohash{$pkg}{latest} && $repohash{$pkg}{latest} ge $latest ) { |
delete $repohash{$pkg}{$pos}; |
129 |
push @rest, $latest; |
} |
130 |
} else { |
} elsif ( ref($repohash{$pkg}{$pos}) eq 'ARRAY' ) { |
131 |
$repohash{$pkg}{latest} = $latest; |
my ($latest, @rest) = sort { $b cmp $a } @{$repohash{$pkg}{$pos}}; |
132 |
$repohash{$pkg}{$pos} = $latest; |
delete $repohash{$pkg}{$pos}; |
133 |
} |
if ( $repohash{$pkg}{latest} && $repohash{$pkg}{latest} ge $latest ) { |
134 |
if ( @rest ) { |
push @rest, $latest; |
135 |
push @remove, map { $_->filename } @rest; |
} else { |
136 |
$changed{$pos}++; |
$repohash{$pkg}{latest} = $latest; |
137 |
} |
$repohash{$pkg}{$pos} = $latest; |
138 |
} |
} |
139 |
} |
if ( @rest ) { |
140 |
} |
push @remove, map { $_->filename } @rest; |
141 |
|
$changed{$pos}++; |
142 |
|
} |
143 |
|
} |
144 |
|
} |
145 |
|
} |
146 |
} |
} |
147 |
|
|
148 |
|
print "\n"; |
149 |
foreach my $pkg ( sort grep { $repohash{$_}{builds} } keys %repohash ) { |
foreach my $pkg ( sort grep { $repohash{$_}{builds} } keys %repohash ) { |
150 |
my %versions = (); |
my %versions = (); |
151 |
foreach my $ver ( sort { $b cmp $a } @{$repohash{$pkg}{builds}} ) { |
foreach my $ver ( sort { $b cmp $a } @{$repohash{$pkg}{builds}} ) { |
152 |
next if $repohash{$pkg}{latest} && $repohash{$pkg}{latest} ge $ver; |
next if $repohash{$pkg}{latest} && $repohash{$pkg}{latest} ge $ver; |
153 |
|
|
154 |
$versions{$ver->tag("VERSION")}++; |
$versions{$ver->tag("VERSION")}++; |
155 |
if ( $versions{$ver->tag("VERSION")} > $releases || (scalar keys %versions) > $releases ) { |
if ( $versions{$ver->tag("VERSION")} > $releases || (scalar keys %versions) > $releases ) { |
156 |
foreach my $rpm ( grep { $ver eq $_ } @{$repohash{$pkg}{"$repodir/smedev"}} ) { |
foreach my $rpm ( grep { $ver eq $_ } @{$repohash{$pkg}{"$releasedir/$smerel/smedev"}} ) { |
157 |
push @remove, $rpm->filename; |
push @remove, $rpm->filename; |
158 |
@{$repohash{$pkg}{"$repodir/smedev"}} = grep { $rpm ne $_ } @{$repohash{$pkg}{"$repodir/smedev"}}; |
@{$repohash{$pkg}{"$releasedir/$smerel/smedev"}} = grep { $rpm ne $_ } @{$repohash{$pkg}{"$releasedir/$smerel/smedev"}}; |
159 |
$changed{"$repodir/smedev"}++; |
$changed{"$releasedir/$smerel/smedev"}++; |
160 |
} |
} |
161 |
} else { |
} else { |
162 |
print "Possible update " . $ver->filename . "\n" if $repohash{$pkg}{latest}; |
print "Possible update " . $ver->filename . "\n" if $repohash{$pkg}{latest}; |
163 |
if ( ! grep { $ver eq $_ } @{$repohash{$pkg}{"$repodir/smedev"}} ) { |
if ( ! grep { $ver eq $_ } @{$repohash{$pkg}{"$releasedir/$smerel/smedev"}} ) { |
164 |
push @{$copy{$devrepo}}, $ver->filename; |
push @{$copy{"$releasedir/$smerel/smedev/$arch/RPMS"}}, $ver->filename; |
165 |
push @{$repohash{$pkg}{"$repodir/smedev"}}, $ver; |
push @{$repohash{$pkg}{"$releasedir/$smerel/smedev"}}, $ver; |
166 |
$changed{"$repodir/smedev"}++; |
$changed{"$releasedir/$smerel/smedev"}++; |
167 |
} |
} |
168 |
} |
} |
169 |
} |
} |
170 |
} |
} |
171 |
|
|
172 |
foreach my $pkg ( grep { $repohash{$_}{"$repodir/smedev"} } keys %repohash ) { |
foreach my $pkg ( grep { $repohash{$_}{"$releasedir/$smerel/smedev"} } keys %repohash ) { |
173 |
foreach my $rpm ( @{$repohash{$pkg}{"$repodir/smedev"}} ) { |
foreach my $rpm ( @{$repohash{$pkg}{"$releasedir/$smerel/smedev"}} ) { |
174 |
unless ( grep { $rpm eq $_ } @{$repohash{$pkg}{builds}} ) { |
unless ( grep { $rpm eq $_ } @{$repohash{$pkg}{builds}} ) { |
175 |
push @remove, $rpm->filename; |
push @remove, $rpm->filename; |
176 |
@{$repohash{$pkg}{"$repodir/smedev"}} = grep { $rpm ne $_ } @{$repohash{$pkg}{"$repodir/smedev"}}; |
@{$repohash{$pkg}{"$releasedir/$smerel/smedev"}} = grep { $rpm ne $_ } @{$repohash{$pkg}{"$releasedir/$smerel/smedev"}}; |
177 |
$changed{"$repodir/smedev"}++; |
$changed{"$releasedir/$smerel/smedev"}++; |
178 |
} |
} |
179 |
} |
} |
180 |
} |
} |
181 |
|
|
182 |
print "\n"; |
print "\n"; |
183 |
foreach my $repo ( sort keys %srcrepohash ) { |
foreach my $repo ( sort keys %srcrepohash ) { |
184 |
foreach my $pkg ( sort grep { $repohash{$_}{$repo} } keys %repohash ) { |
foreach my $pkg ( sort grep { $repohash{$_}{$repo} } keys %repohash ) { |
185 |
my @rpms = ref($repohash{$pkg}{$repo}) eq "ARRAY" ? @{$repohash{$pkg}{$repo}} : ($repohash{$pkg}{$repo}); |
my @rpms = ref($repohash{$pkg}{$repo}) eq "ARRAY" ? @{$repohash{$pkg}{$repo}} : ($repohash{$pkg}{$repo}); |
186 |
foreach my $rpm ( sort @rpms ) { |
foreach my $rpm ( sort @rpms ) { |
187 |
my $src = $rpm->tag("SOURCERPM"); |
my $src = $rpm->tag("SOURCERPM"); |
188 |
|
|
189 |
my @sources = (); |
my @sources = (); |
190 |
push @sources, $src; |
push @sources, $src; |
191 |
push @sources, $src if ($src =~ s/\.2\.el4\.rf\./\.rf\./); |
push @sources, $src if ($src =~ s/\.\d+\.el\d+\.rf\./\.rf\./); |
192 |
push @sources, $src if ($src =~ s/\.el4\.rf\./\.rf\./); |
push @sources, $src if ($src =~ s/\.el\d\.rf\./\.rf\./); |
193 |
push @sources, $src if ($src =~ s/\.el4\.at\./\.at\./); |
push @sources, $src if ($src =~ s/\.el\d\.at\./\.at\./); |
194 |
push @sources, $src if ($src =~ s/\.rf\./\.dag\./); |
push @sources, $src if ($src =~ s/\.fc\d\.at\./\.at\./); |
195 |
|
push @sources, $src if ($src =~ s/\.rf\./\.dag\./); |
196 |
my $found = 0; |
push @sources, $src if ($src =~ s/\.0\.el\d+\./\.at\./); |
197 |
foreach my $source ( @sources ) { |
push @sources, $src if ($src =~ s/\.el\d+\./\.at\./); |
198 |
if ( $sources{$source} ) { |
|
199 |
unless ( -f "$repo/SRPMS/$source" ) { |
|
200 |
push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source"; |
my $found = 0; |
201 |
$changed{$repo}++; |
foreach my $source ( @sources ) { |
202 |
} |
if ( $sources{$source} ) { |
203 |
$srcrepohash{$repo}{$source}++; |
unless ( -f "$repo/SRPMS/$source" ) { |
204 |
$found++; |
push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source"; |
205 |
last; |
$changed{$repo}++; |
206 |
} elsif ( -f "$repo/SRPMS/$source" ) { |
} |
207 |
print "Found missing source $repo/SRPMS/$source for ".$rpm->as_nvre()."\n"; |
$srcrepohash{$repo}{$source}++; |
208 |
$srcrepohash{$repo}{$source}++; |
$found++; |
209 |
$found++; |
last; |
210 |
} |
} elsif ( -f "$repo/SRPMS/$source" ) { |
211 |
} |
print "Found missing source $repo/SRPMS/$source for ".$rpm->as_nvre()."\n"; |
212 |
print "Can't find source for ".$rpm->as_nvre()."\n" unless $found; |
$srcrepohash{$repo}{$source}++; |
213 |
} |
$found++; |
214 |
} |
} |
215 |
|
} |
216 |
foreach my $rpm ( keys %{$srcrepohash{$repo}} ) { |
print "Can't find source for ".$rpm->as_nvre()."\n" unless $found; |
217 |
unless ( $srcrepohash{$repo}{$rpm} ) { |
} |
218 |
push @remove, "$repo/SRPMS/$rpm"; |
} |
219 |
$changed{$repo}++; |
|
220 |
} |
foreach my $rpm ( keys %{$srcrepohash{$repo}} ) { |
221 |
} |
unless ( $srcrepohash{$repo}{$rpm} ) { |
222 |
|
push @remove, "$repo/SRPMS/$rpm"; |
223 |
|
$changed{$repo}++; |
224 |
|
} |
225 |
|
} |
226 |
} |
} |
227 |
|
|
228 |
print "\n"; |
print "\n"; |
229 |
foreach my $repo ( sort keys %copy ) { |
foreach my $repo ( sort keys %copy ) { |
230 |
foreach my $rpm ( sort keys %{{ map { $_ => 1 } @{$copy{$repo}} }} ) { |
foreach my $rpm ( sort keys %{{ map { $_ => 1 } @{$copy{$repo}} }} ) { |
231 |
print "copying $rpm to $repo/\n"; |
print "copying $rpm to $repo/\n"; |
232 |
system(qw(cp --preserve=timestamps), $rpm, "$repo/"); |
system(qw(cp --preserve=timestamps), $rpm, "$repo/"); |
233 |
} |
} |
234 |
} |
} |
235 |
|
|
236 |
print "\n"; |
print "\n"; |
237 |
foreach my $rpm ( sort keys %{{ map { $_ => 1 } @remove }} ) { |
foreach my $rpm ( sort keys %{{ map { $_ => 1 } @remove }} ) { |
238 |
print "removing $rpm\n"; |
print "removing $rpm\n"; |
239 |
unlink $rpm; |
unlink $rpm; |
240 |
} |
} |
241 |
|
|
242 |
print "\n"; |
print "\n"; |
243 |
foreach my $repo ( sort keys %changed ) { |
foreach my $repo ( sort keys %changed ) { |
244 |
next if $repo =~ m{^/builds}; |
next if $repo =~ m{^$stagedir}; |
245 |
|
|
246 |
print "rebuilding $repo/i386...\n"; |
my $dir=`readlink -f $repo/$arch`; |
247 |
system(qw(createrepo), "$repo/i386"); |
chomp $dir; |
248 |
system(qw(repoview), "$repo/i386"); |
print "rebuilding $dir...\n"; |
249 |
|
system(qw(createrepo), "$dir"); |
250 |
|
system(qw(repoview), "$dir"); |
251 |
} |
} |
252 |
|
|