1 package Module::AutoInstall;
5 use ExtUtils::MakeMaker ();
12 # special map on pre-defined feature sets
14 '' => 'Core Features', # XXX: deprecated
15 '-core' => 'Core Features',
18 # various lexical flags
19 my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $HasCPANPLUS );
21 $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps
23 my ( $PostambleActions, $PostambleUsed );
25 # See if it's a testing or non-interactive session
26 _accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN );
30 $AcceptDefault = shift;
41 ? ( UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
48 # initialize various flags, and/or perform install
54 $ENV{PERL_AUTOINSTALL} || $ENV{PERL_EXTUTILS_AUTOINSTALL} || ''
58 if ( $arg =~ /^--config=(.*)$/ ) {
59 $Config = [ split( ',', $1 ) ];
61 elsif ( $arg =~ /^--installdeps=(.*)$/ ) {
62 __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) );
65 elsif ( $arg =~ /^--default(?:deps)?$/ ) {
68 elsif ( $arg =~ /^--check(?:deps)?$/ ) {
71 elsif ( $arg =~ /^--skip(?:deps)?$/ ) {
74 elsif ( $arg =~ /^--test(?:only)?$/ ) {
77 elsif ( $arg =~ /^--all(?:deps)?$/ ) {
83 # overrides MakeMaker's prompt() to automatically accept the default choice
85 goto &ExtUtils::MakeMaker::prompt unless $AcceptDefault;
87 my ( $prompt, $default ) = @_;
88 my $y = ( $default =~ /^[Yy]/ );
90 print $prompt, ' [', ( $y ? 'Y' : 'y' ), '/', ( $y ? 'n' : 'N' ), '] ';
98 my @args = @_ or return;
101 print "*** $class version " . $class->VERSION . "\n";
102 print "*** Checking for Perl dependencies...\n";
104 my $cwd = Cwd::cwd();
110 sort { length($b) <=> length($a) }
114 ? ( ( ref($_) eq 'HASH' ) ? keys(%$_) : @{$_} )
117 map { +{@args}->{$_} }
118 grep { /^[^\-]/ or /^-core$/i } keys %{ +{@args} }
122 # We want to know if we're under CPAN early to avoid prompting, but
123 # if we aren't going to try and install anything anyway then skip the
124 # check entirely since we don't want to have to load (and configure)
125 # an old CPAN just for a cosmetic message
127 $UnderCPAN = _check_lock(1) unless $SkipInstall;
129 while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) {
130 my ( @required, @tests, @skiptests );
134 if ( $feature =~ m/^-(\w+)$/ ) {
137 # check for a newer version of myself
138 _update_to( $modules, @_ ) and return if $option eq 'version';
140 # sets CPAN configuration options
141 $Config = $modules if $option eq 'config';
143 # promote every features to core status
144 $core_all = ( $modules =~ /^all$/i ) and next
145 if $option eq 'core';
147 next unless $option eq 'core';
150 print "[" . ( $FeatureMap{ lc($feature) } || $feature ) . "]\n";
152 $modules = [ %{$modules} ] if UNIVERSAL::isa( $modules, 'HASH' );
154 unshift @$modules, -default => &{ shift(@$modules) }
155 if ( ref( $modules->[0] ) eq 'CODE' ); # XXX: bugward combatability
157 while ( my ( $mod, $arg ) = splice( @$modules, 0, 2 ) ) {
158 if ( $mod =~ m/^-(\w+)$/ ) {
161 $default = $arg if ( $option eq 'default' );
162 $conflict = $arg if ( $option eq 'conflict' );
163 @tests = @{$arg} if ( $option eq 'tests' );
164 @skiptests = @{$arg} if ( $option eq 'skiptests' );
169 printf( "- %-${maxlen}s ...", $mod );
171 if ( $arg and $arg =~ /^\D/ ) {
172 unshift @$modules, $arg;
176 # XXX: check for conflicts and uninstalls(!) them.
177 my $cur = _load($mod);
178 if (_version_cmp ($cur, $arg) >= 0)
180 print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n";
181 push @Existing, $mod => $arg;
182 $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
185 if (not defined $cur) # indeed missing
187 print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n";
191 # no need to check $arg as _version_cmp ($cur, undef) would satisfy >= above
192 print "too old. ($cur < $arg)\n";
195 push @required, $mod => $arg;
199 next unless @required;
201 my $mandatory = ( $feature eq '-core' or $core_all );
207 or ($mandatory and $UnderCPAN)
210 qq{==> Auto-install the }
212 . ( $mandatory ? ' mandatory' : ' optional' )
213 . qq{ module(s) from CPAN?},
214 $default ? 'y' : 'n',
219 push( @Missing, @required );
220 $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
223 elsif ( !$SkipInstall
227 _prompt( qq{==> The module(s) are mandatory! Really skip?}, 'n', )
230 push( @Missing, @required );
231 $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
235 $DisabledTests{$_} = 1 for map { glob($_) } @tests;
239 if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) {
242 "*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
244 # make an educated guess of whether we'll need root permission.
245 print " (You may need to do that as the 'root' user.)\n"
248 print "*** $class configuration finished.\n";
254 *{'main::WriteMakefile'} = \&Write if caller(0) eq 'main';
259 print <<"END_MESSAGE";
260 *** Since we're running under ${thing}, I'll just let it take care
261 of the dependency's installation later.
266 # Check to see if we are currently running under CPAN.pm and/or CPANPLUS;
267 # if we are, then we simply let it taking care of our dependencies
269 return unless @Missing or @_;
271 my $cpan_env = $ENV{PERL5_CPAN_IS_RUNNING};
273 if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) {
274 return _running_under($cpan_env ? 'CPAN' : 'CPANPLUS');
279 if ($CPAN::VERSION > '1.89') {
281 return _running_under('CPAN');
283 return; # CPAN.pm new enough, don't need to check further
286 # last ditch attempt, this -will- configure CPAN, very sorry
288 _load_cpan(1); # force initialize even though it's already loaded
290 # Find the CPAN lock-file
291 my $lock = MM->catfile( $CPAN::Config->{cpan_home}, ".lock" );
292 return unless -f $lock;
296 return unless open(LOCK, $lock);
299 ( $^O eq 'MSWin32' ? _under_cpan() : <LOCK> == getppid() )
300 and ( $CPAN::Config->{prerequisites_policy} || '' ) ne 'ignore'
302 print <<'END_MESSAGE';
304 *** Since we're running under CPAN, I'll just let it take care
305 of the dependency's installation later.
317 my $i; # used below to strip leading '-' from config keys
318 my @config = ( map { s/^-// if ++$i; $_ } @{ +shift } );
320 my ( @modules, @installed );
321 while ( my ( $pkg, $ver ) = splice( @_, 0, 2 ) ) {
323 # grep out those already installed
324 if ( _version_cmp( _load($pkg), $ver ) >= 0 ) {
325 push @installed, $pkg;
328 push @modules, $pkg, $ver;
332 return @installed unless @modules; # nothing to do
333 return @installed if _check_lock(); # defer to the CPAN shell
335 print "*** Installing dependencies...\n";
337 return unless _connected_to('cpan.org');
342 if ( $args{do_once} and open( FAILED, '.#autoinstall.failed' ) ) {
343 while (<FAILED>) { chomp; $failed{$_}++ }
347 while ( my ( $k, $v ) = splice( @modules, 0, 2 ) ) {
348 push @newmod, ( $k => $v ) unless $failed{$k};
353 if ( _has_cpanplus() and not $ENV{PERL_AUTOINSTALL_PREFER_CPAN} ) {
354 _install_cpanplus( \@modules, \@config );
356 _install_cpan( \@modules, \@config );
359 print "*** $class installation finished.\n";
361 # see if we have successfully installed them
362 while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
363 if ( _version_cmp( _load($pkg), $ver ) >= 0 ) {
364 push @installed, $pkg;
366 elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) {
367 print FAILED "$pkg\n";
371 close FAILED if $args{do_once};
376 sub _install_cpanplus {
377 my @modules = @{ +shift };
378 my @config = _cpanplus_config( @{ +shift } );
381 require CPANPLUS::Backend;
382 my $cp = CPANPLUS::Backend->new;
383 my $conf = $cp->configure_object;
385 return unless $conf->can('conf') # 0.05x+ with "sudo" support
386 or _can_write($conf->_get_build('base')); # 0.04x
388 # if we're root, set UNINST=1 to avoid trouble unless user asked for it.
389 my $makeflags = $conf->get_conf('makeflags') || '';
390 if ( UNIVERSAL::isa( $makeflags, 'HASH' ) ) {
391 # 0.03+ uses a hashref here
392 $makeflags->{UNINST} = 1 unless exists $makeflags->{UNINST};
395 # 0.02 and below uses a scalar
396 $makeflags = join( ' ', split( ' ', $makeflags ), 'UNINST=1' )
397 if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } );
400 $conf->set_conf( makeflags => $makeflags );
401 $conf->set_conf( prereqs => 1 );
405 while ( my ( $key, $val ) = splice( @config, 0, 2 ) ) {
406 $conf->set_conf( $key, $val );
409 my $modtree = $cp->module_tree;
410 while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
411 print "*** Installing $pkg...\n";
413 MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall;
416 my $obj = $modtree->{$pkg};
418 if ( $obj and _version_cmp( $obj->{version}, $ver ) >= 0 ) {
420 $pathname =~ s/::/\\W/;
422 foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) {
426 my $rv = $cp->install( modules => [ $obj->{module} ] );
428 if ( $rv and ( $rv->{ $obj->{module} } or $rv->{ok} ) ) {
429 print "*** $pkg successfully installed.\n";
432 print "*** $pkg installation cancelled.\n";
436 $installed += $success;
439 *** Could not find a version $ver or above for $pkg; skipping.
443 MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall;
449 sub _cpanplus_config {
452 my ($key, $value) = (shift(), shift());
453 if ( $key eq 'prerequisites_policy' ) {
454 if ( $value eq 'follow' ) {
455 $value = CPANPLUS::Internals::Constants::PREREQ_INSTALL();
456 } elsif ( $value eq 'ask' ) {
457 $value = CPANPLUS::Internals::Constants::PREREQ_ASK();
458 } elsif ( $value eq 'ignore' ) {
459 $value = CPANPLUS::Internals::Constants::PREREQ_IGNORE();
461 die "*** Cannot convert option $key = '$value' to CPANPLUS version.\n";
464 die "*** Cannot convert option $key to CPANPLUS version.\n";
471 my @modules = @{ +shift };
472 my @config = @{ +shift };
479 if (CPAN->VERSION < 1.80) {
480 # no "sudo" support, probe for writableness
481 return unless _can_write( MM->catfile( $CPAN::Config->{cpan_home}, 'sources' ) )
482 and _can_write( $Config::Config{sitelib} );
485 # if we're root, set UNINST=1 to avoid trouble unless user asked for it.
486 my $makeflags = $CPAN::Config->{make_install_arg} || '';
487 $CPAN::Config->{make_install_arg} =
488 join( ' ', split( ' ', $makeflags ), 'UNINST=1' )
489 if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } );
491 # don't show start-up info
492 $CPAN::Config->{inhibit_startup_message} = 1;
494 # set additional options
495 while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) {
496 ( $args{$opt} = $arg, next )
497 if $opt =~ /^force$/; # pseudo-option
498 $CPAN::Config->{$opt} = $arg;
501 local $CPAN::Config->{prerequisites_policy} = 'follow';
503 while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
504 MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall;
506 print "*** Installing $pkg...\n";
508 my $obj = CPAN::Shell->expand( Module => $pkg );
511 if ( $obj and _version_cmp( $obj->cpan_version, $ver ) >= 0 ) {
513 $pathname =~ s/::/\\W/;
515 foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) {
519 my $rv = $args{force} ? CPAN::Shell->force( install => $pkg )
520 : CPAN::Shell->install($pkg);
522 $CPAN::META->instance( 'CPAN::Distribution', $obj->cpan_file, )
527 if ( $rv eq 'YES' ) {
528 print "*** $pkg successfully installed.\n";
532 print "*** $pkg installation failed.\n";
536 $installed += $success;
540 *** Could not find a version $ver or above for $pkg; skipping.
544 MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall;
553 $INC{'CPANPLUS/Config.pm'}
554 or _load('CPANPLUS::Shell::Default')
559 # make guesses on whether we're under the CPAN installation directory
564 my $cwd = File::Spec->canonpath( Cwd::cwd() );
565 my $cpan = File::Spec->canonpath( $CPAN::Config->{cpan_home} );
567 return ( index( $cwd, $cpan ) > -1 );
571 my $class = __PACKAGE__;
575 if _version_cmp( _load($class), $ver ) >= 0; # no need to upgrade
578 _prompt( "==> A newer version of $class ($ver) is required. Install?",
582 die "*** Please install $class $ver manually.\n";
586 *** Trying to fetch it from CPAN...
590 _load($class) and return $class->import(@_)
591 if $class->install( [], $class, $ver );
593 print << '.'; exit 1;
595 *** Cannot bootstrap myself. :-( Installation terminated.
599 # check if we're connected to some host, using inet_aton
604 ( _load('Socket') and Socket::inet_aton($site) ) or _prompt(
606 *** Your host cannot resolve the domain name '$site', which
607 probably means the Internet connections are unavailable.
608 ==> Should we try to install the required module(s) anyway?), 'n'
613 # check if a directory is writable; may create it on demand
616 mkdir( $path, 0755 ) unless -e $path;
618 return 1 if -w $path;
621 *** You are not allowed to write to the directory '$path';
622 the installation may fail due to insufficient permissions.
626 eval '$>' and lc(`sudo -V`) =~ /version/ and _prompt(
628 ==> Should we try to re-execute the autoinstall process with 'sudo'?),
629 ((-t STDIN) ? 'y' : 'n')
634 # try to bootstrap ourselves from sudo
636 *** Trying to re-execute the autoinstall process with 'sudo'...
638 my $missing = join( ',', @Missing );
639 my $config = join( ',',
640 UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
644 unless system( 'sudo', $^X, $0, "--config=$config",
645 "--installdeps=$missing" );
648 *** The 'sudo' command exited with error! Resuming...
654 ==> Should we try to install the required module(s) anyway?), 'n'
658 # load a module and return the version it reports
660 my $mod = pop; # class/instance doesn't matter
667 return eval { require $file; $mod->VERSION } || ( $@ ? undef: 0 );
670 # Load CPAN.pm and it's configuration
672 return if $CPAN::VERSION and $CPAN::Config and not @_;
674 if ( $CPAN::HandleConfig::VERSION ) {
675 # Newer versions of CPAN have a HandleConfig module
676 CPAN::HandleConfig->load;
678 # Older versions had the load method in Config directly
683 # compare two versions, either use Sort::Versions or plain comparison
684 # return values same as <=>
686 my ( $cur, $min ) = @_;
687 return -1 unless defined $cur; # if 0 keep comparing
688 return 1 unless $min;
692 # check for version numbers that are not in decimal format
693 if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) {
694 if ( ( $version::VERSION or defined( _load('version') )) and
698 # use version.pm if it is installed.
699 return version->new($cur) <=> version->new($min);
701 elsif ( $Sort::Versions::VERSION or defined( _load('Sort::Versions') ) )
704 # use Sort::Versions as the sorting algorithm for a.b.c versions
705 return Sort::Versions::versioncmp( $cur, $min );
708 warn "Cannot reliably compare non-decimal formatted versions.\n"
709 . "Please install version.pm or Sort::Versions.\n";
713 local $^W = 0; # shuts off 'not numeric' bugs
714 return $cur <=> $min;
717 # nothing; this usage is deprecated.
718 sub main::PREREQ_PM { return {}; }
723 $args{PREREQ_PM} = { %{ $args{PREREQ_PM} || {} }, @Existing, @Missing }
724 if $UnderCPAN or $TestOnly;
726 if ( $args{EXE_FILES} and -e 'MANIFEST' ) {
727 require ExtUtils::Manifest;
728 my $manifest = ExtUtils::Manifest::maniread('MANIFEST');
731 [ grep { exists $manifest->{$_} } @{ $args{EXE_FILES} } ];
734 $args{test}{TESTS} ||= 't/*.t';
735 $args{test}{TESTS} = join( ' ',
736 grep { !exists( $DisabledTests{$_} ) }
737 map { glob($_) } split( /\s+/, $args{test}{TESTS} ) );
739 my $missing = join( ',', @Missing );
741 join( ',', UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} )
744 $PostambleActions = (
745 ($missing and not $UnderCPAN)
746 ? "\$(PERL) $0 --config=$config --installdeps=$missing"
747 : "\$(NOECHO) \$(NOOP)"
753 # a wrapper to ExtUtils::MakeMaker::WriteMakefile
756 Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
760 *** Makefile not written in check-only mode.
765 my %args = _make_args(@_);
770 local *MY::postamble = \&postamble unless defined &MY::postamble;
771 ExtUtils::MakeMaker::WriteMakefile(%args);
773 print << "." unless $PostambleUsed;
774 *** WARNING: Makefile written with customized MY::postamble() without
775 including contents from Module::AutoInstall::postamble() --
776 auto installation features disabled. Please contact the author.
787 config :: installdeps
788 \t\$(NOECHO) \$(NOOP)
791 \t\$(PERL) $0 --checkdeps
808 Module::AutoInstall - Automatic install of dependencies via CPAN
812 In F<Makefile.PL>, with L<Module::Install> available on the author's system:
814 use inc::Module::Install;
817 abstract 'Perl Interface to Joe Hacker';
818 author 'Joe Hacker <joe@hacker.org>';
819 include 'Module::AutoInstall';
821 requires 'Module0'; # mandatory modules
832 make_args => '--hello', # option(s) for CPAN::Config
833 force => 1, # pseudo-option to force install
834 do_once => 1, # skip previously failed modules
839 Invoking the resulting F<Makefile.PL>:
841 % perl Makefile.PL # interactive behaviour
842 % perl Makefile.PL --defaultdeps # accept default value on prompts
843 % perl Makefile.PL --checkdeps # check only, no Makefile produced
844 % perl Makefile.PL --skipdeps # ignores all dependencies
845 % perl Makefile.PL --testonly # don't write installation targets
847 Note that the trailing 'deps' of arguments may be omitted, too.
849 Using C<--defaultdeps> will make F<Makefile.PL> behave similarly to a regular
850 Makefile.PL file with C<PREREQ_PM> dependencies.
852 One can use environment variables (see "ENVIRONMENT") below to set a default
853 behavior instead of specifying it in the command line for every invocation
856 Using F<make> (or F<nmake>):
858 % make [all|test|install] # install dependencies first
859 % make checkdeps # same as the --checkdeps above
860 % make installdeps # install dependencies only
864 B<Module::AutoInstall> lets module writers to specify a more
865 sophisticated form of dependency information than the C<PREREQ_PM>
866 option offered by B<ExtUtils::MakeMaker>.
868 This module works best with the B<Module::Install> framework,
869 a drop-in replacement for MakeMaker. However, this module also
870 supports F<Makefile.PL> files based on MakeMaker; see L</EXAMPLES>
873 =head2 Prerequisites and Features
875 Prerequisites are grouped into B<features>, and the user could choose
876 yes/no on each one's dependencies; the module writer may also supply a
877 boolean value via C<-default> to specify the default choice.
879 The B<Core Features> marked by the name C<-core> will double-check with
880 the user, if the user chooses not to install the mandatory modules.
881 This differs from the pre-0.26 'silent install' behaviour.
883 Starting from version 0.27, if C<-core> is set to the string C<all>
884 (case-insensitive), every feature will be considered mandatory.
886 The dependencies are expressed as pairs of C<Module> => C<version>
887 inside an array reference. If the order does not matter, and there
888 are no C<-default>, C<-tests> or C<-skiptests> directives for that
889 feature, you may also use a hash reference.
891 =head2 The Installation Process
893 Once B<Module::AutoInstall> has determined which module(s) are needed,
894 it checks whether it's running under the B<CPAN> shell and should
895 therefore let B<CPAN> handle the dependency.
897 Finally, the C<WriteMakefile()> is overridden to perform some additional
898 checks, as well as skips tests associated with disabled features by the
901 The actual installation happens at the end of the C<make config> target;
902 both C<make test> and C<make install> will trigger the installation of
905 If it's not running under B<CPAN>, the installer will probe for an
906 active connection by trying to resolve the domain C<cpan.org>, and check
907 for the user's permission to use B<CPAN>. If all went well, a separate
908 B<CPAN> instance is created to install the required modules.
910 If you have the B<CPANPLUS> package installed in your system, it is
911 preferred by default over B<CPAN>; it also accepts some extra options
912 (e.g. C<-target =E<gt> 'skiptest', -skiptest =E<gt> 1> to skip testing).
914 All modules scheduled to be installed will be deleted from C<%INC>
915 first, so B<ExtUtils::MakeMaker> will check the newly installed modules.
917 Additionally, you could use the C<make installdeps> target to install
918 the modules, and the C<make checkdeps> target to check dependencies
919 without actually installing them; the C<perl Makefile.PL --checkdeps>
920 command has an equivalent effect.
922 If the F<Makefile.PL> itself needs to use an independent module (e.g.
923 B<Acme::KillarApp>, v1.21 or greater), then use something like below:
926 require Module::AutoInstall;
927 # the first argument is an arrayref of the -config flags
928 Module::AutoInstall->install([], 'Acme::KillerApp' => 1.21);
930 use Acme::KillerApp 1.21;
932 Module::AutoInstall->import(
933 # ... arguments as usual ...
936 Note the version test in the use clause; if you are so close to the
937 cutting edge that B<Acme::KillerApp> 1.20 is the latest version on CPAN,
938 this will prevent your module from going awry.
940 =head2 User-Defined Hooks
942 User-defined I<pre-installation> and I<post-installation> hooks are
943 available via C<MY::preinstall> and C<MY::postinstall> subroutines,
946 # pre-install handler; takes $module_name and $version
947 sub MY::preinstall { return 1; } # return false to skip install
949 # post-install handler; takes $module_name, $version, $success
950 sub MY::postinstall { return; } # the return value doesn't matter
952 Note that since B<Module::AutoInstall> performs installation at the
953 time of C<use> (i.e. before perl parses the remainder of
954 F<Makefile.PL>), you have to declare those two handlers I<before> the
955 C<use> statement for them to take effect.
957 If the user did not choose to install a module or it already exists on
958 the system, neither of the handlers is invoked. Both handlers are invoked
959 exactly once for each module when installation is attempted.
961 C<MY::preinstall> takes two arguments, C<$module_name> and C<$version>;
962 if it returns a false value, installation for that module will be
963 skipped, and C<MY::postinstall> won't be called at all.
965 C<MY::postinstall> takes three arguments, C<$module_name>, C<$version>
966 and C<$success>. The last one denotes whether the installation
967 succeeded or not: C<1> means installation completed successfully, C<0>
968 means failure during install, and C<undef> means that the installation
969 was not attempted at all, possibly due to connection problems, or that
970 module does not exist on CPAN at all.
972 =head2 Customized C<MY::postamble>
974 Starting from version 0.43, B<Module::AutoInstall> supports modules
975 that require a C<MY::postamble> subroutine in their F<Makefile.PL>.
976 The user-defined C<MY::postamble>, if present, is responsible for
977 calling C<Module::AutoInstall::postamble> and include the output in
980 For example, the B<DBD::*> (database driver) modules for the Perl DBI
981 are required to include the postamble generated by the function
982 C<dbd_postamble>, so their F<Makefile.PL> may contain lines like this:
985 return &Module::AutoInstall::postamble . &dbd_postamble;
988 Note that the B<Module::AutoInstall> module does not export the
989 C<postamble> function, so the name should always be fully qualified.
993 B<Module::AutoInstall> will add C<UNINST=1> to your B<make install>
994 flags if your effective uid is 0 (root), unless you explicitly disable
995 it by setting B<CPAN>'s C<make_install_arg> configuration option (or the
996 C<makeflags> option of B<CPANPLUS>) to include C<UNINST=0>. This I<may>
997 cause dependency problems if you are using a fine-tuned directory
998 structure for your site. Please consult L<CPAN/FAQ> for an explanation
1001 If either B<version> or B<Sort::Versions> is available, they will be
1002 used to compare the required version with the existing module's version
1003 and the CPAN module's. Otherwise it silently falls back to use I<cmp>.
1004 This may cause inconsistent behaviours in pathetic situations.
1008 B<Module::AutoInstall> uses a single environment variable,
1009 C<PERL_AUTOINSTALL>. It is taken as the command line argument
1010 passed to F<Makefile.PL>; you could set it to C<--alldeps>, C<--defaultdeps>
1011 or C<--skipdeps> to avoid all interactive behaviour.
1013 C<--alldeps> will install all features, while
1014 C<--defaultdeps> will only install features for which the default answer is
1017 C<--skipdeps> will refrain from loading L<CPAN> and not install anything, unless
1018 you're running under L<CPAN> or L<CPANPLUS>, in which case required dependencies
1021 It also read from the C<PERL_EXTUTILS_AUTOINSTALL> environment variable if
1022 C<PERL_AUTOINSTALL> is not defined.
1028 L<perlmodlib>, L<ExtUtils::MakeMaker>, L<Sort::Versions>, L<CPAN>,
1033 Audrey Tang E<lt>autrijus@autrijus.orgE<gt>
1035 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
1037 Matt S Trout E<lt>mst@shadowcat.co.uE<gt>
1039 =head1 IF THIS BREAKS
1041 Report a ticket to bugs-Module-Install <at> rt.cpan.org and cc Matt
1042 - I appear to have volunteered as primary maintainer for this stuff so
1043 if you run into any problems please tell me
1047 Copyright 2001, 2002, 2003, 2004, 2005, 2006 by Audrey Tang
1049 Some parts copyright 2006 Adam Kennedy
1051 This program is free software; you can redistribute it and/or
1052 modify it under the same terms as Perl itself.
1054 See L<http://www.perl.com/perl/misc/Artistic.html>