X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=sidebyside;f=lib%2FCPANPLUS%2FDist%2FGentoo.pm;h=51f23d10df4345ac507bf3cefca18a8cd05fd24b;hb=69b45a423d8ce50cc9c3cc8cb22a8822e698fb4f;hp=243253e227f33b9c6cc3c14b9bb64332a5d19134;hpb=befc67bc91691a8ee10b9696d61ea3bb49e5b3d0;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 243253e..51f23d1 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -9,6 +9,7 @@ use File::Path (); use File::Spec; use IPC::Cmd qw/run can_run/; +use Parse::CPAN::Meta (); use CPANPLUS::Error (); @@ -264,7 +265,7 @@ sub prepare { $stat->src("mirror://cpan/modules/by-authors/id/$1/$1$2/$author/" . $mod->package); - $stat->license([ qw/Artistic GPL-2/ ]); + $stat->license($self->intuit_license); my $prereqs = $mod->status->prereqs; my @depends; @@ -290,6 +291,49 @@ sub prepare { return $OK->(); } +=head2 C + +Returns an array reference to a list of Gentoo licences identifiers under which the current distribution is released. + +=cut + +my %dslip_license = ( + p => 'perl', + g => 'gpl', + l => 'lgpl', + b => 'bsd', + a => 'artistic', + 2 => 'artistic_2', +); + +sub intuit_license { + my $self = shift; + my $mod = $self->parent; + + my $dslip = $mod->dslip; + if (defined $dslip and $dslip =~ /\S{4}(\S)/) { + my @licenses = CPANPLUS::Dist::Gentoo::Maps::license_c2g($dslip_license{$1}); + return \@licenses if @licenses; + } + my $extract_dir = $mod->status->extract; + + for my $meta_file (qw/META.json META.yml/) { + my $meta = eval { + Parse::CPAN::Meta::LoadFile(File::Spec->catdir( + $extract_dir, + $meta_file, + )); + } or next; + my $license = $meta->{license}; + if (defined $license) { + my @licenses = CPANPLUS::Dist::Gentoo::Maps::license_c2g($license); + return \@licenses if @licenses; + } + } + + return [ CPANPLUS::Dist::Gentoo::Maps::license_c2g('perl') ]; +} + sub create { my $self = shift; my $stat = $self->status; @@ -508,7 +552,7 @@ sub _skip { shift->_notify(@_, '-- skipping') } Gentoo (L). -L, L (core modules since 5.9.5). +L, L (core modules since 5.9.5), L (since 5.10.1). L, L (since perl 5), L (5.001), L (5.002), L (5.00405).