Author: dagolden
Date: Fri Sep 4 04:12:15 2009
New Revision: 13272
Modified:
Module-Build/trunk/lib/Module/Build.pm
Module-Build/trunk/lib/Module/Build/Base.pm
Log:
improve installdeps edge cases, messages and docs
Modified: Module-Build/trunk/lib/Module/Build.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build.pm (original)
+++ Module-Build/trunk/lib/Module/Build.pm Fri Sep 4 04:12:15 2009
@@ -427,6 +427,24 @@
module from being present on your system, which can be a confusing
situation indeed.
+=item installdeps
+
+[version 0.36]
+
+This action will use the C<cpan_client> parameter as a command to install
+missing prerequisites. You will be prompted whether to install
+optional dependencies.
+
+The C<cpan_client> option defaults to 'cpan' but can be set as an option or in
+F<.modulebuildrc>. It must be a shell command that takes a list of modules to
+install as arguments (e.g. 'cpanp -i' for CPANPLUS). If the program part is a
+relative path (e.g. 'cpan' or 'cpanp'), it will be located relative to the perl
+program that executed Build.PL.
+
+ /opt/perl/5.8.9/bin/perl Build.PL
+ ./Build installdeps --cpan_client 'cpanp -i'
+ # installs to 5.8.9
+
=item manifest
[version 0.05]
@@ -713,15 +731,20 @@
Suppress informative messages on output.
+=item verbose
+
+Display extra information about the Build on output.
+
+=item cpan_client
+
+Sets the C<cpan_client> command for use with the C<installdeps> action.
+See C<installdeps> for more details.
+
=item use_rcfile
Load the F<~/.modulebuildrc> option file. This option can be set to
false to prevent the custom resource file from being loaded.
-=item verbose
-
-Display extra information about the Build on output.
-
=item allow_mb_mismatch
Suppresses the check upon startup that the version of Module::Build
@@ -764,10 +787,11 @@
to all actions, and the key 'Build_PL' specifies options to be applied
when you invoke C<perl Build.PL>.
- * verbose=1 # global options
- diff flags=-u
- install --install_base /home/ken
- --install_path html=/home/ken/docs/html
+ * verbose=1 # global options
+ diff flags=-u
+ install --install_base /home/ken
+ --install_path html=/home/ken/docs/html
+ installdeps --cpan_client 'cpanp -i'
If you wish to locate your resource file in a different location, you
can set the environment variable C<MODULEBUILDRC> to the complete
Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Fri Sep 4 04:12:15 2009
@@ -1326,6 +1326,13 @@
of the modules indicated above before proceeding with this installation
EOF
+ unless ( $ENV{PERL5_CPANPLUS_IS_RUNNING} || $ENV{PERL5_CPAN_IS_RUNNING} ) {
+ my $client = $self->cpan_client;
+ $self->log_info(
+ "Run 'Build installdeps' to install missing prerequisites.\n\n"
+ );
+ }
+
return 0;
} else {
@@ -3149,9 +3156,19 @@
sub ACTION_installdeps {
my ($self) = @_;
- my $info = $self->_enum_prereqs or return;
+ # XXX include feature prerequisites as optional prereqs?
- my $failures = $self->prereq_failures($info) or return;
+ my $info = $self->_enum_prereqs;
+ if (! $info ) {
+ $self->log_info( "No prerequisites detected\n" );
+ return;
+ }
+
+ my $failures = $self->prereq_failures($info);
+ if ( ! $failures ) {
+ $self->log_info( "All prerequisites satisfied\n" );
+ return;
+ }
my @install;
while (my ($type, $prereqs) = each %$failures) {
@@ -3159,12 +3176,14 @@
push(@install, keys %$prereqs);
next;
}
+ $self->log_info("Checking optional dependencies:\n");
while (my ($module, $status) = each %$prereqs) {
- $self->log_info("$status->{message}\n");
push(@install, $module) if($self->y_n("Install $module?", 'y'));
}
}
+ return unless @install;
+
my ($command, @opts) = $self->split_like_shell($self->cpan_client);
# relative command should be relative to our active Perl