diff options
author | Timothy Legge <timlegge@gmail.com> | 2020-03-24 23:51:11 +0000 |
---|---|---|
committer | Timothy Legge <timlegge@gmail.com> | 2020-03-27 02:02:24 +0000 |
commit | e448c9a452906e374d2028e1f85e9cad4adff663 (patch) | |
tree | 0a5c10fada0d0b702784875e0b77fee47ebd01e2 | |
parent | 8c62020a34ea413a515b32fbd97f7782b9810bd1 (diff) | |
download | abuild-e448c9a452906e374d2028e1f85e9cad4adff663.tar.bz2 abuild-e448c9a452906e374d2028e1f85e9cad4adff663.tar.xz |
apkbuild-cpan.in: Avoid processing duplicate modules in parse_deps
-rwxr-xr-x | apkbuild-cpan.in | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/apkbuild-cpan.in b/apkbuild-cpan.in index 254ebb2..9d4f546 100755 --- a/apkbuild-cpan.in +++ b/apkbuild-cpan.in @@ -126,24 +126,31 @@ sub parse_deps { my $distfiles = {}; my $response; my $deps = ""; + my $reqmodlist = ""; + #Get list of unique required modules from all parameters foreach $reqs (@_) { for my $module ($reqs->required_modules) { - if (Module::CoreList->is_core($module)) { - my $perlver = Module::CoreList->first_release($module); - say "$module is part of core perl since $perlver."; - next; - } - next if $module eq 'perl'; + $reqmodlist .= "$module " unless $reqmodlist =~ m/$module/; + } + } - # map module name to package name - $response = $ua->get("https://fastapi.metacpan.org/module/$module"); - $response->is_success or die $response->status_line; - my $moddata = $json->decode($response->decoded_content); - $moddata->{error} and die "Error trying to locate $module: $moddata->{error}\n"; - $distfiles->{$module} = $moddata->{distribution}; + # Check add the require module to $dep if not part of core perl + foreach my $module (split " ", $reqmodlist) { + next if $module eq 'perl'; + if (Module::CoreList->is_core($module)) { + my $perlver = Module::CoreList->first_release($module); + say "$module is part of core perl since $perlver."; + next; } + # map module name to package name + $response = $ua->get("https://fastapi.metacpan.org/module/$module"); + $response->is_success or die $response->status_line; + my $moddata = $json->decode($response->decoded_content); + $moddata->{error} and die "Error trying to locate $module: $moddata->{error}\n"; + $distfiles->{$module} = $moddata->{distribution}; } + # map package names to alpine packages foreach ( keys %{ $distfiles } ) { $response = $ua->get("https://fastapi.metacpan.org/module/$_"); |