aboutsummaryrefslogtreecommitdiffstats
path: root/URPM
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-08-12 11:29:58 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-08-12 11:29:58 +0000
commit1ef4588c1e65bae444f1778c9ea6b1ced8db7bcc (patch)
tree25395c94aec196259226ccd253ea13dae1f6740d /URPM
parent2665dc703d726e66eeb8d1eb8f1394396e86f443 (diff)
downloadperl-URPM-1ef4588c1e65bae444f1778c9ea6b1ced8db7bcc.tar
perl-URPM-1ef4588c1e65bae444f1778c9ea6b1ced8db7bcc.tar.gz
perl-URPM-1ef4588c1e65bae444f1778c9ea6b1ced8db7bcc.tar.bz2
perl-URPM-1ef4588c1e65bae444f1778c9ea6b1ced8db7bcc.tar.xz
perl-URPM-1ef4588c1e65bae444f1778c9ea6b1ced8db7bcc.zip
- sort choices per media, then per version
nb: on 2004-12-13, rgs replaced "$a->id <=> $b->id" with "$b->compare_pkg($a) || $a->id <=> $b->id" Return the list of chosen packages sorted by descending version (bug #12645). the end result is the sorting by media was dropped :-/
Diffstat (limited to 'URPM')
-rw-r--r--URPM/Resolve.pm33
1 files changed, 28 insertions, 5 deletions
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm
index f0184fa..2b8b7bc 100644
--- a/URPM/Resolve.pm
+++ b/URPM/Resolve.pm
@@ -181,16 +181,39 @@ sub find_chosen_packages {
#- sort packages in order to have preferred ones first
#- (this means good locales, no locales, bad locales).
- return (sort sort_package_result @chosen_good_locales),
- (sort sort_package_result @chosen_other_en),
- (sort sort_package_result @chosen_other),
- (sort sort_package_result @chosen_bad_locales);
+ return sort_package_result($urpm, @chosen_good_locales),
+ 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 sort_package_result { $b->compare_pkg($a) || $a->id <=> $b->id }
+sub find(&@) {
+ my $f = shift;
+ $f->($_) and return $_ foreach @_;
+ undef;
+}
+sub pkg2media {
+ my ($mediums, $p) = @_;
+ my $id = $p->id;
+ find { $id >= $_->{start} && $id <= $_->{end} } @$mediums;
+}
+
+sub sort_package_result {
+ my ($urpm, @l) = @_;
+ if ($urpm->{media}) {
+ map { $_->[0] } sort {
+ $a->[1] != $b->[1] ?
+ $a->[0]->id <=> $b->[0]->id :
+ $b->[0]->compare_pkg($a->[0]);
+ } map { [ $_, pkg2media($urpm->{media}, $_) ] } @l;
+ } else {
+ $urpm->{debug_URPM}("can't sort choices by media") if $urpm->{debug_URPM};
+ sort { $b->compare_pkg($a) || $a->id <=> $b->id } @l;
+ }
+}
#- return unresolved requires of a package (a new one or an existing one).
sub unsatisfied_requires {