diff options
author | Gustavo De Nardin <spuk@mandriva.org> | 2007-03-24 10:04:55 +0000 |
---|---|---|
committer | Gustavo De Nardin <spuk@mandriva.org> | 2007-03-24 10:04:55 +0000 |
commit | 54ac05ac9906926bbc5f2c3d047e0d2073f7fc4e (patch) | |
tree | af734e0770ab788e18db2baaf0900b35aa7aba56 /lib | |
parent | 55398d96968ca129b0229f6087aa9bc393a881a4 (diff) | |
download | mga-youri-core-54ac05ac9906926bbc5f2c3d047e0d2073f7fc4e.tar mga-youri-core-54ac05ac9906926bbc5f2c3d047e0d2073f7fc4e.tar.gz mga-youri-core-54ac05ac9906926bbc5f2c3d047e0d2073f7fc4e.tar.bz2 mga-youri-core-54ac05ac9906926bbc5f2c3d047e0d2073f7fc4e.tar.xz mga-youri-core-54ac05ac9906926bbc5f2c3d047e0d2073f7fc4e.zip |
Replaced old code for package section discovery (Mandriva_upload::_get_section()).
This should fix bug #28719.
The new code searches for specific versions first, using only source media
when it exists. This should solve the search order dependency when there are
no duplicates of a package with the same version-release in more than one
section.
The previous code depended on search order to find a section, preferring
source medias, but still searching in binary medias when a section was not
found in the source media, and had a hack to avoid finding /testing
sections.
This /testing avoidance hack caused packages submitted to /testing
subsections to always end up getting section 'contrib/release' (fallback..),
and this in turn made Youri::Submit::Action::Archive to get confused and
remove older packages in other-than-submitted sections.
When a package was submitted to a non-/testing section, and a different
section with older version of that (binary or source) package came first in
the search. For example: package submitted to main/backports, existing also
in main/release, with main/release appearing first in search list, then the
section for it would be found to be main/release, and
Youri::Submit::Action::Archive would remove the older package there.
Another problem would be if the first package processed was the SRPM, with a
"bad" section early in search, the older SRPM in the "bad" section would be
removed, and then binaries on other sections would not be removed, due to
the search preferring the section in which the new SRPM is (the right one).
Etc..
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Youri/Repository/Mandriva_upload.pm | 98 |
1 files changed, 73 insertions, 25 deletions
diff --git a/lib/Youri/Repository/Mandriva_upload.pm b/lib/Youri/Repository/Mandriva_upload.pm index bfc4935..381aee5 100644 --- a/lib/Youri/Repository/Mandriva_upload.pm +++ b/lib/Youri/Repository/Mandriva_upload.pm @@ -276,6 +276,9 @@ sub _get_section { my ($self, $package, $target, $user_context, $app_context) = @_; my $name = $package->get_name(); + my $cname = $package->get_canonical_name(); + my $version = $package->get_version(); + my $release = $package->get_release(); my $section = $user_context->{section}; my $media = $self->_get_media_config($target); my $arch = $package->get_arch(); @@ -293,7 +296,7 @@ sub _get_section { $section = "debug_$section" } - # if section is provided, check this one is defined + # if have section already, check if it exists, and may return immediately if ($section) { print "Using requested section $section\n"; if ($media->{$arch}{$section}) { @@ -302,50 +305,95 @@ sub _get_section { die "FATAL youri: unknown section $section for target $target for arch $arch\n" } } - # try to find section automatically + # else, try to find section automatically + + # pattern for search of src package with specific version-release, + # should be searched first, because we prefer to find the precise + # section a package is already in + my $specific_source_pattern = PACKAGE_CLASS->get_pattern( + $cname, + $version, + $release, + 'src' + ); my $source_pattern = PACKAGE_CLASS->get_pattern( - $package->get_canonical_name(), + $cname, undef, undef, 'src' ); + # if a media has no source media configured, or if it is a debug + # package, we search in binary media + + # pattern for search when a binary media has no src media configured + my $specific_binary_pattern = PACKAGE_CLASS->get_pattern( + $name, + $version, + $release, + $arch + ); + + # last resort pattern: previous existing binary packages my $binary_pattern = PACKAGE_CLASS->get_pattern( - $package->get_name(), - undef, - undef, - $arch + $name, + undef, + undef, + $arch ); - # for each potential section, try to match - # a suitable source patten in source directory - # a suitable binary patten in binary directory + # first try to find section for the specific version, as it is possibly already there + print "Looking for package $name with version $version-$release\n"; foreach my $m (keys %{$media->{$arch}}) { - # do not use testing by default - next if $m =~ /testing/; - next unless - ($media->{src}{$m} && - $self->get_files( - '', - $media->{src}{$m}, - $source_pattern - )) || $self->get_files( - '', - $media->{$arch}{$m}, - $binary_pattern - ); - print "Section is $m\n"; + print " .. section '$m' path '".$media->{$arch}{$m}."'\n" if $self->{_verbose}; + # - prefer source for non-debug packages, use binary if there is no source media configured + # - debug packages must be searched in binary medias, due to their + # src section != binary section; NOTE: should/need we search in + # src medias and add the 'debug_' prefix? + if (!$package->is_debug() && $media->{src}{$m}) { + next unless $self->get_files('', $media->{src}{$m}, $specific_source_pattern); + } else { + next unless $self->get_files('', $media->{$arch}{$m}, $specific_binary_pattern); + } $section = $m; last; } - print STDERR "Can't guess destination: section missing, defaulting to contrib/release\n" unless $section; + # if still not found, try finding any version of the package in a + # /release subsection (safe default: /release is default for cooker, + # should be locked for released distros, and we don't risk wrongly + # choosing /backports, /testing, or /updates); + if (!$section) { + # debug packages should be found by previous specific version search + # NOTE: as above, should/need we search here and add the 'debug_' prefix? + if ($package->is_debug()) { + die "FATAL: debug package $name with version $version-$release not found.\n" + } + + print "Warning: Looking for any section with a package $name of any version\n"; + foreach my $m (keys %{$media->{$arch}}) { + print " .. section '$m' path '".$media->{$arch}{$m}."'\n" if $self->{_verbose}; + next if $m !~ /release/; + # - prefer source + if ($media->{src}{$m}) { + next unless $self->get_files('', $media->{src}{$m}, $source_pattern); + } else { + next unless $self->get_files('', $media->{$arch}{$m}, $binary_pattern); + } + $section = $m; + last; + } + } + + print STDERR "Warning: Can't guess destination: section missing, defaulting to contrib/release\n" unless $section; $section ||= 'contrib/release'; # next time we don't need to search everything again $self->{packages}{$file}{section} = $section; + print "Section is '$section'.\n"; + return $section; } |