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