summaryrefslogtreecommitdiffstats
path: root/urpm
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
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')
-rw-r--r--urpm/args.pm3
-rw-r--r--urpm/select.pm33
2 files changed, 35 insertions, 1 deletions
diff --git a/urpm/args.pm b/urpm/args.pm
index 80419d78..efe0349e 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -133,6 +133,7 @@ my %options_spec = (
'norebuild!' => sub { $urpm->{options}{'build-hdlist-on-error'} = !$_[1] },
'test!' => \$::test,
'skip=s' => \$options{skip},
+ 'prefer=s' => \$options{prefer},
'root=s' => sub {
require File::Spec;
$urpm->{root} = File::Spec->rel2abs($_[1]);
@@ -359,7 +360,7 @@ foreach my $k ("help|h", "version", "no-locales", "test!", "force", "root=s", "u
{
$options_spec{urpme}{$k} = $options_spec{urpmi}{$k};
}
-foreach my $k ("root=s", "nolock", "use-distrib=s", "skip=s")
+foreach my $k ("root=s", "nolock", "use-distrib=s", "skip=s", "prefer=s")
{
$options_spec{urpmq}{$k} = $options_spec{urpmi}{$k};
}
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