1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
use 5.008;
use strict;
use warnings;
package Dist::Zilla::Plugin::InstallGuide;
# ABSTRACT: Build an INSTALL file
our $VERSION = '1.200004'; # VERSION
use Moose;
use Moose::Autobox;
with 'Dist::Zilla::Role::InstallTool';
with 'Dist::Zilla::Role::TextTemplate';
has template => (is => 'ro', isa => 'Str', default => <<'END_TEXT');
This is the Perl distribution {{ $dist->name }}.
Installing {{ $dist->name }} is straightforward.
## Installation with cpanm
If you have cpanm, you only need one line:
% cpanm {{ $package }}
If you are installing into a system-wide directory, you may need to pass the
"-S" flag to cpanm, which uses sudo to install the module:
% cpanm -S {{ $package }}
## Installing with the CPAN shell
Alternatively, if your CPAN shell is set up, you should just be able to do:
% cpan {{ $package }}
## Manual installation
{{ $manual_installation }}
## Documentation
{{ $dist->name }} documentation is available as POD.
You can run perldoc from a shell to read the documentation:
% perldoc {{ $package }}
END_TEXT
has makemaker_manual_installation => (is => 'ro', isa => 'Str', default => <<'END_TEXT');
As a last resort, you can manually install it. Download the tarball, untar it,
then build it:
% perl Makefile.PL
% make && make test
Then install it:
% make install
If you are installing into a system-wide directory, you may need to run:
% sudo make install
END_TEXT
has module_build_manual_installation => (is => 'ro', isa => 'Str', default => <<'END_TEXT');
As a last resort, you can manually install it. Download the tarball, untar it,
then build it:
% perl Build.PL
% ./Build && ./Build test
Then install it:
% ./Build install
If you are installing into a system-wide directory, you may need to run:
% sudo ./Build install
END_TEXT
has file_content => (is => 'ro', isa => 'Str', lazy => 1, builder => '_build_file_content');
sub _build_file_content {
my $self = shift;
my $zilla = $self->zilla;
my $manual_installation = '';
my %installer = map { $_->name => 1 }
grep { $_->name eq 'Makefile.PL' or $_->name eq 'Build.PL' }
@{ $zilla->files };
if ($installer{'Build.PL'}) {
$manual_installation .= $self->module_build_manual_installation;
}
elsif ($installer{'Makefile.PL'}) {
$manual_installation .= $self->makemaker_manual_installation;
}
unless ($manual_installation) {
$self->log_fatal('neither Makefile.PL nor Build.PL is present, aborting');
}
(my $main_package = $zilla->name) =~ s!-!::!g;
my $content = $self->fill_in_string(
$self->template,
{ dist => \$zilla,
package => $main_package,
manual_installation => $manual_installation
}
);
return $content;
}
sub setup_installer {
my $self = shift;
require Dist::Zilla::File::FromCode;
$self->add_file(Dist::Zilla::File::FromCode->new({
name => 'INSTALL',
code => sub { $self->file_content },
}));
return;
}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Zilla::Plugin::InstallGuide - Build an INSTALL file
=head1 VERSION
version 1.200004
=head1 SYNOPSIS
In C<dist.ini>:
[InstallGuide]
=head1 DESCRIPTION
This plugin adds a very simple F<INSTALL> file to the distribution, telling
the user how to install this distribution.
You should use this plugin in your L<Dist::Zilla> configuration after
C<[MakeMaker]> or C<[ModuleBuild]> so that it can determine what kind of
distribution you are building and which installation instructions are
appropriate.
=head1 METHODS
=head2 setup_installer
Creates the C<INSTALL> file and prepare its contents, which will be finalized
near the end of the build process.
=for test_synopsis 1;
__END__
=head1 AVAILABILITY
The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
site near you, or see L<https://metacpan.org/module/Dist::Zilla::Plugin::InstallGuide/>.
=head1 SOURCE
The development version is on github at L<http://github.com/doherty/Dist-Zilla-Plugin-InstallGuide>
and may be cloned from L<git://github.com/doherty/Dist-Zilla-Plugin-InstallGuide.git>
=head1 BUGS AND LIMITATIONS
You can make new bug reports, and view existing ones, through the
web interface at L<https://github.com/doherty/Dist-Zilla-Plugin-InstallGuide/issues>.
=head1 AUTHORS
=over 4
=item *
Marcel GrĂ¼nauer <marcel@cpan.org>
=item *
Mike Doherty <doherty@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Marcel GrĂ¼nauer <marcel@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|