NAME
ExtUtils::AutoInstall - Automatic install of dependencies via CPAN
SYNOPSIS
in Makefile.PL:
# till we think of a better solution...
BEGIN { eval q{ require ExtUtils::AutoInstall; 1 } or eval q{
warn "*** This module needs ExtUtils::AutoInstall...\n";
use CPAN; CPAN::install('ExtUtils::AutoInstall') }; }
use ExtUtils::MakeMaker;
use ExtUtils::AutoInstall (
-version => '0.21', # required ExtUtils::AutoInstall version
-core => [
# core modules
Package1 => '0.01',
],
'Feature1' => [
# do we want to install this feature by default?
-default => (system('feature1 --version') == 0 ),
Package2 => '0.02',
],
'Feature2' => [
# associate tests to be disabled along with this
-tests => [ <t/feature2*.t> ],
Package3 => '0.03',
],
);
WriteMakefile(
AUTHOR => 'Joe Hacker (joe@hacker.org)',
ABSTRACT => 'Perl Interface to Joe Hacker',
NAME => 'Joe::Hacker',
VERSION_FROM => 'Hacker.pm',
DISTNAME => 'Joe-Hacker',
);
DESCRIPTION
ExtUtils::AutoInstall lets module writers specify a more sophisticated form of dependency information than the PREREQ_PM
option offered by ExtUtils::MakeMaker.
Prerequisites are grouped into features, and the user could specify yes/no on each one. The module writer may also supply a boolean value via -default
to specify the default choice.
The Core Features marked by the name -core
is an exeption: all missing packages that belongs to it will be installed without prompting the user.
Once ExtUtils::AutoInstall knows which module(s) are needed, it checks whether it's running under the CPAN shell and should let CPAN handle the dependency.
If it's not running under CPAN, the installer will probe for an active connection by trying to resolve the domain cpan.org
, and check for the user's permission to use CPAN. If all tests pass, a separate CPAN instance is created to install the required modules.
All modules scheduled to install will be deleted from %INC
first, so ExtUtils::MakeMaker will check the newly installed modules.
Finally, the WriteMakefile()
is overrided to perform some additional checks, as well as skips tests associated with disabled features by the -tests
option.
NOTES
Since this module is needed before writing Makefile, it makes little use as a CPAN module; hence each distribution must include it in full. The only alternative I'm aware of, namely prompting in Makefile.PL to force user install it (cf. the Template Toolkit's dependency on AppConfig) is not very desirable either.
The current compromise is to add this line before every script:
BEGIN { eval q{ require ExtUtils::AutoInstall; 1 } or eval q{
warn "*** This module needs ExtUtils::AutoInstall...\n";
use CPAN; CPAN::install('ExtUtils::AutoInstall') }; }
But that ain't pretty.
Since we do not want all future options of ExtUtils::AutoInstall to be painfully detected manually like the above, this module provides a bootstrapping mechanism via the -version
flag. If it sees a newer version is needed by a certain Makefile.PL, it will go ahead to fetch a new version, reload it into memory, and pass the arguments forward.
If you have any recommendations, please let me know. Thanks.
SEE ALSO
perlmodlib, CPAN, ExtUtils::MakeMaker
AUTHORS
Autrijus Tang <autrijus@autrijus.org>
COPYRIGHT
Copyright 2001 by Autrijus Tang <autrijus@autrijus.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.