Skip to content

Commit

Permalink
Only require Software::License if we're writing a LICENSE file. Still
Browse files Browse the repository at this point in the history
use it if it's available for putting the URL in META.yml though.



git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@12162 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
kenahoo committed Dec 15, 2008
1 parent 4f04a15 commit 970e352
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions lib/Module/Build/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3468,9 +3468,34 @@ BEGIN { *scripts = \&script_files; }
restrictive => undef,
unknown => undef,
);

# TODO - would be nice to not have these here, since they're more
# properly stored only in Software::License
my %license_urls = (
perl => 'http://dev.perl.org/licenses/',
apache => 'http://apache.org/licenses/LICENSE-2.0',
artistic => 'http://opensource.org/licenses/artistic-license.php',
artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php',
lgpl => 'http://opensource.org/licenses/lgpl-license.php',
lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php',
lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html',
bsd => 'http://opensource.org/licenses/bsd-license.php',
gpl => 'http://opensource.org/licenses/gpl-license.php',
gpl2 => 'http://opensource.org/licenses/gpl-2.0.php',
gpl3 => 'http://opensource.org/licenses/gpl-3.0.html',
mit => 'http://opensource.org/licenses/mit-license.php',
mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
open_source => undef,
unrestricted => undef,
restrictive => undef,
unknown => undef,
);
sub valid_licenses {
return \%licenses;
}
sub _license_url {
return $license_urls{$_[1]};
}
}

sub _hash_merge {
Expand Down Expand Up @@ -3569,14 +3594,19 @@ sub prepare_metadata {
}
$node->{version} = '' . $node->{version}; # Stringify version objects

if (defined( $self->license ) &&
defined( my $key = $self->valid_licenses->{ $self->license } )) {
my $class = "Software::License::$key";
eval "use $class; 1"
or die "Couldn't load $class: $@";
if (defined( my $l = $self->license )) {
die "Unknown license string '$l'"
unless exists $self->valid_licenses->{ $self->license };

# S::L requires a 'holder' key
$node->{resources}{license} = $class->new({holder=>"nobody"})->url;
if (my $key = $self->valid_licenses->{ $self->license }) {
my $class = "Software::License::$key";
if (eval "use $class; 1") {
# S::L requires a 'holder' key
$node->{resources}{license} = $class->new({holder=>"nobody"})->url;
} else {
$node->{resources}{license} = $self->_license_urls($key);
}
}
}

if (exists $p->{configure_requires}) {
Expand Down

0 comments on commit 970e352

Please sign in to comment.