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