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