Acme-Perl-Consensual
view release on metacpan or search on metacpan
inc/Module/Install/Package.pm view on Meta::CPAN
#line 1
##
# name: Module::Install::Package
# abstract: Module::Install support for Module::Package
# author: Ingy döt Net <ingy@cpan.org>
# license: perl
# copyright: 2011
# see:
# - Module::Package
# This module contains the Module::Package logic that must be available to
# both the Author and the End User. Author-only logic goes in a
# Module::Package::Plugin subclass.
package Module::Install::Package;
use strict;
use Module::Install::Base;
use vars qw'@ISA $VERSION';
@ISA = 'Module::Install::Base';
$VERSION = '0.30';
#-----------------------------------------------------------------------------#
# XXX BOOTBUGHACK
# This is here to try to get us out of Module-Package-0.11 cpantesters hell...
# Remove this when the situation has blown over.
sub pkg {
*inc::Module::Package::VERSION = sub { $VERSION };
my $self = shift;
$self->module_package_internals_init($@);
}
#-----------------------------------------------------------------------------#
# We allow the author to specify key/value options after the plugin. These
# options need to be available both at author time and install time.
#-----------------------------------------------------------------------------#
# OO accessor for command line options:
sub package_options {
@_>1?($_[0]->{package_options}=$_[1]):$_[0]->{package_options}}
my $default_options = {
deps_list => 1,
install_bin => 1,
install_share => 1,
manifest_skip => 1,
requires_from => 1,
};
#-----------------------------------------------------------------------------#
# Module::Install plugin directives. Use long, ugly names to not pollute the
# Module::Install plugin namespace. These are only intended to be called from
# Module::Package.
#-----------------------------------------------------------------------------#
# Module::Package starts off life as a normal call to this Module::Install
# plugin directive:
my $module_install_plugin;
my $module_package_plugin;
my $module_package_dist_plugin;
# XXX ARGVHACK This @argv thing is a temporary fix for an ugly bug somewhere in the
# Wikitext module usage.
my @argv;
sub module_package_internals_init {
my $self = $module_install_plugin = shift;
my ($plugin_spec, %options) = @_;
$self->package_options({%$default_options, %options});
if ($module_install_plugin->is_admin) {
$module_package_plugin = $self->_load_plugin($plugin_spec);
$module_package_plugin->mi($module_install_plugin);
$module_package_plugin->version_check($VERSION);
}
else {
$module_package_dist_plugin = $self->_load_dist_plugin($plugin_spec);
$module_package_dist_plugin->mi($module_install_plugin) if ref $module_package_dist_plugin;
}
# NOTE - This is the point in time where the body of Makefile.PL runs...
return;
sub INIT {
return unless $module_install_plugin;
return if $Module::Package::ERROR;
eval {
if ($module_install_plugin->is_admin) {
$module_package_plugin->initial();
$module_package_plugin->main();
}
else {
$module_install_plugin->_initial();
$module_package_dist_plugin->_initial() if ref $module_package_dist_plugin;
$module_install_plugin->_main();
$module_package_dist_plugin->_main() if ref $module_package_dist_plugin;
}
};
if ($@) {
$Module::Package::ERROR = $@;
die $@;
}
@argv = @ARGV; # XXX ARGVHACK
}
# If this Module::Install plugin was used (by Module::Package) then wrap
# up any loose ends. This will get called after Makefile.PL has completed.
sub END {
@ARGV = @argv; # XXX ARGVHACK
return unless $module_install_plugin;
return if $Module::Package::ERROR;
$module_package_plugin
? do {
$module_package_plugin->final;
$module_package_plugin->replicate_module_package;
}
: do {
$module_install_plugin->_final;
$module_package_dist_plugin->_final() if ref $module_package_dist_plugin;
( run in 1.098 second using v1.01-cache-2.11-cpan-ceb78f64989 )