summaryrefslogtreecommitdiffstats
path: root/urpm/select.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-08-11 16:25:18 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-08-11 16:25:18 +0000
commit57ce115d84224fe8dd75f19490f788fe8acf198c (patch)
treeb66cbe8793ca5291d0e7ea7f73bba593296fe949 /urpm/select.pm
parentf0c0ba3c176af4afd6659f532541043c7143e0e8 (diff)
downloadurpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.tar
urpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.tar.gz
urpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.tar.bz2
urpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.tar.xz
urpmi-57ce115d84224fe8dd75f19490f788fe8acf198c.zip
- urpmi
o handle preferred choices (through --prefer, /etc/urpmi/prefer.list and /etc/urpmi/prefer.vendor.list)
Diffstat (limited to 'urpm/select.pm')
-rw-r--r--urpm/select.pm33
1 files changed, 33 insertions, 0 deletions
diff --git a/urpm/select.pm b/urpm/select.pm
index 7544e83b..978f88bb 100644
--- a/urpm/select.pm
+++ b/urpm/select.pm
@@ -4,6 +4,7 @@ package urpm::select;
use urpm::msg;
use urpm::util;
+use urpm::sys;
use URPM;
sub _findindeps {
@@ -248,6 +249,38 @@ sub resolve_dependencies {
$need_restart;
}
+sub cooked_prefer {
+ my ($urpm, $cmdline_prefer) = @_;
+
+ $urpm->{prefer_regexps} ||= [
+ map {
+ m!^/(.*)/$! ? "($1)" : '^' . quotemeta($_) . '$';
+ } map { @$_ }
+ urpm::sys::get_packages_list($urpm->{prefer_list}, $cmdline_prefer),
+ urpm::sys::get_packages_list($urpm->{prefer_vendor_list})
+ ];
+ @{$urpm->{prefer_regexps}};
+}
+
+sub sort_choices {
+ my ($urpm, $choices, $cmdline_prefer) = @_;
+
+ my @prefer;
+ my @l = @$choices;
+ foreach my $re (cooked_prefer($urpm, $cmdline_prefer)) {
+ my ($prefer, $other) = partition { $_->name =~ $re } @l;
+ push @prefer, @$prefer;
+ @l = @$other;
+
+ if (@$prefer) {
+ my $prefer_s = join(',', map { $_->name } @$prefer);
+ my $other_s = join(',', map { $_->name } @l);
+ $urpm->{log}("preferring $prefer_s over $other_s");
+ }
+ }
+ (@prefer, @l);
+}
+
#- find packages to remove.
#- options:
#- bundle