App-Build
view release on metacpan or search on metacpan
lib/App/Build.pm view on Meta::CPAN
This will be put to good use sometime in the future.
=head1 FIX-UPS
Module::Build complains if the PREFIX environment variable is
set. App::Build doesn't. It just ignores it.
The CPAN shell (for some reason I don't understand) runs Build.PL
as "perl Build.PL Build" and this fails.
App::Build just throws away the "Build" so that the default "build"
action is invoked.
Module::Build deprecated the PREFIX option to Makefile.PL
(i.e. "perl Makefile.PL PREFIX=/usr/foo"). App::Build just makes
the PREFIX option a synonym for "install_base", which does
essentially the same thing.
=cut
delete $ENV{PREFIX}; # Module::Build protests if this var is set
# Enable the continued use of the PREFIX=$PREFIX option
# (from Makefile.PL and ExtUtils::MakeMaker) by making it
# an alias for the "install_base" option of Module::Build.
######################################################################
# BUILD: enhancements to "perl Build.PL"
######################################################################
=head1 METHODS
The documentation of the methods below is not for users of the
App::Build module (who are writing Build.PL scripts), but for people
interested in the internals of how App::Build extends Module::Build.
It is also so that I can remember what I was doing so that if the
internals of Module::Build change, I can maintain this code.
=head2 new()
We override the new() method in order to enhance the install paths.
In the future, we may also download and unpack external perl
distributions.
=cut
sub new {
my ($class, %args) = @_;
my $obj = $class->SUPER::new(%args);
$obj->_enhance_install_paths() if $obj->_prefix;
$obj->_get_supporting_software();
return($obj);
}
=head2 read_config()
Overridden to transparently call C<_enhance_install_paths()>.
=cut
sub read_config {
my ($self) = @_;
$self->SUPER::read_config();
$self->_enhance_install_paths() if $self->_prefix;
}
=head2 install_base()
Overridden to transparently call C<_enhance_install_paths()>.
=cut
sub install_base {
my ($self, @args) = @_;
my $ret = $self->SUPER::install_base(@args);
$self->_enhance_install_paths() if $self->_prefix;
return $ret;
}
=head2 _get_supporting_software()
Downloads supporting software (if necessary), unpacks it, compiles it,
and installs it.
=cut
sub _get_supporting_software {
my ($self) = @_;
my $tag = $self->_app_tag();
my $url = $App::options{"$tag.url"}; # check to see if there was software to download
if ($url) {
my $file = $App::options{"$tag.file"};
if (!$file) {
$file = $url;
$file =~ s!.*/!!;
}
($file) || die "File [$tag.file] does not exist";
my $subdir = $App::options{"$tag.subdir"};
if (!$subdir) {
$subdir = $file;
$subdir =~ s!\.tar.gz$!!;
$subdir =~ s!\.tgz$!!;
}
($subdir) || die "Subdir [$tag.subdir] does not exist";
my $archive_dir = $App::options{archive_dir} || "archive";
mkdir($archive_dir) if (! -d $archive_dir);
my $archive = "$archive_dir/$file";
(-d $archive_dir) || die "Archive Directory [$archive_dir] does not exist";
(-w $archive_dir) || die "Archive Directory [$archive_dir] not writeable";
$self->mirror($url, $archive);
$self->unpack($archive, "unpack", $subdir);
}
}
=head2 _app_tag()
This lowercase-ifies the dist_name, removes "app-build-" from the front,
and returns it as the "application tag".
Therefore, a distribution called "App-Build-Kwiki" would have an
"app_tag" of "kwiki". An "app_tag" is used for looking up configuration
( run in 0.477 second using v1.01-cache-2.11-cpan-39bf76dae61 )