From f426c6e78f1b862a364002ec7b0c6a29c0f4a4d1 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Tue, 28 Feb 2023 15:58:24 +0100 Subject: [PATCH 1/2] MM_Any.pm: in _mymeta_from_meta deal with underbars in version more gracefully Use eval to deal with underbars in the version number. --- lib/ExtUtils/MM_Any.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ExtUtils/MM_Any.pm b/lib/ExtUtils/MM_Any.pm index 173b673cb..9fc2ddc63 100644 --- a/lib/ExtUtils/MM_Any.pm +++ b/lib/ExtUtils/MM_Any.pm @@ -1671,7 +1671,7 @@ sub _mymeta_from_meta { # rolled their own tarball rather than using "make dist". if ($meta->{generated_by} && $meta->{generated_by} =~ /ExtUtils::MakeMaker version ([\d\._]+)/) { - my $eummv = do { no warnings; $1+0; }; + my $eummv = do { no warnings; eval("$1") + 0; }; # deal with underbars gracefully if ($eummv < 6.2501) { return; } From 88dba539450852d5ec791c2902152d442909115c Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Tue, 28 Feb 2023 16:40:49 +0100 Subject: [PATCH 2/2] MM_Any.pm - deal with license discrepancy between META.yml and Makefile.PL Detect if the generated license metadata from Makefile.PL is different from that in the META.yml and warn about it. Also do not complain about it being "unknown" when in fact it is being overiden by the META.yml file. --- lib/ExtUtils/MM_Any.pm | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/ExtUtils/MM_Any.pm b/lib/ExtUtils/MM_Any.pm index 9fc2ddc63..5066c25fd 100644 --- a/lib/ExtUtils/MM_Any.pm +++ b/lib/ExtUtils/MM_Any.pm @@ -1184,6 +1184,8 @@ sub _fix_metadata_before_conversion { return unless _has_cpan_meta; + my $generated_metadata = $self->{generated_metadata}; + my $bad_version = $metadata->{version} && !CPAN::Meta::Validator->new->version( 'version', $metadata->{version} ); # just delete all invalid versions @@ -1236,13 +1238,27 @@ sub _fix_metadata_before_conversion { $meta = bless $metadata, 'CPAN::Meta'; } + + my $gen_license; + $gen_license = $generated_metadata->as_struct({version => 2})->{license} + if $generated_metadata; my $now_license = $meta->as_struct({ version => 2 })->{license}; - if ($self->{LICENSE} and $self->{LICENSE} ne 'unknown' and - @{$now_license} == 1 and $now_license->[0] eq 'unknown' - ) { - warn "Invalid LICENSE value '$self->{LICENSE}' ignored\n"; + + if ($self->{LICENSE} and $self->{LICENSE} ne 'unknown') { + if (@{$now_license} == 1 and $now_license->[0] eq 'unknown') { + if (!$gen_license or (@{$gen_license} == 1 and $gen_license->[0] eq "unknown")) { + warn "Invalid LICENSE value '$self->{LICENSE}' ignored\n"; + } else { + $meta->{license}= $generated_metadata->{license}; + } + } + if ($gen_license and $now_license and "@$gen_license" ne "@$now_license") { + warn "Your META.yml has a different license (@$now_license) than your Makefile.PL (@$gen_license)\n"; + } } + $self->{generated_metadata} ||= $meta; + $meta; }