WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions lib/Module/Install.pod
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ version scanning tools.

The C<license> command specifies the license for the distribution.

Most often this value will be C<'perl'>, meaning I<"the same as for Perl
itself">. Other allowed values include C<'gpl'>, C<'lgpl'>, C<'bsd'>,
C<'MIT'>, and C<'artistic'>.
Most often this value will be C<'perl'>, meaning I<"the same terms as the perl 5 programming language system itself">. Other allowed values include C<'apache'>, C<'artistic'>, C<'artistic_2'>, C<'bsd'>, C<'gpl'>, C<'lgpl'>, C<'mit'> and C<'mozilla'>.

This value is always considered a summary, and it is normal for authors
to include a F<LICENSE> file in the distribution, containing the full
Expand Down
87 changes: 47 additions & 40 deletions lib/Module/Install/Metadata.pm
Original file line number Diff line number Diff line change
Expand Up @@ -452,55 +452,42 @@ sub author_from {

#Stolen from M::B
my %license_urls = (
open_source => undef,
unrestricted => undef,
restrictive => undef,
unknown => undef,

## from Software-License - should we be using S-L instead ?
# duplicates commeted out, see hack above ^^
# open_source => 'http://www.gnu.org/licenses/agpl-3.0.txt',
# apache => 'http://www.apache.org/licenses/LICENSE-1.1',
apache => 'http://www.apache.org/licenses/LICENSE-2.0.txt',

#from MI v1.06
apache => undef,
artistic => 'http://www.perlfoundation.org/artistic_license_1_0',
artistic_2 => 'http://www.perlfoundation.org/artistic_license_2_0',
bsd => 'http://opensource.org/licenses/BSD-3-Clause',
# unrestricted => 'http://creativecommons.org/publicdomain/zero/1.0/',
# open_source => 'http://www.freebsd.org/copyright/freebsd-license.html',
# open_source => 'http://www.gnu.org/licenses/fdl-1.2.txt',
# open_source => 'http://www.gnu.org/licenses/fdl-1.3.txt',
# gpl => 'http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt',
# gpl => 'http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt',
gpl => 'http://www.gnu.org/licenses/gpl-3.0.txt',
# lgpl => 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt',
lgpl => 'http://www.gnu.org/licenses/lgpl-3.0.txt',
gpl => undef,
lgpl => undef,
mit => 'http://www.opensource.org/licenses/mit-license.php',
# mozilla => 'http://www.mozilla.org/MPL/MPL-1.0.txt',
# mozilla => 'http://www.mozilla.org/MPL/MPL-1.1.txt',
mozilla => 'http://www.mozilla.org/MPL/2.0/index.txt',
# restrictive => '',
# open_source => 'http://www.openssl.org/source/license.html',
mozilla => undef,
open_source => undef,
perl => 'http://dev.perl.org/licenses/',
# open_source => 'http://www.opensource.org/licenses/postgresql',
# open_source => 'http://trolltech.com/products/qt/licenses/licensing/qpl',
# unrestricted => 'http://h71000.www7.hp.com/doc/83final/BA554_90007/apcs02.html',
# open_source => 'http://www.openoffice.org/licenses/sissl_license.html',
# open_source => 'http://www.zlib.net/zlib_license.html',
unrestricted => undef,
restrictive => undef,
# unknown => undef,
);


sub license {
my $self = shift;
return $self->{values}->{license} unless @_;
my $license = shift or die(
'Did not provide a value to license()'
);
$license = __extract_license($license) || lc $license;

# test for valid meta license name
_valid_license($license);

$self->{values}->{license} = $license;

# Automatically fill in license URLs
if ( $license_urls{$license} ) {
$self->resources( license => $license_urls{$license} );
}
return 1;
}

return 1;
}
Expand All @@ -524,14 +511,6 @@ sub _extract_license {
sub __extract_license {
my $license_text = shift or return;
my @phrases = (
'(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1,
'(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1,

# the following are relied on by the test system even if they are wrong :(
'(?:Free)?BSD license' => 'bsd', 1,
'Artistic license 2\.0' => 'artistic_2', 1,
'LGPL' => 'lgpl', 1,
'MIT' => 'mit', 1,

## from Software-License
'The GNU Affero General Public License, Version 3, November 2007' => 'open_source', 1,
Expand All @@ -540,7 +519,7 @@ sub __extract_license {
'The Artistic License 1.0' => 'artistic', 1,
'The Artistic License 2.0 (GPL Compatible)' => 'artistic_2', 1,
'The (three-clause) BSD License' => 'bsd', 1,
'CC0 License' => 'unrestricted', 1,
'CC0 License' => 'unrestricted', 1,
'The (two-clause) FreeBSD License' => 'open_source', 1,
'GNU Free Documentation License v1.2' => 'open_source', 1,
'GNU Free Documentation License v1.3' => 'open_source', 1,
Expand All @@ -565,7 +544,10 @@ sub __extract_license {

while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
$pattern =~ s#\s+#\\s+#gs;
if ( $license_text =~ /\b$pattern\b/i ) {
$pattern =~ s#\(#\\(\\s*#gs;
$pattern =~ s#\)#\\)\\s*#gs;

if ( $license_text =~ m/\b$pattern\b/i ) {
return $license;
}
}
Expand All @@ -582,6 +564,31 @@ sub license_from {
}
}

sub _valid_license {
my $license = shift;

my %meta_licenses = (
apache => 1,
artistic => 1,
artistic_2 => 1,
bsd => 1,
gpl => 1,
lgpl => 1,
mit => 1,
mozilla => 1,
open_source => 1,
perl => 1,
unrestricted => 1,
restrictive => 1,
);

if (not $meta_licenses{$license}) {
die("ERROR: license is not a recognised meta name - $license\n");
return 0;
}
return 1,;
}

sub _extract_bugtracker {
my @links = $_[0] =~ m#L<(
https?\Q://rt.cpan.org/\E[^>]+|
Expand Down
2 changes: 1 addition & 1 deletion t/09_read.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Foo Bar
=head1 COPYRIGHT

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
modify it under the same terms as the perl 5 programming language system itself.

END_POD

Expand Down
6 changes: 3 additions & 3 deletions t/10_test.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ no_index 'directory' => qw{ t xt share inc };
install_share 'eg';
keywords 'kw1','kw 2';
keywords 'kw3';
license 'apache';
license 'artistic_2';

WriteAll;
END_DSL
Expand Down Expand Up @@ -73,8 +73,8 @@ END_TEST
"no_index: @{ $meta->{no_index}->{directory} }"
);

is($meta->{license},'apache','license');
is($meta->{resources}->{license},'http://www.apache.org/licenses/LICENSE-2.0.txt','license URL');
is($meta->{license},'artistic_2','license');
is($meta->{resources}->{license},'http://www.perlfoundation.org/artistic_license_2_0','license URL');

my $makefile = makefile();
ok( -f $makefile, 'Makefile created' );
Expand Down
79 changes: 69 additions & 10 deletions t/11_extraction.t
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/perl
#!perl

use strict;
BEGIN {
$| = 1;
$^W = 1;
}

use Test::More tests => 16;
use Test::More tests => 26;

require_ok( 'Module::Install::Metadata' );

Expand Down Expand Up @@ -80,7 +80,7 @@ SCOPE: {


SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 Copyright\nunder the same terms as the perl programming language\n=cut\n");
my $l=Module::Install::Metadata::_extract_license("=head1 Copyright\nunder the same terms as the perl 5 programming language system itself\n=cut\n");
is($l, 'perl', 'Perl license detected',
);
}
Expand All @@ -89,7 +89,7 @@ SCOPE: {
my $text="=head1 LICENSE

This is free software, you may use it and distribute it under
the same terms as Perl itself.
the same terms as the perl 5 programming language system itself.

=head1 SEE ALSO

Expand All @@ -105,7 +105,7 @@ test
SCOPE: {
my $text="=head1 COPYRIGHTS

This module is distributed under the same terms as Perl itself.
This module is distributed under the same terms as the perl 5 programming language system itself.

=cut
";
Expand All @@ -115,8 +115,14 @@ This module is distributed under the same terms as Perl itself.
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 COPYRIGHT\nAs LGPL license\n=cut\n");
is($l, 'lgpl', 'LGPL detected',
my $l=Module::Install::Metadata::_extract_license("=head1 COPYRIGHT\nThe GNU Lesser General Public License, Version 2.1, February 1999\n=cut\n");
is($l, 'lgpl', 'LGPL license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 COPYRIGHT\nThe GNU Lesser General Public License, Version 3, June 2007\n=cut\n");
is($l, 'lgpl', 'LGPL license detected',
);
}

Expand All @@ -125,7 +131,7 @@ SCOPE: {
=head1 COPYRIGHT AND LICENCE

... is free software; you can redistribute it and/or modify it under
the terms of Perl itself, that is to say, under the terms of either:
the same terms as the perl 5 programming language system itself, that is to say, under the terms of either:

=over 4

Expand All @@ -147,22 +153,75 @@ EOT
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 LICENSE\nThe Artistic License 1.0\n=cut\n");
is($l, 'artistic', 'Artistic license detected',
);
}


SCOPE: {
my $text=<<'EOT';
=head1 COPYRIGHT AND LICENCE

Copyright (C) 2010

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://opensource.org/licenses/artistic-license-2.0.php.
This library is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0 (GPL Compatible) For details, see the full text of the license at http://opensource.org/licenses/artistic-license-2.0.php.

=cut
EOT
my $l=Module::Install::Metadata::_extract_license($text);
is($l, 'artistic_2', 'Artistic 2.0 license detected',
is($l, 'artistic_2', 'Artistic license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe (three-clause) BSD License\n=cut\n");
is($l, 'bsd', 'BSD license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe GNU General Public License, Version 1, February 1989\n=cut\n");
is($l, 'gpl', 'GNU license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 LICENsE\nThe GNU General Public License, Version 2, June 1991\n=cut\n");
is($l, 'gpl', 'GNU license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe GNU General Public License, Version 3, June 2007\n=cut\n");
is($l, 'gpl', 'GNU license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe MIT (X11) License\n=cut\n");
is($l, 'mit', 'MIT license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 LICENCE\nThe Mozilla Public License 1.0\n=cut\n");
is($l, 'mozilla', 'Mozilla license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 LICENSE\nThe Mozilla Public License 1.1\n=cut\n");
is($l, 'mozilla', 'Mozilla license detected',
);
}

SCOPE: {
my $l=Module::Install::Metadata::_extract_license("=head1 Copyright\nMozilla Public License Version 2.0\n=cut\n");
is($l, 'mozilla', 'Mozilla license detected',
);
}


SCOPE: {
Expand Down
6 changes: 3 additions & 3 deletions t/24_multiple_license_blocks.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ BEGIN {
use Test::More tests => 3;
use Module::Install::Metadata;


my %p = _setup();

for (
Expand Down Expand Up @@ -67,9 +68,8 @@ POD
=head1 LICENCE

This module is free software; you can redistribute it and/or modify it
under the
same terms as Perl itself, i.e. under the terms of either the GNU
General Public
under the same terms as the perl 5 programming language system itself,
i.e. under the terms of either the GNU General Public
License or the Artistic License, as specified in the F<LICENCE> file.

POD
Expand Down
2 changes: 1 addition & 1 deletion t/27_build_requires_and_include.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/perl
#!perl

use strict;
BEGIN {
Expand Down
Loading