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