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; |
|
197 |
foreach my $source ( @sources ) { |
my $found = 0; |
198 |
if ( $sources{$source} ) { |
foreach my $source ( @sources ) { |
199 |
unless ( -f "$repo/SRPMS/$source" ) { |
if ( $sources{$source} ) { |
200 |
push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source"; |
unless ( -f "$repo/SRPMS/$source" ) { |
201 |
$changed{$repo}++; |
push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source"; |
202 |
} |
$changed{$repo}++; |
203 |
$srcrepohash{$repo}{$source}++; |
} |
204 |
$found++; |
$srcrepohash{$repo}{$source}++; |
205 |
last; |
$found++; |
206 |
} elsif ( -f "$repo/SRPMS/$source" ) { |
last; |
207 |
print "Found missing source $repo/SRPMS/$source for ".$rpm->as_nvre()."\n"; |
} elsif ( -f "$repo/SRPMS/$source" ) { |
208 |
$srcrepohash{$repo}{$source}++; |
print "Found missing source $repo/SRPMS/$source for ".$rpm->as_nvre()."\n"; |
209 |
$found++; |
$srcrepohash{$repo}{$source}++; |
210 |
} |
$found++; |
211 |
} |
} |
212 |
print "Can't find source for ".$rpm->as_nvre()."\n" unless $found; |
} |
213 |
} |
print "Can't find source for ".$rpm->as_nvre()."\n" unless $found; |
214 |
} |
} |
215 |
|
} |
216 |
foreach my $rpm ( keys %{$srcrepohash{$repo}} ) { |
|
217 |
unless ( $srcrepohash{$repo}{$rpm} ) { |
foreach my $rpm ( keys %{$srcrepohash{$repo}} ) { |
218 |
push @remove, "$repo/SRPMS/$rpm"; |
unless ( $srcrepohash{$repo}{$rpm} ) { |
219 |
$changed{$repo}++; |
push @remove, "$repo/SRPMS/$rpm"; |
220 |
} |
$changed{$repo}++; |
221 |
} |
} |
222 |
|
} |
223 |
} |
} |
224 |
|
|
225 |
print "\n"; |
print "\n"; |
226 |
foreach my $repo ( sort keys %copy ) { |
foreach my $repo ( sort keys %copy ) { |
227 |
foreach my $rpm ( sort keys %{{ map { $_ => 1 } @{$copy{$repo}} }} ) { |
foreach my $rpm ( sort keys %{{ map { $_ => 1 } @{$copy{$repo}} }} ) { |
228 |
print "copying $rpm to $repo/\n"; |
print "copying $rpm to $repo/\n"; |
229 |
system(qw(cp --preserve=timestamps), $rpm, "$repo/"); |
system(qw(cp --preserve=timestamps), $rpm, "$repo/"); |
230 |
} |
} |
231 |
} |
} |
232 |
|
|
233 |
print "\n"; |
print "\n"; |
234 |
foreach my $rpm ( sort keys %{{ map { $_ => 1 } @remove }} ) { |
foreach my $rpm ( sort keys %{{ map { $_ => 1 } @remove }} ) { |
235 |
print "removing $rpm\n"; |
print "removing $rpm\n"; |
236 |
unlink $rpm; |
unlink $rpm; |
237 |
} |
} |
238 |
|
|
239 |
print "\n"; |
print "\n"; |
240 |
foreach my $repo ( sort keys %changed ) { |
foreach my $repo ( sort keys %changed ) { |
241 |
next if $repo =~ m{^/builds}; |
next if $repo =~ m{^$stagedir}; |
242 |
|
|
243 |
print "rebuilding $repo/i386...\n"; |
my $dir=`readlink -f $repo/$arch`; |
244 |
system(qw(createrepo), "$repo/i386"); |
chomp $dir; |
245 |
system(qw(repoview), "$repo/i386"); |
print "rebuilding $dir...\n"; |
246 |
|
system(qw(createrepo), "$dir"); |
247 |
|
system(qw(repoview), "$dir"); |
248 |
} |
} |
249 |
|
|