From: Graham Knop Date: Wed, 22 Jul 2015 19:45:28 +0000 (-0400) Subject: license file generation X-Git-Tag: v0.003000~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c97878e5a46e85a28f7dfe06481005e4f6a81ddf;p=p5sagit%2FDistar.git license file generation --- diff --git a/helpers/generate-license b/helpers/generate-license new file mode 100755 index 0000000..1229056 --- /dev/null +++ b/helpers/generate-license @@ -0,0 +1,15 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Software::LicenseUtils; + +my ($authors, @licenses) = @ARGV; + +my %uniq; +print + join "\n\n", + map { $_->new({holder => $authors})->license } + grep { !$uniq{$_}++ } + map { Software::LicenseUtils->guess_license_from_meta_key($_, 2) } + @licenses; diff --git a/lib/Distar.pm b/lib/Distar.pm index 323b181..8727a22 100644 --- a/lib/Distar.pm +++ b/lib/Distar.pm @@ -205,6 +205,11 @@ END_FRAG ); my $helpers = File::Spec->catdir($distar, 'helpers'); + my $licenses = $self->{LICENSE} || $self->{META_ADD}{license} || $self->{META_MERGE}{license}; + my $authors = $self->{AUTHOR}; + $_ = ref $_ ? $_ : [$_ || ()] + for $licenses, $authors; + my %vars = ( DISTAR => $self->quote_literal($distar), HELPERS => $self->quote_literal($helpers), @@ -213,6 +218,8 @@ END_FRAG CHANGELOG => $self->{CHANGELOG} ||= 'Changes', DEV_NULL_STDOUT => ($self->{DEV_NULL} ? '>'.File::Spec->devnull : ''), DISTTEST_MAKEFILE_PARAMS => '', + AUTHORS => $self->quote_literal(join(', ', @$authors)), + LICENSES => join(' ', map $self->quote_literal($_), @$licenses), ); my $dist_test = $self->SUPER::dist_test(@_); @@ -246,14 +253,21 @@ pushrelease :: pushrelease$(FAKE_RELEASE) :: cpan-upload $(DISTVNAME).tar$(SUFFIX) git push origin v$(VERSION) HEAD -distdir: readmefile +distdir: readmefile licensefile readmefile: create_distdir $(NOECHO) $(TEST_F) $(DISTVNAME)/README || $(MAKE) $(DISTVNAME)/README $(DISTVNAME)/README: $(VERSION_FROM) $(NOECHO) $(MKPATH) $(DISTVNAME) pod2text $(VERSION_FROM) >$(DISTVNAME)/README $(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) README -distsignature: readmefile +distsignature: readmefile licensefile +licensefile: create_distdir + $(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(MAKE) $(DISTVNAME)/LICENSE +$(DISTVNAME)/LICENSE: Makefile.PL + $(NOECHO) $(MKPATH) $(DISTVNAME) + $(ABSPERLRUN) $(HELPERS)/generate-license $(AUTHORS) $(LICENSES) >$(DISTVNAME)/LICENSE + $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-to-manifest LICENSE + $(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) LICENSE disttest: distmanicheck distmanicheck: create_distdir cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"