| Perl-Dist-WiX documentation | view source | Contained in the Perl-Dist-WiX distribution. |
Perl::Dist::WiX::Mixin::BuildPerl - 4th generation Win32 Perl distribution builder
This document describes Perl::Dist::WiX::Mixin::BuildPerl version 1.500002.
This module provides (most of) the routines that Perl::Dist::WiX uses in order to build Perl itself.
# This module is not to be used independently. # It provides methods to be called on a Perl::Dist::WiX object.
The install_cpan_upgrades method is provided to upgrade all the
modules that were installed with Perl that were not upgraded by the
install_perl_toolchain subroutine.
Returns true or throws an exception.
This is recommended to be used as a task in the tasklist, and is in the default tasklist after the "perl toolchain" is installed.
when (
/Unicode-Normalize-1 [.] (\d\d)-withoutworldwriteables/msx)
{
$self->install_distribution(
name => "SADAHIRO/Unicode-Normalize-1.$1.tar.gz",
mod_name => 'Unicode::Normalize',
$self->_install_location(1),
$self->_force_flag($default_force),
);
}
=cut
when (m{/ExtUtils-MakeMaker-\d}msx) {
# Get rid of the old ExtUtils::MakeMaker files that were deleted in 6.50.
$self->remove_file(
qw{perl lib ExtUtils MakeMaker bytes.pm});
$self->remove_file(
qw{perl lib ExtUtils MakeMaker vmsish.pm});
$self->_install_cpan_module( $module, $default_force );
}
when (m{/CGI [.] pm-\d}msx) {
# New CGI.pm (3.46 and later) versions require FCGI.
$self->install_modules(qw( FCGI ));
$self->_install_cpan_module( $module, $default_force );
}
when (m{/\QDevel-DProf-20110228}msx) {
#errors in tests, and this version does not contains
#any useful changes
#already patched in repository
next
}
default {
$self->_install_cpan_module( $module, $default_force );
}
} ## end given
} ## end for my $module ( @{$module_info...})
# NOW install delayed modules!
for my $module (@delayed_modules) {
$self->_install_cpan_module( $module, $default_force );
}
# Getting modules for autodie support installed.
# Yes, I know that technically it's a core module with
# non-core dependencies, and that's ugly. I've just got
# to live with it.
my $autodie_location = $self->file(qw(perl lib autodie.pm));
if ( -e $autodie_location ) {
$self->install_modules(qw( Win32::Process IPC::System::Simple ));
}
# Getting CPANPLUS config file installed.
# (Since we're building 5.10.0+ only, it IS installed now.)
$self->trace_line( 1,
"Getting CPANPLUS config file ready for patching\n" );
$self->patch_file(
'perl/lib/CPANPLUS/Config.pm' => $self->image_dir(),
{ dist => $self, } );
# Install newest dev version of CPAN if we haven't already.
if ( not $self->fragment_exists('CPAN') ) {
$self->install_distribution(
name => 'ANDK/CPAN-1.9600.tar.gz',
mod_name => 'CPAN',
makefilepl_param => ['INSTALLDIRS=perl'],
buildpl_param => [ '--installdirs', 'core' ],
);
}
# Install version of Module::Build if we haven't already.
if ( not $self->fragment_exists('Module_Build') ) {
$self->install_distribution(
name => 'DAGOLDEN/Module-Build-0.3800.tar.gz',
mod_name => 'Module::Build',
makefilepl_param => ['INSTALLDIRS=perl'],
buildpl_param => [ '--installdirs', 'core' ],
force => ( $self->image_dir() =~ /\AD:/ms ) ? 1 : 0,
);
}
return $self;
} ## end sub install_cpan_upgrades
sub _get_cpan_upgrades_list { my $self = shift;
# Get the CPAN url.
my $url = $self->cpan()->as_string();
# Generate the CPAN installation script
my $cpan_string = <<"END_PERL";
print "Loading CPAN...\\n";
use CPAN 1.9600;
CPAN::HandleConfig->load unless \$CPAN::Config_loaded++;
\$CPAN::Config->{'urllist'} = [ '$url' ];
END_PERL
$cpan_string .= <<'END_PERL';
print "Loading Storable...\n";
use Storable qw(nstore);
my ($module, %seen, %need, @toget);
my @modulelist = CPAN::Shell->expand('Module', '/./');
# Schwartzian transform from CPAN.pm. my @expand; @expand = map { $_->[1] } sort { $b->[0] <=> $a->[0] || $a->[1]{ID} cmp $b->[1]{ID}, } map { [$_->_is_representative_module, $_ ] } @modulelist;
require Config; my $vendorlib=$Config::Config{'installvendorlib'}; MODULE: for $module (@expand) { my $file = $module->cpan_file;
# If there's no file to download, skip it.
next MODULE unless defined $file;
$file =~ s{^./../}{};
my $latest = $module->cpan_version;
my $inst_file = $module->inst_file;
my $have;
my $next_MODULE;
eval { # version.pm involved!
if ($inst_file and $vendorlib ne substr($inst_file,0,length($vendorlib))) {
$have = $module->inst_version;
local $^W = 0;
++$next_MODULE unless CPAN::Version->vgt($latest, $have);
# to be pedantic we should probably say:
# && !($have eq "undef" && $latest ne "undef" && $latest gt "");
# to catch the case where CPAN has a version 0 and we have a version undef
} else {
++$next_MODULE;
}
};
next MODULE if $next_MODULE;
if ($@) {
next MODULE;
}
$seen{$file} ||= 0;
next MODULE if $seen{$file}++;
push @toget, $module;
$need{$module->id}++;
}
unless (%need) { print "All modules are up to date\n"; }
END_PERL my $cpan_info_file = catfile( $self->output_dir(), 'cpan.info' ); $cpan_string .= <<"END_PERL"; nstore \\\@toget, '$cpan_info_file'; print "Completed collecting information on all modules\\n";
exit 0; END_PERL
# Dump the CPAN script to a temp file and execute.
$self->trace_line( 1, "Running upgrade of all modules\n" );
my $cpan_file = catfile( $self->build_dir(), 'cpan_string.pl' );
SCOPE: {
my $CPAN_FILE;
open $CPAN_FILE, '>', $cpan_file
or PDWiX->throw("CPAN script open failed: $OS_ERROR");
print {$CPAN_FILE} $cpan_string
or PDWiX->throw("CPAN script print failed: $OS_ERROR");
close $CPAN_FILE
or PDWiX->throw("CPAN script close failed: $OS_ERROR");
}
$self->execute_perl($cpan_file)
or PDWiX->throw('CPAN script execution failed');
if ($CHILD_ERROR) {
PDWiX->throw('Failure detected during cpan upgrade, stopping');
}
return $cpan_info_file;
} ## end sub _get_cpan_upgrades_list
sub _install_location { my ( $self, $core ) = @_;
# Return the correct location information.
my $vendor =
!$self->portable() ? 1
: ( $self->perl_major_version() >= 12 ) ? 1
: 0;
if ($core) {
return (
makefilepl_param => ['INSTALLDIRS=perl'],
buildpl_param => [ '--installdirs', 'core' ],
);
} elsif ($vendor) {
return (
makefilepl_param => ['INSTALLDIRS=vendor'],
buildpl_param => [ '--installdirs', 'vendor' ],
);
} else {
return (
makefilepl_param => ['INSTALLDIRS=site'],
buildpl_param => [ '--installdirs', 'site' ],
);
}
} ## end sub _install_location
sub _install_cpan_module { my ( $self, $module, $force ) = @_;
# Collect information.
$force = $force or $self->force();
my $perl_version = $self->perl_version_literal();
my $module_id = $self->_module_fix( $module->id() );
my $module_file = substr $module->cpan_file(), 5;
#<<<
my $core =
exists $Module::CoreList::version{ $perl_version }{ $module_id }
? 1
: 0;
# Override core determination for this module.
# (It's not in core, but other modules that this distribution
# installs are)
if ('Locale::Codes' eq $module_id) {
$core = 1;
}
# Actually do the installation.
$self->install_distribution(
name => $module_file,
mod_name => $self->_packlist_fix($module_id),
$self->_install_location($core),
$force
? ( force => 1 )
: (),
);
#>>>
return 1;
} ## end sub _install_cpan_module
sub _skip_upgrade { my ( $self, $module ) = @_;
# DON'T try to install Perl at this point!
return 1 if $module->cpan_file() =~ m{/perl-5 [.]}msx;
# DON'T try to install Term::ReadKey, we
# already upgraded it.
return 1 if $module->id() eq 'Term::ReadKey';
# DON'T try to install Win32API::Registry, we
# already upgraded it as far as we can.
return 1 if $module->id() eq 'Win32API::Registry';
# If the ID is CGI::Carp, there's a bug in the index.
return 1 if $module->id() eq 'CGI::Carp';
# If the ID is ExtUtils::MakeMaker, we've already installed it.
# There were some files gotten rid of after 6.50, so
# install_cpan_upgrades thinks that it needs to upgrade
# those files using it when using perl versions that
# still had those files.
# This code is in here for safety as of yet.
return 1 if $module->cpan_file() =~ m{/ExtUtils-MakeMaker-6 [.] 50}msx;
return 0;
} ## end sub _skip_upgrade
##################################################################### # Perl installation support
The install_perl method is a minimal routine provided to call the
_install_perl_plugin routine (which the "perl version" plugins
provide.)
Returns true or throws an exception.
This is recommended to be used as a task in the tasklist, and is in the default tasklist after the "c toolchain" is installed.
The install_perl_toolchain method is a routine provided to install the
"perl toolchain": the modules required for CPAN and CPANPLUS to be able to
install modules.
Returns true (technically, the object that called it), or throws an exception.
This is recommended to be used as a task in the tasklist, and is in the default tasklist after the perl interpreter is installed.
See Perl::Dist::WiX::Diagnostics (Perl::Dist::WiX::Diagnostics) for a list of exceptions that this module can throw.
Bugs should be reported via:
1) The CPAN bug tracker at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-Dist-WiX if you have an account there.
2) Email to <bug-Perl-Dist-WiX@rt.cpan.org> if you do not.
For other issues, contact the topmost author.
Curtis Jewell <csjewell@cpan.org>
Adam Kennedy <adamk@cpan.org>
Copyright 2009 - 2011 Curtis Jewell.
Copyright 2008 - 2009 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this distribution.
| Perl-Dist-WiX documentation | view source | Contained in the Perl-Dist-WiX distribution. |