aboutsummaryrefslogtreecommitdiffstats
path: root/URPM/Resolve.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-02-25 09:19:35 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-02-25 09:19:35 +0000
commit9a3afbdb4783144473466f73283a0e93357c2f13 (patch)
tree50736848421776ebe3edeb8f0ecc4a442dba4674 /URPM/Resolve.pm
parentd6553e80c9c2c71549f46433eb1073dd5627f93c (diff)
downloadperl-URPM-9a3afbdb4783144473466f73283a0e93357c2f13.tar
perl-URPM-9a3afbdb4783144473466f73283a0e93357c2f13.tar.gz
perl-URPM-9a3afbdb4783144473466f73283a0e93357c2f13.tar.bz2
perl-URPM-9a3afbdb4783144473466f73283a0e93357c2f13.tar.xz
perl-URPM-9a3afbdb4783144473466f73283a0e93357c2f13.zip
- sort choices on virtual package by provided version (#12645)
Diffstat (limited to 'URPM/Resolve.pm')
-rw-r--r--URPM/Resolve.pm31
1 files changed, 25 insertions, 6 deletions
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm
index 53830cb..492a498 100644
--- a/URPM/Resolve.pm
+++ b/URPM/Resolve.pm
@@ -111,13 +111,30 @@ sub _is_selected_or_installed {
$db->traverse_tag('name', [ $name ], undef) > 0;
}
+sub provided_version_that_overlaps {
+ my ($pkg, $provide_name) = @_;
+
+ my $version;
+ foreach my $property ($pkg->provides) {
+ my ($n, undef, $v) = property2name_op_version($property) or next;
+ $n eq $provide_name or next;
+
+ if ($version) {
+ $version = $v if URPM::rpmvercmp($v, $version) > 0;
+ } else {
+ $version = $v;
+ }
+ }
+ $version;
+}
+
# deprecated function name
sub find_chosen_packages { &find_required_package }
#- side-effects: flag_install, flag_upgrade (and strict_arch_check_installed cache)
sub find_required_package {
my ($urpm, $db, $state, $id_prop) = @_;
- my %packages;
+ my (%packages, %provided_version);
my $strict_arch = strict_arch($urpm);
my $may_add_to_packages = sub {
@@ -152,6 +169,7 @@ sub find_required_package {
#- determine if this package is better than a possibly previously chosen package.
$pkg->flag_selected || exists $state->{selected}{$pkg->id} and return [$pkg];
!$strict_arch || strict_arch_check_installed($db, $pkg) or next;
+ $provided_version{$pkg} = provided_version_that_overlaps($pkg, $name);
$may_add_to_packages->($pkg);
}
}
@@ -180,7 +198,7 @@ sub find_required_package {
return \@kmod, \@kmod;
}
- _find_required_package__sort($urpm, $db, \@packages);
+ _find_required_package__sort($urpm, $db, \@packages, \%provided_version);
} else {
\@packages;
}
@@ -188,16 +206,17 @@ sub find_required_package {
# nb: _set_flag_installed_and_upgrade_if_no_newer must be done on $packages
sub _find_required_package__sort {
- my ($urpm, $db, $packages) = @_;
+ my ($urpm, $db, $packages, $provided_version) = @_;
- my ($best, @other) = sort {
- $a->[1] <=> $b->[1] #- we want the lowest (ie preferred arch)
+ my ($best, @other) = sort {
+ URPM::rpmvercmp($b->[3], $a->[3]) #- highest provided version
+ || $a->[1] <=> $b->[1] #- we want the lowest (ie preferred arch)
|| $b->[2] <=> $a->[2]; #- and the higher
} map {
my $score = 0;
$score += 2 if $_->flag_requested;
$score += $_->flag_upgrade ? 1 : -1 if $_->flag_installed;
- [ $_, $_->is_arch_compat, $score ];
+ [ $_, $_->is_arch_compat, $score, $provided_version->{$_} || 0 ];
} @$packages;
my @chosen_with_score = ($best, grep { $_->[1] == $best->[1] && $_->[2] == $best->[2] } @other);