50 |
"$builds/SRPMS", |
"$builds/SRPMS", |
51 |
); |
); |
52 |
|
|
|
my %repohash; |
|
|
my %srcrepohash; |
|
|
my %changed; |
|
|
my %copy; |
|
|
my @remove; |
|
|
|
|
53 |
my $rpm_flags = RPM2->vsf_nodsaheader | RPM2->vsf_nodsa; |
my $rpm_flags = RPM2->vsf_nodsaheader | RPM2->vsf_nodsa; |
54 |
|
|
55 |
%{$srcrepohash{$stagedir}} = map { $_ => 0 } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, "$stagedir/SRPMS" ); |
my @rpms; |
56 |
closedir SRPMS; |
my %srpms; |
57 |
|
my %sources; |
58 |
|
my %changed; |
59 |
|
my %copy; |
60 |
|
|
61 |
foreach my $repo ( @repos ) { |
foreach my $repo ( @repos ) { |
62 |
if ( $repo =~ m{^($releasedir/$smerel/sme[^/]*)/} ) { |
my $r = $repo; |
63 |
my $srcrepo = $1; |
if ( $repo =~ m{$stagedir/RPMS} ) { |
64 |
|
$r = $stagedir; |
65 |
%{$srcrepohash{$srcrepo}} = map { $_ => 0 } grep { /\.rpm$/ } readdir SRPMS if ( opendir SRPMS, "$srcrepo/SRPMS" ); |
} elsif ( $repo =~ m{$builds/RPMS} ) { |
66 |
closedir SRPMS; |
$r = 'builds'; |
67 |
} |
} elsif ( $repo =~ m{^($releasedir/$smerel/sme[^/]*)/} ) { |
68 |
|
$r = $1; |
69 |
opendir RPMS, $repo; |
} |
70 |
foreach my $rpm ( grep { m{\.rpm} } readdir RPMS ) { |
|
71 |
my $header = RPM2->open_package("$repo/$rpm", $rpm_flags); |
if ( $r ne 'builds' ) { |
72 |
my $pkg = $header->tag("NAME").".".$header->tag("ARCH"); |
opendir SRPMS, "$r/SRPMS" or next; |
73 |
if ( $repo =~ m{$stagedir/RPMS} ) { |
foreach my $srpm ( grep { /\.rpm$/ } readdir SRPMS ) { |
74 |
push @{$repohash{$pkg}{$stagedir}}, $header; |
$srpms{$r}{$srpm} = 0; |
75 |
} elsif ( $repo =~ m{$builds/RPMS} ) { |
$sources{$srpm} = "$r/SRPMS"; |
76 |
push @{$repohash{$pkg}{builds}}, $header; |
} |
77 |
} elsif ( $repo =~ m{^($releasedir/$smerel/sme[^/]*)/} ) { |
closedir SRPMS; |
78 |
my $pos = $1; |
} |
79 |
push @{$repohash{$pkg}{$pos}}, $header; |
|
80 |
} |
opendir RPMS, $repo or next; |
81 |
} |
foreach my $pkg ( reverse sort map { RPM2->open_package("$repo/$_", $rpm_flags); } grep { /\.rpm$/ } readdir RPMS ) { |
82 |
closedir RPMS; |
my $rpm = { name => $pkg->tag("NAME"), |
83 |
|
filename => join("-", map { $pkg->tag($_) } qw/name version release/) . "." . $pkg->tag("ARCH"), |
84 |
|
version => $pkg->tag("VERSION"), |
85 |
|
release => $pkg->tag("RELEASE"), |
86 |
|
repo => $r, |
87 |
|
rpm => $pkg, |
88 |
|
}; |
89 |
|
my $source = $pkg->tag("SOURCERPM"); |
90 |
|
$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; |
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; |
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{$stagedir/RPMS} ) { |
unless ( grep { $_->{name} eq $rpm->{name} && $_->{rpm} gt $rpm->{rpm} } @latest ) { |
114 |
next unless $repohash{$pkg}; |
push @latest, $rpm; |
115 |
if ( $repohash{$pkg}{$stagedir} ) { |
unless ( grep { $_->{repo} eq $stagedir && $_->{filename} eq $rpm->{filename} } @rpms ) { |
116 |
my ($latest, @rest) = sort { $b cmp $a } @{$repohash{$pkg}{$stagedir}}; |
push @{$copy{"$stagedir/RPMS"}}, $rpm->{rpm}->filename; |
117 |
delete $repohash{$pkg}{$stagedir}; |
push @rpms, { name => $rpm->{name}, |
118 |
push @remove, map { $_->filename } @rest if @rest; |
filename => $rpm->{filename}, |
119 |
if ( $repohash{$pkg}{latest} ) { |
version => $rpm->{version}, |
120 |
if ($repohash{$pkg}{latest} ne $latest ) { |
release => $rpm->{release}, |
121 |
push @remove, $latest->filename; |
repo => $stagedir, |
122 |
push @{$copy{"$stagedir/RPMS"}}, $repohash{$pkg}{latest}->filename; |
rpm => $rpm->{rpm}, |
123 |
$repohash{$pkg}{$stagedir} = $repohash{$pkg}{latest}; |
source => $rpm->{source} |
124 |
} else { |
}; |
125 |
$repohash{$pkg}{$stagedir} = $latest; |
} |
126 |
} |
} |
127 |
} else { |
} |
128 |
push @remove, $latest->filename; |
|
129 |
} |
foreach my $rpm ( grep { $_->{repo} eq $stagedir } @rpms ) { |
130 |
} elsif ( $repohash{$pkg}{latest} ) { |
$rpm->{repo} = 'deleted' unless grep { $_->{filename} eq $rpm->{filename} } @latest; |
131 |
push @{$copy{"$stagedir/RPMS"}}, $repohash{$pkg}{latest}->filename; |
} |
132 |
$repohash{$pkg}{$stagedir} = $repohash{$pkg}{latest}; |
|
133 |
} |
my @devel; |
134 |
} elsif ( $repo =~ m{^($releasedir/$smerel/sme[^/]*)/} ) { |
my %versions; |
135 |
my $pos = $1; |
foreach my $rpm ( grep { $_->{repo} eq 'builds' } @rpms ) { |
136 |
next unless $repohash{$pkg}{$pos}; |
next if grep { $_->{name} eq $rpm->{name} && $_->{rpm} ge $rpm->{rpm} } @latest; |
137 |
if ( $pos =~ m{/smedev$} ) { |
|
138 |
next unless $repohash{$pkg}{latest}; |
$versions{$rpm->{name}}{$rpm->{version}}++ unless grep { $_->{name} eq $rpm->{name} && $_->{rpm} eq $rpm->{rpm} } @devel; |
139 |
my @rest = grep { $_ le $repohash{$pkg}{latest} } @{$repohash{$pkg}{$pos}}; |
next if $versions{$rpm->{name}}{$rpm->{version}} > $releases || scalar keys %{$versions{$rpm->{name}}} > $releases; |
140 |
if ( @rest ) { |
print "Possible update " . $rpm->{rpm}->filename . "\n" if grep { $_->{name} eq $rpm->{name} } @latest; |
141 |
push @remove, map { $_->filename } @rest; |
|
142 |
$changed{$pos}++; |
push @devel, $rpm; |
143 |
@{$repohash{$pkg}{$pos}} = grep { $_ gt $repohash{$pkg}{latest} } @{$repohash{$pkg}{$pos}}; |
unless ( grep { $_->{repo} =~ m{/smedev$} && $_->{filename} eq $rpm->{filename} } @rpms ) { |
144 |
delete $repohash{$pkg}{$pos}; |
push @{$copy{"$releasedir/$smerel/smedev/$arch/RPMS"}}, $rpm->{rpm}->filename; |
145 |
} |
$changed{"$releasedir/$smerel/smedev"}++; |
146 |
} elsif ( ref($repohash{$pkg}{$pos}) eq 'ARRAY' ) { |
push @rpms, { name => $rpm->{name}, |
147 |
my ($latest, @rest) = sort { $b cmp $a } @{$repohash{$pkg}{$pos}}; |
filename => $rpm->{filename}, |
148 |
delete $repohash{$pkg}{$pos}; |
version => $rpm->{version}, |
149 |
if ( $repohash{$pkg}{latest} && $repohash{$pkg}{latest} ge $latest ) { |
release => $rpm->{release}, |
150 |
push @rest, $latest; |
repo => "$releasedir/$smerel/smedev", |
151 |
} else { |
rpm => $rpm->{rpm}, |
152 |
$repohash{$pkg}{latest} = $latest; |
source => $rpm->{source} |
153 |
$repohash{$pkg}{$pos} = $latest; |
}; |
154 |
} |
} |
|
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"}++; |
|
|
} |
|
|
} |
|
|
} |
|
155 |
} |
} |
156 |
|
|
157 |
foreach my $pkg ( grep { $repohash{$_}{"$releasedir/$smerel/smedev"} } keys %repohash ) { |
foreach my $rpm ( grep { $_->{repo} =~ m{/smedev$} } @rpms ) { |
158 |
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"}++; |
|
|
} |
|
|
} |
|
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; |
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 = $rpm->tag("SOURCERPM")); |
push @sources, $src if (($src = $srpm) =~ s/\.[0-3]\.el\d+\.rf\./\.rf\./); |
170 |
push @sources, $src if (($src = $rpm->tag("SOURCERPM")) =~ s/\.el\d\.rf\./\.rf\./); |
push @sources, $src if (($src = $srpm) =~ s/\.(el|fc)\d\.at//); |
171 |
push @sources, $src if (($src = $rpm->tag("SOURCERPM")) =~ s/\.[0-3]\.el\d+\.rf\./\.rf\./); |
push @sources, $src if (($src = $srpm) =~ s/\.at//); |
172 |
push @sources, $src if (($src = $rpm->tag("SOURCERPM")) =~ s/\.(el|fc)\d\.at//); |
push @sources, $src if (($src = $srpm) =~ s/\.(el|fc)\d//); |
173 |
push @sources, $src if (($src = $rpm->tag("SOURCERPM")) =~ s/\.at//); |
push @sources, $src if (($src = $srpm) =~ s/\.\d+\.(el|fc)\d//); |
174 |
push @sources, $src if (($src = $rpm->tag("SOURCERPM")) =~ s/\.(el|fc)\d//); |
|
175 |
push @sources, $src if (($src = $rpm->tag("SOURCERPM")) =~ s/\.\d+\.(el|fc)\d//); |
my $found = 0; |
176 |
$src = $rpm->tag("SOURCERPM"); |
my $repo = $rpm->{repo}; |
177 |
|
foreach my $source ( @sources ) { |
178 |
my $found = 0; |
if ( $sources{$source} ) { |
179 |
foreach my $source ( @sources ) { |
unless ( -f "$repo/SRPMS/$source" ) { |
180 |
if ( $sources{$source} ) { |
push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source"; |
181 |
unless ( -f "$repo/SRPMS/$source" ) { |
$changed{$repo}++ unless $repo eq $stagedir; |
182 |
push @{$copy{"$repo/SRPMS"}}, "$sources{$source}/$source"; |
} |
183 |
$changed{$repo}++; |
$srpms{$repo}{$source}++; |
184 |
} |
$found++; |
185 |
$srcrepohash{$repo}{$source}++; |
last; |
186 |
$found++; |
} |
187 |
last; |
} |
188 |
} elsif ( -f "$repo/SRPMS/$source" ) { |
print "Can't find source for ".$rpm->{rpm}->filename."\n" unless $found; |
189 |
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; |
|
|
} |
|
|
} |
|
190 |
|
|
191 |
foreach my $rpm ( keys %{$srcrepohash{$repo}} ) { |
my @remove; |
192 |
unless ( $srcrepohash{$repo}{$rpm} ) { |
foreach my $repo ( keys %srpms ) { |
193 |
push @remove, "$repo/SRPMS/$rpm"; |
foreach my $rpm ( keys %{$srpms{$repo}} ) { |
194 |
$changed{$repo}++; |
unless ( $srpms{$repo}{$rpm} ) { |
195 |
} |
push @remove, "$repo/SRPMS/$rpm"; |
196 |
} |
$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 ( @{$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 ( @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 ) { |
|
next if $repo =~ m{^$stagedir}; |
|
|
|
|
217 |
my $dir=`readlink -f $repo/$arch`; |
my $dir=`readlink -f $repo/$arch`; |
218 |
chomp $dir; |
chomp $dir; |
219 |
print "rebuilding $dir...\n"; |
print "rebuilding $dir...\n"; |
220 |
system(qw(createrepo), "$dir"); |
system(qw(createrepo), "$dir"); |
221 |
system(qw(repoview), "$dir"); |
system(qw(repoview), "$dir"); |
222 |
} |
} |
|
|
|