From f349023599f2fdc021bea2eb6a17c9eaa46aaaea Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 11 Mar 2004 15:01:14 +0000 Subject: - add function packagesProviding() - use it --- perl-install/pkgs.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index f0495b352..a0bb7b0a7 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -132,6 +132,11 @@ sub size2time { } +sub packagesProviding { + my ($packages, $name) = @_; + map { $packages->{depslist}[$_] } keys %{$packages->{provides}{$name} || {}}; +} + #- searching and grouping methods. #- package is a reference to list that contains #- a hash to search by name and @@ -141,8 +146,7 @@ sub packageByName { #- search package with given name and compatible with current architecture. #- take the best one found (most up-to-date). my @packages; - foreach (keys %{$packages->{provides}{$name} || {}}) { - my $pkg = $packages->{depslist}[$_]; + foreach my $pkg (packagesProviding($packages, $name)) { $pkg->is_arch_compat or next; $pkg->name eq $name or next; push @packages, $pkg; @@ -172,14 +176,13 @@ sub packages2kernels { my ($packages) = @_; map { - my $pkg = $packages->{depslist}[$_]; - if (my ($ext, $version) = analyse_kernel_name($pkg->name)) { - { pkg => $pkg, ext => $ext, version => $version }; + if (my ($ext, $version) = analyse_kernel_name($_->name)) { + { pkg => $_, ext => $ext, version => $version }; } else { - log::l("ERROR: unknown package " . $pkg->name . " providing kernel"); + log::l("ERROR: unknown package " . $_->name . " providing kernel"); (); } - } keys %{$packages->{provides}{kernel}}; + } packagesProviding($packages, 'kernel'); } sub bestKernelPackage { -- cgit v1.2.1