Skip to content

Fix strange warning from existing META.yml license info conflicting with Makefile.PL #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions lib/ExtUtils/MM_Any.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -1671,7 +1687,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;
}
Expand Down