summaryrefslogtreecommitdiffstats
path: root/urpm/select.pm
diff options
context:
space:
mode:
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