Skip to content

Commit 88dba53

Browse files
committed
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.
1 parent f426c6e commit 88dba53

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lib/ExtUtils/MM_Any.pm

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,8 @@ sub _fix_metadata_before_conversion {
11841184

11851185
return unless _has_cpan_meta;
11861186

1187+
my $generated_metadata = $self->{generated_metadata};
1188+
11871189
my $bad_version = $metadata->{version} &&
11881190
!CPAN::Meta::Validator->new->version( 'version', $metadata->{version} );
11891191
# just delete all invalid versions
@@ -1236,13 +1238,27 @@ sub _fix_metadata_before_conversion {
12361238
$meta = bless $metadata, 'CPAN::Meta';
12371239
}
12381240

1241+
1242+
my $gen_license;
1243+
$gen_license = $generated_metadata->as_struct({version => 2})->{license}
1244+
if $generated_metadata;
12391245
my $now_license = $meta->as_struct({ version => 2 })->{license};
1240-
if ($self->{LICENSE} and $self->{LICENSE} ne 'unknown' and
1241-
@{$now_license} == 1 and $now_license->[0] eq 'unknown'
1242-
) {
1243-
warn "Invalid LICENSE value '$self->{LICENSE}' ignored\n";
1246+
1247+
if ($self->{LICENSE} and $self->{LICENSE} ne 'unknown') {
1248+
if (@{$now_license} == 1 and $now_license->[0] eq 'unknown') {
1249+
if (!$gen_license or (@{$gen_license} == 1 and $gen_license->[0] eq "unknown")) {
1250+
warn "Invalid LICENSE value '$self->{LICENSE}' ignored\n";
1251+
} else {
1252+
$meta->{license}= $generated_metadata->{license};
1253+
}
1254+
}
1255+
if ($gen_license and $now_license and "@$gen_license" ne "@$now_license") {
1256+
warn "Your META.yml has a different license (@$now_license) than your Makefile.PL (@$gen_license)\n";
1257+
}
12441258
}
12451259

1260+
$self->{generated_metadata} ||= $meta;
1261+
12461262
$meta;
12471263
}
12481264

0 commit comments

Comments
 (0)