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