Perl-Dist-WiX
view release on metacpan or search on metacpan
lib/Perl/Dist/WiX/Asset/Module.pm view on Meta::CPAN
has assume_installed => (
is => 'bare',
isa => Bool,
reader => '_get_assume',
default => 0,
);
=head3 feature
Specifies which feature the module is supposed to go in.
=cut
has feature => (
is => 'bare',
isa => Maybe [Str],
reader => 'get_feature',
default => undef,
);
=head2 install
The install method installs the module described by the
B<Perl::Dist::WiX::Asset::Module> object and returns the files
that were installed as a L<File::List::Object|File::List::Object> object.
=cut
sub install {
my $self = shift;
# Set up variables needed.
my $name = $self->get_name();
my $force = $self->_get_force();
my $assume = $self->_get_assume();
my $packlist_flag = $self->_get_packlist();
my $use_sqlite = $self->_use_sqlite();
my $vendor =
!$self->_get_parent()->portable() ? 1
: ( $self->_get_parent()->perl_major_version() >= 12 ) ? 1
: 0;
# Verify the existence of perl.
if ( not $self->_get_bin_perl() ) {
PDWiX->throw(
'Cannot install CPAN modules yet, perl is not installed');
}
# Generate the CPAN installation script.
my $dist_file = catfile( $self->_get_output_dir(), 'cpan_distro.txt' );
my $url = $self->_get_cpan()->as_string();
my $dp_dir = catdir( $self->_get_wix_dist_dir(), 'distroprefs' );
my $internet_available = ( $url =~ m{ \A file://}msx ) ? 1 : 0;
my $cpan_string = <<"END_PERL";
print "Loading CPAN...\\n";
use CPAN 1.9600;
CPAN::HandleConfig->load unless \$CPAN::Config_loaded++;
\$CPAN::Config->{'urllist'} = [ '$url' ];
\$CPAN::Config->{'use_sqlite'} = q[$use_sqlite];
\$CPAN::Config->{'prefs_dir'} = q[$dp_dir];
\$CPAN::Config->{'patches_dir'} = q[$dp_dir];
\$CPAN::Config->{'prerequisites_policy'} = q[ignore];
\$CPAN::Config->{'connect_to_internet_ok'} = q[$internet_available];
\$CPAN::Config->{'ftp'} = q[];
if ($vendor) {
\$CPAN::Config->{'makepl_arg'} = q[INSTALLDIRS=vendor];
\$CPAN::Config->{'make_install_arg'} = q[INSTALLDIRS=vendor];
\$CPAN::Config->{'mbuildpl_arg'} = q[--installdirs vendor];
\$CPAN::Config->{'mbuild_install_arg'} = q[--installdirs vendor];
}
print "Installing $name from CPAN...\\n";
my \$module = CPAN::Shell->expandany( "$name" )
or die "CPAN.pm couldn't locate $name";
my \$dist_file = '$dist_file';
if ( \$module->uptodate ) {
unlink \$dist_file;
print "$name is up to date\\n";
exit(0);
}
SCOPE: {
open( CPAN_FILE, '>', \$dist_file ) or die "open: \$!";
print CPAN_FILE
\$module->distribution()->pretty_id() or die "print: \$!";
close( CPAN_FILE ) or die "close: \$!";
}
print "\\\$ENV{PATH} = '\$ENV{PATH}'\\n";
if ( $force ) {
CPAN::Shell->notest('install', '$name');
} else {
CPAN::Shell->install('$name');
}
print "Completed install of $name\\n";
unless ( $assume or \$module->uptodate() ) {
die "Installation of $name appears to have failed";
}
exit(0);
END_PERL
# Scan the perl directory if that's needed.
my $filelist_sub;
if ( not $self->_get_packlist() ) {
$filelist_sub =
File::List::Object->new()->readdir( $self->_dir('perl') );
$self->_trace_line( 5,
"***** Module being installed $name"
. " requires packlist => 0 *****\n" );
}
# Dump the CPAN script to a temp file and execute
$self->_trace_line( 1, "Running install of $name\n" );
$self->_trace_line( 2, ' at ' . localtime() . "\n" );
my $cpan_file = catfile( $self->_get_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
( run in 2.591 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )