t/00-load.t
t/11-maps-name.t
t/12-maps-version.t
+t/13-maps-license.t
t/91-pod.t
t/92-pod-coverage.t
t/95-portability-files.t
ABSTRACT_FROM => 'lib/CPANPLUS/Dist/Gentoo.pm',
PL_FILES => {},
PREREQ_PM => {
- 'Carp' => 0,
- 'CPANPLUS' => 0,
- 'Cwd' => 0,
- 'File::Copy' => 0,
- 'File::Path' => 0,
- 'File::Spec' => 0,
- 'IPC::Cmd' => 0,
- 'base' => 0,
+ 'Carp' => 0,
+ 'CPANPLUS' => 0,
+ 'Cwd' => 0,
+ 'File::Copy' => 0,
+ 'File::Path' => 0,
+ 'File::Spec' => 0,
+ 'IPC::Cmd' => 0,
+ 'Parse::CPAN::Meta' => 0,
+ 'base' => 0,
},
MIN_PERL_VERSION => 5.006,
META_MERGE => \%META,
use File::Spec;
use IPC::Cmd qw/run can_run/;
+use Parse::CPAN::Meta ();
use CPANPLUS::Error ();
$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;
return $OK->();
}
+=head2 C<intuit_license>
+
+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;
Gentoo (L<http://gentoo.org>).
-L<CPANPLUS>, L<IPC::Cmd> (core modules since 5.9.5).
+L<CPANPLUS>, L<IPC::Cmd> (core modules since 5.9.5), L<Parse::CPAN::Meta> (since 5.10.1).
L<Cwd>, L<Carp> (since perl 5), L<File::Path> (5.001), L<File::Copy> (5.002), L<File::Spec> (5.00405).
return $gentooisms{$name} || $name;
}
+=head2 C<license_c2g @licenses>
+
+Maps F<META.yml> C<license> tag values to the corresponding list of Gentoo licenses identifiers.
+Duplicates are stripped off.
+
+The included data was gathered from L<Module::Install> and L<Software::License>.
+
+=cut
+
+my %licenses = (
+ apache => [ 'Apache-2.0' ],
+ artistic => [ 'Artistic' ],
+ artistic_2 => [ 'Artistic-2' ],
+ bsd => [ 'BSD' ],
+ gpl => [ 'GPL-1' ],
+ gpl2 => [ 'GPL-2' ],
+ gpl3 => [ 'GPL-3' ],
+ lgpl => [ 'LGPL-2.1' ],
+ lgpl2 => [ 'LGPL-2.1' ],
+ lgpl3 => [ 'LGPL-3' ],
+ mit => [ 'MIT' ],
+ mozilla => [ 'MPL-1.1' ],
+ perl => [ 'Artistic', 'GPL-2' ],
+);
+
+sub license_c2g {
+ my %seen;
+ grep !$seen{$_}++, map @{$licenses{+lc} || []}, @_;
+}
+
=head2 C<version_c2g $version>
Converts a CPAN version to a Gentoo version.
--- /dev/null
+#!perl -T
+
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+
+use CPANPLUS::Dist::Gentoo::Maps;
+
+sub check_licenses {
+ my @licenses = CPANPLUS::Dist::Gentoo::Maps::license_c2g(@{$_[0]});
+ is_deeply \@licenses, $_[1], $_[2];
+}
+
+check_licenses [ 'woo' ], [ ], 'nonexistent';
+check_licenses [ 'perl' ], [ qw/Artistic GPL-2/ ], 'perl';
+check_licenses [ qw/perl gpl2/ ], [ qw/Artistic GPL-2/ ], 'perl + gpl2';
+check_licenses [ qw/perl bsd/ ], [ qw/Artistic GPL-2 BSD/ ], 'perl + bsd';