From b8a54b0d52da0193ad9290f85cc95b279e60ca23 Mon Sep 17 00:00:00 2001 From: Ed J Date: Sun, 26 Jul 2026 18:52:13 +0100 Subject: [PATCH 1/2] Add Alien::Build::Meta->has_requires - #431 --- Changes | 1 + README.md | 9 +++++++++ lib/Alien/Build.pm | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/Changes b/Changes index 0126529e..3dc97373 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ Revision history for {{$dist->name}} {{$NEXT}} - Added CPU arch detection support for illumos (Marcel Telka++ gh#427) + - Add Alien::Build::Meta->has_requires (gh#431) 2.84 2024-10-28 18:51:39 -0600 - Added is_system_install and is_share_install methods to diff --git a/README.md b/README.md index 1879325c..a61f5fe1 100644 --- a/README.md +++ b/README.md @@ -991,6 +991,15 @@ Add the requirement to the given phase. Phase should be one of: - share - system +## has\_requires + +``` +if (Alien::Build->meta->has_requires($phase, $module_pat, ...)) {...} +``` + +Tests to see if the given phase has any of the given substrings as +a requirement. Phase as ["add\_requires"](#add_requires). + ## interpolator ```perl diff --git a/lib/Alien/Build.pm b/lib/Alien/Build.pm index 23cd55fa..b337e2f4 100644 --- a/lib/Alien/Build.pm +++ b/lib/Alien/Build.pm @@ -2132,6 +2132,28 @@ sub add_requires $self; } +=head2 has_requires + + if (Alien::Build->meta->has_requires($phase, $module_pat, ...)) {...} + +Tests to see if the given phase has any of the given substrings as +a requirement. Phase as L. + +=cut + +sub has_requires +{ + my $self = shift; + my $phase = shift; + my @has = keys %{ $self->{require}->{$phase} }; + while(@_) + { + my $pattern = shift; + return 1 if grep index($_, $pattern) != -1, @has; + } + return; +} + =head2 interpolator my $interpolator = $build->meta->interpolator; From f6f2a4a354728a30054bd8f5a7e9018493d0ac9e Mon Sep 17 00:00:00 2001 From: Ed J Date: Sun, 26 Jul 2026 18:39:30 +0100 Subject: [PATCH 2/2] use has_requires to detect we're using Download::GitHub - #431 --- Changes | 1 + lib/Alien/Build.pm | 4 ++-- lib/Alien/Build/Plugin/Download/Negotiate.pm | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 3dc97373..ca88eb3e 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for {{$dist->name}} {{$NEXT}} - Added CPU arch detection support for illumos (Marcel Telka++ gh#427) - Add Alien::Build::Meta->has_requires (gh#431) + - Fix false warning in Download::Negotiate by detecting Download::GitHub (gh#431) 2.84 2024-10-28 18:51:39 -0600 - Added is_system_install and is_share_install methods to diff --git a/lib/Alien/Build.pm b/lib/Alien/Build.pm index b337e2f4..ca67dcdc 100644 --- a/lib/Alien/Build.pm +++ b/lib/Alien/Build.pm @@ -2149,9 +2149,9 @@ sub has_requires while(@_) { my $pattern = shift; - return 1 if grep index($_, $pattern) != -1, @has; + for (@has) { return 1 if index($_, $pattern) != -1; } } - return; + return (); } =head2 interpolator diff --git a/lib/Alien/Build/Plugin/Download/Negotiate.pm b/lib/Alien/Build/Plugin/Download/Negotiate.pm index abd9a938..061a874e 100644 --- a/lib/Alien/Build/Plugin/Download/Negotiate.pm +++ b/lib/Alien/Build/Plugin/Download/Negotiate.pm @@ -247,7 +247,7 @@ sub init } } - if($self->url =~ /^http.*github.com.*releases$/) + if($self->url =~ /^http.*github.com.*releases$/ && !$meta->has_requires('configure', 'Download::GitHub')) { Alien::Build->log('!! WARNING !! WARNING !!'); Alien::Build->log('!! WARNING !! It looks like this alien is using the regular download negotiator');