aboutsummaryrefslogtreecommitdiffstats
path: root/URPM
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-09-10 15:16:05 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-09-10 15:16:05 +0000
commit5fae99fe03b435f83f03eb4e091fa9ca556952f2 (patch)
treedb0a3d324e12d2f4dafa2e0699e5eaec7d278573 /URPM
parent06e1c2c6830806b1a73e57eefefc1e159a78f901 (diff)
downloadperl-URPM-5fae99fe03b435f83f03eb4e091fa9ca556952f2.tar
perl-URPM-5fae99fe03b435f83f03eb4e091fa9ca556952f2.tar.gz
perl-URPM-5fae99fe03b435f83f03eb4e091fa9ca556952f2.tar.bz2
perl-URPM-5fae99fe03b435f83f03eb4e091fa9ca556952f2.tar.xz
perl-URPM-5fae99fe03b435f83f03eb4e091fa9ca556952f2.zip
create _find_chosen_packages__sort() out of find_chosen_packages()
Diffstat (limited to 'URPM')
-rw-r--r--URPM/Resolve.pm16
1 files changed, 11 insertions, 5 deletions
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm
index 0cab240..a1a8a89 100644
--- a/URPM/Resolve.pm
+++ b/URPM/Resolve.pm
@@ -143,10 +143,19 @@ sub find_chosen_packages {
#- probability of being chosen) and ask the user.
#- Packages with more compatibles architectures are always preferred.
#- Puts the results in @chosen. Other are left unordered.
- foreach my $p (values(%packages)) {
+ foreach my $p (values(%$packages)) {
_set_flag_installed_and_upgrade_if_no_newer($db, $p);
}
+ _find_chosen_packages__sort($urpm, $db, \%packages);
+ } else {
+ values(%packages);
+ }
+}
+
+sub _find_chosen_packages__sort {
+ my ($urpm, $db, $packages) = @_;
+
my ($best, @other) = sort {
$a->[1] <=> $b->[1] #- we want the lowest (ie preferred arch)
|| $b->[2] <=> $a->[2]; #- and the higher
@@ -155,7 +164,7 @@ sub find_chosen_packages {
$score += 2 if $_->flag_requested;
$score += $_->flag_upgrade ? 1 : -1 if $_->flag_installed;
[ $_, $_->is_arch_compat, $score ];
- } values %packages;
+ } values %$packages;
my @chosen_with_score = ($best, grep { $_->[1] == $best->[1] && $_->[2] == $best->[2] } @other);
my @chosen = map { $_->[0] } @chosen_with_score;
@@ -213,9 +222,6 @@ sub find_chosen_packages {
sort_package_result($urpm, @chosen_other_en),
sort_package_result($urpm, @chosen_other),
sort_package_result($urpm, @chosen_bad_locales);
- } else {
- return values(%packages);
- }
}
sub find(&@) {