diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-10-18 08:31:40 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-10-18 08:31:40 +0000 |
commit | 8f7537dbea75d19ad1e0d3d336ec8a6b33a956be (patch) | |
tree | 4e597ee95c98e3318768c10c69dc5264980fc4ab /URPM/Resolve.pm | |
parent | f01beabac78cb5ea46acc64574edf85543663b63 (diff) | |
download | perl-URPM-8f7537dbea75d19ad1e0d3d336ec8a6b33a956be.tar perl-URPM-8f7537dbea75d19ad1e0d3d336ec8a6b33a956be.tar.gz perl-URPM-8f7537dbea75d19ad1e0d3d336ec8a6b33a956be.tar.bz2 perl-URPM-8f7537dbea75d19ad1e0d3d336ec8a6b33a956be.tar.xz perl-URPM-8f7537dbea75d19ad1e0d3d336ec8a6b33a956be.zip |
Patch by Gwenole Beauchesne to prefer packages which have the closest
architecture compatibility over others when version/release are the same
(using rpm's scoring system).
Diffstat (limited to 'URPM/Resolve.pm')
-rw-r--r-- | URPM/Resolve.pm | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm index eafa50f..d6d6011 100644 --- a/URPM/Resolve.pm +++ b/URPM/Resolve.pm @@ -2,6 +2,8 @@ package URPM; use strict; +sub min { my $n = shift; $_ < $n and $n = $_ foreach @_; $n } + #- find candidates packages from a require string (or id), #- take care of direct choices using | sepatator. sub find_candidate_packages { @@ -69,7 +71,7 @@ sub find_chosen_packages { } if (keys(%packages) > 1) { - my ($mode, @chosen, @chosen_good_locales, @chosen_bad_locales, @chosen_other); + my ($mode, @chosen, @chosen_good_locales, @chosen_bad_locales, @chosen_other, $install); #- packages should be preferred if one of their provides is referenced #- in the "requested" hash, or if the package itself is requested (or @@ -86,25 +88,29 @@ sub find_chosen_packages { $p->flag_upgrade and $p->set_flag_upgrade($p->compare_pkg($pp) > 0); }); } + my $arch_score = ($p->is_arch_compat < min map { $_->is_arch_compat } @chosen) ? 10 : 0; if ($p->flag_requested && $p->flag_installed) { - $mode < 3 and @chosen = (); - $mode = 3; + $mode < 3 + $arch_score and @chosen = (); + $mode = 3 + $arch_score; + $install = 1; } elsif ($p->flag_requested) { - $mode < 2 and @chosen = (); - $mode > 2 and next; - $mode = 2; + $mode < 2 + $arch_score and @chosen = (); + $mode > 2 + $arch_score and next; + $mode = 2 + $arch_score; } elsif ($p->flag_installed) { - $mode < 1 and @chosen = (); - $mode > 1 and next; - $mode = 1; + $mode < 1 + $arch_score and @chosen = (); + $mode > 1 + $arch_score and next; + $mode = 1 + $arch_score; } else { - $mode and next; + $mode < $arch_score and @chosen = (); + $mode > $arch_score and next; + $mode = $arch_score; } push @chosen, $p; } #- if several packages are installed, trim the choices. - if (!$urpm->{options}{morechoices} && $mode == 3 && @chosen > 1) { @chosen = ($chosen[0]) } + if (!$urpm->{options}{morechoices} && $install && @chosen > 1) { @chosen = ($chosen[0]) } #- packages that require locales-xxx when the corresponding locales are #- already installed should be preferred over packages that require locales |