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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
|
use 5.008;
use strict;
use warnings;
package Dist::Zilla::Plugin::InstallGuide; # git description: v1.200011-3-g7d54ffa
# ABSTRACT: Build an INSTALL file
our $VERSION = '1.200012';
use Moose;
with 'Dist::Zilla::Role::FileGatherer';
with 'Dist::Zilla::Role::TextTemplate';
with 'Dist::Zilla::Role::FileMunger';
use List::Util 1.33 qw(first any);
use namespace::autoclean;
#pod =head1 SYNOPSIS
#pod
#pod In C<dist.ini>:
#pod
#pod [InstallGuide]
#pod
#pod =begin :prelude
#pod
#pod =for test_synopsis BEGIN { die "SKIP: synopsis isn't perl code" }
#pod
#pod =end :prelude
#pod
#pod =head1 DESCRIPTION
#pod
#pod This plugin adds a very simple F<INSTALL> file to the distribution, telling
#pod the user how to install this distribution.
#pod
#pod You should use this plugin in your L<Dist::Zilla> configuration after
#pod C<[MakeMaker]> or C<[ModuleBuild]> so that it can determine what kind of
#pod distribution you are building and which installation instructions are
#pod appropriate.
#pod
#pod =head1 METHODS
#pod
#pod =cut
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 it does not have permission to install modules to the current perl, cpanm
will automatically set up and install to a local::lib in your home directory.
See the local::lib documentation (https://metacpan.org/pod/local::lib) for
details on enabling it in your environment.
## 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 }}
The prerequisites of this distribution will also have to be installed manually. The
prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated
by running the manual build process described above.
## Configure Prerequisites
This distribution requires other modules to be installed before this
distribution's installer can be run. They can be found under the
{{ join(" or the\n",
$has_meta_yml ? '"configure_requires" key of META.yml' : '',
$has_meta_json ? '"{prereqs}{configure}{requires}" key of META.json' : '',
)}}.
## Other Prerequisites
This distribution may require additional modules to be installed after running
{{ join(' or ', grep { $installer{$_} } qw(Build.PL Makefile.PL)) }}.
Look for prerequisites in the following phases:
* to run {{ join(' or ',
($installer{'Build.PL'} ? './Build' : ()),
($installer{'Makefile.PL'} ? 'make' : ())) }}, PHASE = build
* to use the module code itself, PHASE = runtime
* to run tests, PHASE = test
They can all be found in the {{ join(" or the\n",
$has_meta_yml ? '"PHASE_requires" key of MYMETA.yml' : '',
$has_meta_json ? '"{prereqs}{PHASE}{requires}" key of MYMETA.json' : '',
)}}.
## Documentation
{{ $dist->name }} documentation is available as POD.
You can run `perldoc` from a shell to read the documentation:
% perldoc {{ $package }}
For more information on installing Perl modules via CPAN, please see:
https://www.cpan.org/modules/INSTALL.html
END_TEXT
our $common_instructions = <<'END_TEXT';
As a last resort, you can manually install it. Download the tarball, untar it,
install configure prerequisites (see below), then build it:
END_TEXT
has makemaker_manual_installation => (
is => 'ro', isa => 'Str',
default => $common_instructions . <<'END_TEXT',
% perl Makefile.PL
% make && make test
Then install it:
% make install
On Windows platforms, you should use `dmake` or `nmake`, instead of `make`.
If your perl is system-managed, you can create a local::lib in your home
directory to install modules to. For details, see the local::lib documentation:
https://metacpan.org/pod/local::lib
END_TEXT
);
has module_build_manual_installation => (
is => 'ro', isa => 'Str',
default => $common_instructions . <<'END_TEXT',
% perl Build.PL
% ./Build && ./Build test
Then install it:
% ./Build install
Or the more portable variation:
% perl Build.PL
% perl Build
% perl Build test
% perl Build install
If your perl is system-managed, you can create a local::lib in your home
directory to install modules to. For details, see the local::lib documentation:
https://metacpan.org/pod/local::lib
END_TEXT
);
#pod =head2 gather_files
#pod
#pod Creates the F<INSTALL> file.
#pod
#pod =cut
sub gather_files {
my $self = shift;
require Dist::Zilla::File::InMemory;
$self->add_file(Dist::Zilla::File::InMemory->new({
name => 'INSTALL',
content => $self->template,
}));
return;
}
#pod =head2 munge_files
#pod
#pod Inserts the appropriate installation instructions into F<INSTALL>.
#pod
#pod =cut
sub munge_files {
my $self = shift;
my $zilla = $self->zilla;
my $manual_installation = '';
my %installer = (
map {
$_->isa('Dist::Zilla::Plugin::MakeMaker') ? ( 'Makefile.PL' => 1 ) : (),
$_->does('Dist::Zilla::Role::BuildPL') ? ( 'Build.PL' => 1 ) : (),
} @{ $zilla->plugins }
);
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 $file = first { $_->name eq 'INSTALL' } @{ $zilla->files };
my $content = $self->fill_in_string(
$file->content,
{ dist => \$zilla,
package => $main_package,
manual_installation => $manual_installation,
has_meta_yml => (any { $_->name eq 'META.yml' } @{ $zilla->files }),
has_meta_json => (any { $_->name eq 'META.json' } @{ $zilla->files }),
installer => \%installer,
}
);
$file->content($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.200012
=for test_synopsis BEGIN { die "SKIP: synopsis isn't perl code" }
=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 gather_files
Creates the F<INSTALL> file.
=head2 munge_files
Inserts the appropriate installation instructions into F<INSTALL>.
=head1 SUPPORT
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-InstallGuide>
(or L<bug-Dist-Zilla-Plugin-InstallGuide@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-InstallGuide@rt.cpan.org>).
There is also a mailing list available for users of this distribution, at
L<http://dzil.org/#mailing-list>.
There is also an irc channel available for users of this distribution, at
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>.
=head1 AUTHORS
=over 4
=item *
Marcel GrĂ¼nauer <marcel@cpan.org>
=item *
Mike Doherty <doherty@cpan.org>
=back
=head1 CONTRIBUTORS
=for stopwords Mike Doherty Karen Etheridge Marcel Gruenauer jonasbn Dan Book Dave Rolsky Apocalypse
=over 4
=item *
Mike Doherty <mike@mikedoherty.ca>
=item *
Karen Etheridge <ether@cpan.org>
=item *
Marcel Gruenauer <hanekomu@gmail.com>
=item *
jonasbn <jonasbn@gmail.com>
=item *
Mike Doherty <doherty@cs.dal.ca>
=item *
Dan Book <grinnz@gmail.com>
=item *
Dave Rolsky <autarch@urth.org>
=item *
Apocalypse <APOCAL@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
|