From 149fb8a5a816f6b90c3e39815a4537a46f21d03c Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 14 Sep 2007 14:32:20 +0000 Subject: - create resolve_requested_and_check() which nicely check selection failures - keep_unrequested_dependencies is now a global flag in perl-URPM 2.01 --- perl-install/install/pkgs.pm | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/perl-install/install/pkgs.pm b/perl-install/install/pkgs.pm index b7414f8b2..d65fc7c0d 100644 --- a/perl-install/install/pkgs.pm +++ b/perl-install/install/pkgs.pm @@ -258,6 +258,20 @@ sub select_by_package_names_or_die { } } +sub resolve_requested_and_check { + my ($packages, $state, $requested) = @_; + + my @l = $packages->resolve_requested($packages->{rpmdb}, $state, $requested, + callback_choices => \&packageCallbackChoices); + + if (find { !exists $state->{selected}{$_} } keys %$requested) { + my @rejected = urpm::select::unselected_packages($packages, $state); + log::l("ERROR: selection failed: " . urpm::select::translate_why_unselected($packages, $state, @rejected)); + } + + @l; +} + sub selectPackage { my ($packages, $pkg, $b_base) = @_; @@ -265,12 +279,7 @@ sub selectPackage { $packages->{rpmdb} ||= rpmDbOpen(); - my @l = $packages->resolve_requested($packages->{rpmdb}, $state, packageRequest($packages, $pkg) || {}, - callback_choices => \&packageCallbackChoices); - - if (!exists $state->{selected}{$pkg->id}) { - log::l("ERROR: selecting " . $pkg->name . " failed: " . urpm::select::translate_why_unselected_one($packages, $state, scalar $pkg->fullname)); - } + my @l = resolve_requested_and_check($packages, $state, packageRequest($packages, $pkg) || {}); if ($b_base) { $_->set_flag_base foreach @l; @@ -308,8 +317,7 @@ sub unselectAllPackages { } #- clean state, in order to start with a brand new set... $packages->{state} = {}; - $packages->resolve_requested($packages->{rpmdb}, $packages->{state}, \%keep_selected, - callback_choices => \&packageCallbackChoices); + resolve_requested_and_check($packages, $packages->{state}, \%keep_selected); } sub empty_packages() { @@ -320,6 +328,7 @@ sub empty_packages() { $packages->{log} = \&log::l; $packages->{prefer_vendor_list} = '/etc/urpmi/prefer.vendor.list'; + $packages->{keep_unrequested_dependencies} = 1; $packages; } @@ -374,9 +383,7 @@ sub setSelectedFromCompssList { #- selecting $p. the packages are not selected. my $state = $packages->{state} ||= {}; - my @l = $packages->resolve_requested($packages->{rpmdb}, $state, packageRequest($packages, $p) || {}, - keep_unrequested_dependencies => 1, - callback_choices => \&packageCallbackChoices); + my @l = resolve_requested_and_check($packages, $state, packageRequest($packages, $p) || {}); #- this enable an incremental total size. my $old_nb = $nb; @@ -636,14 +643,9 @@ sub selectPackagesToUpgrade { log::l("selected pkgs to upgrade: " . join(' ', map { $packages->{depslist}[$_]->name } keys %selection)); log::l("resolving dependencies..."); - $packages->resolve_requested($packages->{rpmdb}, $state, \%selection, - callback_choices => \&packageCallbackChoices); + resolve_requested_and_check($packages, $state, \%selection); log::l("...done"); log::l("finally selected pkgs: ", join(" ", sort map { $_->name } grep { $_->flag_selected } @{$packages->{depslist}})); - if ($state->{rejected}) { - require Data::Dumper; - log::l(Data::Dumper::Dumper($state)); - } } sub installTransactionClosure { -- cgit v1.2.1