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