From 98fe1b85f7c0a613343e0def29cc531f7e4d68dd Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sun, 12 Aug 2007 12:15:01 +0000 Subject: - library o urpm::select: new function get_preferred() replacing sort_choices() (for drakx) o get rid of "use of unitialized" when file is unset (for drakx) --- NEWS | 4 ++++ urpm/select.pm | 4 ++-- urpm/sys.pm | 2 +- urpmi | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 9fcf62d1..c679a653 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +- library + o urpm::select: new function get_preferred() replacing sort_choices() + (for drakx) + Version 4.10.0 - 11 August 2007, by Pascal "Pixel" Rigaux - new major release (motivation: urpmi has many new features) diff --git a/urpm/select.pm b/urpm/select.pm index 978f88bb..cc96d9d5 100644 --- a/urpm/select.pm +++ b/urpm/select.pm @@ -262,7 +262,7 @@ sub cooked_prefer { @{$urpm->{prefer_regexps}}; } -sub sort_choices { +sub get_preferred { my ($urpm, $choices, $cmdline_prefer) = @_; my @prefer; @@ -278,7 +278,7 @@ sub sort_choices { $urpm->{log}("preferring $prefer_s over $other_s"); } } - (@prefer, @l); + (\@prefer, \@l); } #- find packages to remove. diff --git a/urpm/sys.pm b/urpm/sys.pm index 612c9ed6..da7736d9 100644 --- a/urpm/sys.pm +++ b/urpm/sys.pm @@ -16,7 +16,7 @@ use POSIX (); sub get_packages_list { my ($file, $o_extra) = @_; my @l = split(/,/, $o_extra || ''); - if (open(my $f, '<', $file)) { + if ($file && open(my $f, '<', $file)) { push @l, <$f>; } [ grep { $_ } map { diff --git a/urpmi b/urpmi index 30a42358..cbbfc663 100755 --- a/urpmi +++ b/urpmi @@ -429,7 +429,8 @@ if (@src_names) { sub ask_choice { my ($urpm, $_db, $_state, $choices, $virtual_pkg_name) = @_; - my @choices = urpm::select::sort_choices($urpm, $choices, $options{prefer}); + my ($prefer, $other) = urpm::select::get_preferred($urpm, $choices, $options{prefer}); + my @choices = (@$prefer, @$other); my (@l) = map { my ($name, $summary) = (scalar($_->fullname), translate($_->summary)); -- cgit v1.2.1