X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDistar.pm;h=e048045fad3c2570fa792089b1ee5436198ea7d6;hb=adbdb6d2cf84c64cc92a9a4ba35b9d06f6ef8c59;hp=3ded7cdcf1b3ab3b053e602b3bcccf26ab739515;hpb=c34106970628efc3f1b176bcbffe99e6186fa825;p=p5sagit%2FDistar.git diff --git a/lib/Distar.pm b/lib/Distar.pm index 3ded7cd..e048045 100644 --- a/lib/Distar.pm +++ b/lib/Distar.pm @@ -8,7 +8,7 @@ use File::Spec (); use File::Basename (); our $VERSION = '0.003000'; -$VERSION = eval $VERSION; +$VERSION =~ tr/_//d; my $MM_VER = eval $ExtUtils::MakeMaker::VERSION; @@ -30,6 +30,7 @@ sub author { our $Author = shift; $Author = [ $Author ] if !ref $Author; + 1; } our @Manifest = ( @@ -46,6 +47,7 @@ our @Manifest = ( sub manifest_include { push @Manifest, @_; + 1; } sub readme_generator { @@ -78,6 +80,22 @@ sub write_manifest_skip { { package Distar::MM; + sub _gen_make_section { + return join '', + map { + my @lines; + if (ref) { + @lines = @$_; + s/^\t?/\t/mg for @lines; + } + else { + @lines = $_; + } + s/\n?\z/\n/ for @lines; + @lines; + } @_; + } + sub new { my ($class, $args) = @_; my %test = %{$args->{test}||{}}; @@ -161,12 +179,25 @@ sub write_manifest_skip { $out; } + sub libscan { + my $self = shift; + my ($path) = @_; + + # default setup for Distar involves checking it out as a subdirectory at + # the top of the dist. Without NORECURS, EUMM would try to include + # Distar's Makefile.PL. Prevent EUMM from looking inside. + return '' + if $path eq 'Distar'; + + $self->SUPER::libscan(@_); + } + sub tarfile_target { my $self = shift; my $out = $self->SUPER::tarfile_target(@_); - my $verify = <<'END_FRAG'; - $(ABSPERLRUN) $(HELPERS)/verify-tarball $(DISTVNAME).tar $(DISTVNAME)/MANIFEST --tar="$(TAR)" -END_FRAG + my $verify = _gen_make_section([ + '$(ABSPERLRUN) $(HELPERS)/verify-tarball $(DISTVNAME).tar $(DISTVNAME)/MANIFEST --tar="$(TAR)"', + ]); $out =~ s{(\$\(TAR\).*\n)}{$1$verify}; $out; } @@ -175,7 +206,7 @@ END_FRAG my $self = shift; my $distar_lib = File::Basename::dirname(__FILE__); - my $helpers = File::Spec->catdir($distar_lib, File::Spec->updir, 'helpers'); + my $helpers = File::Spec->catdir($distar_lib, 'Distar', 'helpers'); my $licenses = $self->{LICENSE} || $self->{META_ADD}{license} || $self->{META_MERGE}{license}; my $authors = $self->{AUTHOR}; @@ -211,73 +242,90 @@ END_FRAG my @out; - push @out, <<'END'; -preflight: check-version check-manifest check-cpan-upload - $(ABSPERLRUN) $(HELPERS)/preflight $(VERSION) --changelog=$(CHANGELOG) --branch=$(BRANCH) -check-version: - $(ABSPERLRUN) $(HELPERS)/check-version $(VERSION) $(TO_INST_PM) $(EXE_FILES) -check-manifest: - $(ABSPERLRUN) $(HELPERS)/check-manifest -check-cpan-upload: - $(NOECHO) cpan-upload -h $(DEV_NULL_STDOUT) -releasetest: - $(MAKE) disttest RELEASE_TESTING=1 DISTTEST_MAKEFILE_PARAMS="PREREQ_FATAL=1" PASTHRU="$(PASTHRU) TEST_FILES=\"$(TEST_FILES)\"" - $(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(ECHO) "Failed to generate $(DISTVNAME)/LICENSE!" >&2 - $(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE -release: preflight - $(MAKE) releasetest - $(GET_CHANGELOG) -p"Release commit for $(VERSION)" | git commit -a -F - - $(GET_CHANGELOG) -p"release v$(VERSION)" | git tag -a -F - "v$(VERSION)" - $(RM_RF) $(DISTVNAME) - $(MAKE) $(DISTVNAME).tar$(SUFFIX) - $(NOECHO) $(MAKE) pushrelease FAKE_RELEASE=$(FAKE_RELEASE) -pushrelease :: - $(NOECHO) $(NOOP) -pushrelease$(FAKE_RELEASE) :: - cpan-upload $(DISTVNAME).tar$(SUFFIX) - git push origin v$(VERSION) HEAD -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 licensefile -licensefile: create_distdir - $(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(MAKE) $(DISTVNAME)/LICENSE || $(TRUE) -$(DISTVNAME)/LICENSE: Makefile.PL - $(NOECHO) $(MKPATH) $(DISTVNAME) - $(ABSPERLRUN) $(HELPERS)/generate-license -o $(DISTVNAME)/LICENSE $(AUTHORS) $(LICENSES) - $(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) LICENSE -disttest: distmanicheck -distmanicheck: create_distdir - cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck" -nextrelease: - $(ABSPERLRUN) $(HELPERS)/add-changelog-heading --git $(VERSION) $(CHANGELOG) -refresh: - $(UPDATE_DISTAR) - $(RM_F) $(FIRST_MAKEFILE) - $(REMAKE) -END + push @out, ( + 'preflight: check-version check-manifest check-cpan-upload' => [ + '$(ABSPERLRUN) $(HELPERS)/preflight $(VERSION) --changelog=$(CHANGELOG) --branch=$(BRANCH)', + ], + 'check-version:' => [ + '$(ABSPERLRUN) $(HELPERS)/check-version $(VERSION) $(TO_INST_PM) $(EXE_FILES)', + ], + 'check-manifest:' => [ + '$(ABSPERLRUN) $(HELPERS)/check-manifest', + ], + 'check-cpan-upload:' => [ + '$(NOECHO) cpan-upload -h $(DEV_NULL_STDOUT)', + ], + 'releasetest:' => [ + '$(MAKE) disttest RELEASE_TESTING=1 DISTTEST_MAKEFILE_PARAMS="PREREQ_FATAL=1" PASTHRU="$(PASTHRU) TEST_FILES=\"$(TEST_FILES)\""', + '$(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(ECHO) "Failed to generate $(DISTVNAME)/LICENSE!" >&2', + '$(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE', + ], + 'release: preflight' => [ + '$(MAKE) releasetest', + '$(GET_CHANGELOG) -p"Release commit for $(VERSION)" | git commit -a -F -', + '$(GET_CHANGELOG) -p"release v$(VERSION)" | git tag -a -F - "v$(VERSION)"', + '$(RM_RF) $(DISTVNAME)', + '$(MAKE) $(DISTVNAME).tar$(SUFFIX)', + '$(NOECHO) $(MAKE) pushrelease FAKE_RELEASE=$(FAKE_RELEASE)', + ], + 'pushrelease ::' => [ + '$(NOECHO) $(NOOP)', + ], + 'pushrelease$(FAKE_RELEASE) ::' => [ + 'cpan-upload $(DISTVNAME).tar$(SUFFIX)', + 'git push origin v$(VERSION) HEAD', + ], + '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 licensefile', + 'licensefile: create_distdir' => [ + '$(NOECHO) $(TEST_F) $(DISTVNAME)/LICENSE || $(MAKE) $(DISTVNAME)/LICENSE || $(TRUE)', + ], + '$(DISTVNAME)/LICENSE: Makefile.PL' => [ + '$(NOECHO) $(MKPATH) $(DISTVNAME)', + '$(ABSPERLRUN) $(HELPERS)/generate-license -o $(DISTVNAME)/LICENSE $(AUTHORS) $(LICENSES)', + '$(NOECHO) $(ABSPERLRUN) $(HELPERS)/add-to-manifest -d $(DISTVNAME) LICENSE', + ], + 'disttest: distmanicheck', + 'distmanicheck: create_distdir' => [ + $self->cd('$(DISTVNAME)', + '$(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"', + ), + ], + 'nextrelease:' => [ + '$(ABSPERLRUN) $(HELPERS)/add-changelog-heading --git $(VERSION) $(CHANGELOG)', + ], + 'refresh:' => [ + '$(UPDATE_DISTAR)', + '$(RM_F) $(FIRST_MAKEFILE)', + '$(REMAKE)', + ], + ); + my @bump_targets = grep { $include !~ /^bump$_(?: +\w+)*:/m } ('', 'minor', 'major'); - for my $target (@bump_targets) { - push @out, sprintf <<'END', "bump$target", ($target || '$(V)'); -%s: - $(ABSPERLRUN) $(HELPERS)/bump-version --git $(VERSION) %s - $(RM_F) $(FIRST_MAKEFILE) - $(REMAKE) -END - } + push @out, map +( + "bump$_:" => [ + '$(ABSPERLRUN) $(HELPERS)/bump-version --git $(VERSION) '.($_ || '$(V)'), + '$(RM_F) $(FIRST_MAKEFILE)', + '$(REMAKE)', + ], + ), @bump_targets; join('', $dist_test, "\n\n# --- Distar section:\n\n", (map "$_ = $vars{$_}\n", sort keys %vars), "\n", - @out, + _gen_make_section(@out), ($include ? ( "\n", "# --- Makefile.include:\n",