smokebrew
view release on metacpan or search on metacpan
lib/App/SmokeBrew/Plugin/CPANPLUS/YACSmoke.pm view on Meta::CPAN
use IO::Handle;
open my $boxed, '>', 'bin/boxer' or die "$!\n";
$boxed->autoflush(1);
print $boxed $self->_boxed;
close $boxed;
my $cmd = [ $perl, 'bin/boxer' ];
local $ENV{PERL_MM_USE_DEFAULT} = 1;
return unless scalar run( command => $cmd, verbose => 1 );
}
rmtree( $extract ) unless $self->noclean();
my $conf = File::Spec->catdir( $self->prefix->absolute, 'conf', $self->perl_version );
mkpath( $conf );
{
local $ENV{APPDATA} = $conf;
my $cpconf = $self->_cpconf();
my $CWD = pushd( $self->builddir->absolute );
use IO::Handle;
open my $boxed, '>', 'cpconf.pl' or die "$!\n";
$boxed->autoflush(1);
print $boxed $cpconf;
close $boxed;
my $cmd = [ $perl, 'cpconf.pl', '--email', $self->email ];
push @$cmd, ( '--mx', $self->mx ) if $self->mx;
return unless scalar run( command => $cmd, verbose => 1 );
unlink( 'cpconf.pl' ) unless $self->noclean();
# Setup symlinks
if ( eval { symlink("",""); 1 } ) {
my $parent = realpath( File::Spec->catdir( $self->prefix->absolute, '..' ) );
my $authors = File::Spec->catdir( $parent, 'authors' );
my $smokeini = File::Spec->catfile( $parent, 'cpansmoke.ini' );
unless ( -e $smokeini ) {
open my $ini, '>', $smokeini or die "$!\n";
$ini->autoflush(1);
print $ini $self->_cpansmokeini;
close $ini;
}
mkpath( $authors ) unless -d $authors;
symlink( $authors, File::Spec->catdir( $conf, '.cpanplus', 'authors' ) );
symlink( $smokeini, File::Spec->catdir( $conf, '.cpanplus', 'cpansmoke.ini' ) );
}
}
return 1;
}
sub _boxed {
my $self = shift;
return q+
BEGIN {
use strict;
use warnings;
use Config;
use FindBin;
use File::Spec;
use File::Spec::Unix;
use vars qw[@RUN_TIME_INC $LIB_DIR $BUNDLE_DIR $BASE $PRIV_LIB];
$LIB_DIR = File::Spec->catdir( $FindBin::Bin, qw[.. lib] );
$BUNDLE_DIR = File::Spec->catdir( $FindBin::Bin, qw[.. inc bundle] );
my $who = getlogin || getpwuid($<) || $<;
$BASE = File::Spec->catfile(
$FindBin::Bin, '..', '.cpanplus', $who);
$PRIV_LIB = File::Spec->catfile( $BASE, 'lib' );
@RUN_TIME_INC = ($PRIV_LIB, @INC);
unshift @INC, $LIB_DIR, $BUNDLE_DIR;
$ENV{'PERL5LIB'} = join $Config{'path_sep'}, grep { defined }
$PRIV_LIB, # to find the boxed config
$LIB_DIR, # the CPANPLUS libs
$ENV{'PERL5LIB'}; # original PERL5LIB
}
use FindBin;
use File::Find qw[find];
use CPANPLUS::Error;
use CPANPLUS::Configure;
use CPANPLUS::Internals::Constants;
use CPANPLUS::Internals::Utils;
{ for my $dir ( ($BUNDLE_DIR, $LIB_DIR) ) {
my $base_re = quotemeta $dir;
find( sub { my $file = $File::Find::name;
return unless -e $file && -f _ && -s _;
return if $file =~ /\._/; # osx temp files
$file =~ s/^$base_re(\W)?//;
return if $INC{$file};
my $unixfile = File::Spec::Unix->catfile(
File::Spec->splitdir( $file )
);
my $pm = join '::', File::Spec->splitdir( $file );
$pm =~ s/\.pm$//i or return; # not a .pm file
#return if $pm =~ /(?:IPC::Run::)|(?:File::Spec::)/;
eval "require $pm ; 1";
if( $@ ) {
push @failures, $unixfile;
}
}, $dir );
}
delete $INC{$_} for @failures;
@INC = @RUN_TIME_INC;
}
my $ConfObj = CPANPLUS::Configure->new;
my $Config = CONFIG_BOXED;
my $Util = 'CPANPLUS::Internals::Utils';
my $ConfigFile = $ConfObj->_config_pm_to_file( $Config => $PRIV_LIB );
( run in 0.499 second using v1.01-cache-2.11-cpan-ceb78f64989 )