Skip to content

Commit

Permalink
MM_Any.pm - deal with license discrepancy between META.yml and Makefi…
Browse files Browse the repository at this point in the history
…le.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.
  • Loading branch information
demerphq committed Mar 1, 2023
1 parent f426c6e commit 88dba53
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 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

0 comments on commit 88dba53

Please sign in to comment.