From f647c533c77edfd66e0f7e21ddd86fad8b29075b Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 1 Oct 2007 16:02:45 +0000 Subject: create _find_required_package__kernel_source() out of _find_required_package__sort() --- URPM/Resolve.pm | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'URPM/Resolve.pm') diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm index 23656a0..a9befc6 100644 --- a/URPM/Resolve.pm +++ b/URPM/Resolve.pm @@ -203,31 +203,9 @@ sub _find_required_package__sort { return [ $chosen[0] ]; } - #- prefer kernel-source-stripped over kernel-source - if ($chosen[0]->name =~ /^kernel-(.*source-|.*-devel-)/) { - - my @l = grep { - if ($_->name =~ /^kernel-.*source-stripped-(.*)/) { - my $version = quotemeta($1); - find { - $_->name =~ /-$version$/ && ($_->flag_installed || $_->flag_selected); - } $urpm->packages_providing('kernel'); - } elsif ($_->name =~ /(kernel-.*)-devel-(.*)/) { - my $kernel = "$1-$2"; - _is_selected_or_installed($urpm, $db, $kernel); - } elsif ($_->name =~ /^kernel-.*source-/) { - #- hopefully we don't have a media with kernel-source but not kernel-source-stripped nor kernel-.*-devel - 0; - } else { - $urpm->{debug_URPM}("unknown kernel-source package " . $_->fullname) if $urpm->{debug_URPM}; - 0; - } - } @chosen; - - if (@l) { - $urpm->{debug_URPM}("packageCallbackChoices: kernel source chosen " . join(",", map { $_->name } @l) . " in " . join(",", map { $_->name } @chosen)) if $urpm->{debug_URPM}; - return \@l, \@l; - } + if (my @kernel_source = _find_required_package__kernel_source($urpm, $db, \@chosen)) { + $urpm->{debug_URPM}("packageCallbackChoices: kernel source chosen " . join(",", map { $_->name } @kernel_source) . " in " . join(",", map { $_->name } @chosen)) if $urpm->{debug_URPM}; + return \@kernel_source, \@kernel_source; } if ($urpm->{media}) { @@ -255,6 +233,31 @@ sub _find_required_package__sort { [ map { $_->[0] } @chosen_with_score ], [ map { $_->[0] } @prefered ]; } +sub _find_required_package__kernel_source { + my ($urpm, $db, $choices) = @_; + + #- prefer kernel-source-stripped over kernel-source + $choices->[0]->name =~ /^kernel-(.*source-|.*-devel-)/ or return; + + my @l = grep { + if ($_->name =~ /^kernel-.*source-stripped-(.*)/) { + my $version = quotemeta($1); + find { + $_->name =~ /-$version$/ && ($_->flag_installed || $_->flag_selected); + } $urpm->packages_providing('kernel'); + } elsif ($_->name =~ /(kernel-.*)-devel-(.*)/) { + my $kernel = "$1-$2"; + _is_selected_or_installed($urpm, $db, $kernel); + } elsif ($_->name =~ /^kernel-.*source-/) { + #- hopefully we don't have a media with kernel-source but not kernel-source-stripped nor kernel-.*-devel + 0; + } else { + $urpm->{debug_URPM}("unknown kernel-source package " . $_->fullname) if $urpm->{debug_URPM}; + 0; + } + } @$choices; +} + #- Packages that require locales-xxx when the corresponding locales are #- already installed should be preferred over packages that require locales #- which are not installed. -- cgit v1.2.1