| 1 | package App::SmokeBrew::Plugin::BINGOS; | ||
| 2 | 1 | $App::SmokeBrew::Plugin::BINGOS::VERSION = '1.00'; | |
| 3 | #ABSTRACT: a smokebrew plugin to configure things like BINGOS does | ||
| 4 | |||
| 5 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | extends 'App::SmokeBrew::Plugin::CPANPLUS::YACSmoke'; | |
| 10 | |||
| 11 | 1 | has 'relay' => ( | |
| 12 | is => 'ro', | ||
| 13 | isa => 'Str', | ||
| 14 | required => 1, | ||
| 15 | ); | ||
| 16 | |||
| 17 | 1 | has 'port' => ( | |
| 18 | is => 'ro', | ||
| 19 | isa => 'Str', | ||
| 20 | required => 1, | ||
| 21 | ); | ||
| 22 | |||
| 23 | 1 | has 'testskip' => ( | |
| 24 | is => 'ro', | ||
| 25 | isa => 'Bool', | ||
| 26 | default => 0, | ||
| 27 | ); | ||
| 28 | |||
| 29 | 0 | ▶ | sub _boxed { |
|
Subroutine
_boxed: not called CC=1 SCAR=6.9
| |||
| 30 | 0 | my $self = shift; | |
| 31 | 0 | return q+ | |
| 32 | BEGIN { | ||
| 33 | use strict; | ||
| 34 | use warnings; | ||
| 35 | |||
| 36 | use Config; | ||
| 37 | use FindBin; | ||
| 38 | use File::Spec; | ||
| 39 | use File::Spec::Unix; | ||
| 40 | |||
| 41 | use vars qw[@RUN_TIME_INC $LIB_DIR $BUNDLE_DIR $BASE $PRIV_LIB]; | ||
| 42 | $LIB_DIR = File::Spec->catdir( $FindBin::Bin, qw[.. lib] ); | ||
| 43 | $BUNDLE_DIR = File::Spec->catdir( $FindBin::Bin, qw[.. inc bundle] ); | ||
| 44 | |||
| 45 | my $who = getlogin || getpwuid($<) || $<; | ||
| 46 | $BASE = File::Spec->catfile( | ||
| 47 | $FindBin::Bin, '..', '.cpanplus', $who); | ||
| 48 | $PRIV_LIB = File::Spec->catfile( $BASE, 'lib' ); | ||
| 49 | |||
| 50 | @RUN_TIME_INC = ($PRIV_LIB, @INC); | ||
| 51 | unshift @INC, $LIB_DIR, $BUNDLE_DIR; | ||
| 52 | |||
| 53 | $ENV{'PERL5LIB'} = join $Config{'path_sep'}, grep { defined } | ||
| 54 | $PRIV_LIB, # to find the boxed config | ||
| 55 | $LIB_DIR, # the CPANPLUS libs | ||
| 56 | $ENV{'PERL5LIB'}; # original PERL5LIB | ||
| 57 | |||
| 58 | } | ||
| 59 | |||
| 60 | use FindBin; | ||
| 61 | use File::Find qw[find]; | ||
| 62 | use CPANPLUS::Error; | ||
| 63 | use CPANPLUS::Configure; | ||
| 64 | use CPANPLUS::Internals::Constants; | ||
| 65 | use CPANPLUS::Internals::Utils; | ||
| 66 | |||
| 67 | { for my $dir ( ($BUNDLE_DIR, $LIB_DIR) ) { | ||
| 68 | my $base_re = quotemeta $dir; | ||
| 69 | |||
| 70 | find( sub { my $file = $File::Find::name; | ||
| 71 | return unless -e $file && -f _ && -s _; | ||
| 72 | |||
| 73 | return if $file =~ /\._/; # osx temp files | ||
| 74 | |||
| 75 | $file =~ s/^$base_re(\W)?//; | ||
| 76 | |||
| 77 | return if $INC{$file}; | ||
| 78 | |||
| 79 | my $unixfile = File::Spec::Unix->catfile( | ||
| 80 | File::Spec->splitdir( $file ) | ||
| 81 | ); | ||
| 82 | my $pm = join '::', File::Spec->splitdir( $file ); | ||
| 83 | $pm =~ s/\.pm$//i or return; # not a .pm file | ||
| 84 | |||
| 85 | #return if $pm =~ /(?:IPC::Run::)|(?:File::Spec::)/; | ||
| 86 | |||
| 87 | eval "require $pm ; 1"; | ||
| 88 | |||
| 89 | if( $@ ) { | ||
| 90 | push @failures, $unixfile; | ||
| 91 | } | ||
| 92 | }, $dir ); | ||
| 93 | } | ||
| 94 | |||
| 95 | delete $INC{$_} for @failures; | ||
| 96 | |||
| 97 | @INC = @RUN_TIME_INC; | ||
| 98 | } | ||
| 99 | |||
| 100 | |||
| 101 | my $ConfObj = CPANPLUS::Configure->new; | ||
| 102 | my $Config = CONFIG_BOXED; | ||
| 103 | my $Util = 'CPANPLUS::Internals::Utils'; | ||
| 104 | my $ConfigFile = $ConfObj->_config_pm_to_file( $Config => $PRIV_LIB ); | ||
| 105 | |||
| 106 | { ### no base dir even, set it up | ||
| 107 | unless( IS_DIR->( $BASE ) ) { | ||
| 108 | $Util->_mkdir( dir => $BASE ) or die CPANPLUS::Error->stack_as_string; | ||
| 109 | } | ||
| 110 | |||
| 111 | unless( -e $ConfigFile ) { | ||
| 112 | $ConfObj->set_conf( base => $BASE ); # new base dir | ||
| 113 | $ConfObj->set_conf( verbose => 1 ); # be verbose | ||
| 114 | $ConfObj->set_conf( prereqs => 1 ); # install prereqs | ||
| 115 | $ConfObj->set_conf( prefer_bin => 1 ); | ||
| 116 | $ConfObj->set_conf( prefer_makefile => 1 ); # prefer Makefile.PL because of v5.10.0 | ||
| 117 | $ConfObj->set_conf( enable_custom_sources => 0 ); # install prereqs | ||
| 118 | $ConfObj->set_conf( hosts => + . $self->_mirrors . q+ ); | ||
| 119 | $ConfObj->set_conf( skiptest => + . $self->testskip . q+ ); | ||
| 120 | $ConfObj->set_program( sudo => undef ); | ||
| 121 | $ConfObj->save( $Config => $PRIV_LIB ); # save the pm in that dir | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | { | ||
| 126 | $Module::Load::Conditional::CHECK_INC_HASH = 1; | ||
| 127 | use CPANPLUS::Backend; | ||
| 128 | my $cb = CPANPLUS::Backend->new( $ConfObj ); | ||
| 129 | my $su = $cb->selfupdate_object; | ||
| 130 | |||
| 131 | $cb->module_tree( 'Test::More' )->install() if $] == 5.010000; # need this because 'version' | ||
| 132 | $cb->module_tree( 'parent' )->install() if $] < 5.010001; # need this because 'version' | ||
| 133 | $cb->module_tree( 'version' )->install(); # Move this here too because EUMM icky is icky :S | ||
| 134 | $cb->module_tree( 'ExtUtils::MakeMaker' )->install(); # Move this here because icky is icky >:) | ||
| 135 | $cb->module_tree( 'Module::Build' )->install(); # Move this here because perl-5.10.0 is icky | ||
| 136 | |||
| 137 | $su->selfupdate( update => 'dependencies', latest => 1 ); | ||
| 138 | $cb->module_tree( $_ )->install() for | ||
| 139 | qw( | ||
| 140 | CPANPLUS | ||
| 141 | File::Temp | ||
| 142 | Compress::Raw::Bzip2 | ||
| 143 | Compress::Raw::Zlib | ||
| 144 | Compress::Zlib | ||
| 145 | ExtUtils::CBuilder | ||
| 146 | ExtUtils::ParseXS | ||
| 147 | ExtUtils::Manifest | ||
| 148 | Log::Message::Simple | ||
| 149 | Test::Reporter::Transport::Socket | ||
| 150 | CPANPLUS::YACSmoke | ||
| 151 | ); | ||
| 152 | $_->install() for map { $su->modules_for_feature( $_ ) } qw(prefer_makefile md5 storable cpantest); | ||
| 153 | } | ||
| 154 | +; | ||
| 155 | } | ||
| 156 | |||
| 157 | 0 | ▶ | sub _cpconf { |
|
Subroutine
_cpconf: not called CC=1 SCAR=6.9
| |||
| 158 | 0 | my $self = shift; | |
| 159 | 0 | my $cpconf = q+ | |
| 160 | use strict; | ||
| 161 | use warnings; | ||
| 162 | use Getopt::Long; | ||
| 163 | use CPANPLUS::Configure; | ||
| 164 | |||
| 165 | my $mx; | ||
| 166 | my $email; | ||
| 167 | |||
| 168 | GetOptions( 'mx=s', \$mx, 'email=s', \$email ); | ||
| 169 | |||
| 170 | my $conf = CPANPLUS::Configure->new(); | ||
| 171 | $conf->set_conf( verbose => 1 ); | ||
| 172 | $conf->set_conf( prefer_bin => 1 ); | ||
| 173 | $conf->set_conf( cpantest => 'dont_cc' ); | ||
| 174 | $conf->set_conf( 'cpantest_reporter_args' => | ||
| 175 | { | ||
| 176 | transport => 'Socket', | ||
| 177 | transport_args => [ host => +; | ||
| 178 | 0 | $cpconf .= sprintf( "'%s', port => '%s' ] } );", $self->relay, $self->port ); | |
| 179 | 0 | $cpconf .= q+ | |
| 180 | $conf->set_conf( email => $email ); | ||
| 181 | $conf->set_conf( makeflags => 'UNINST=1' ); | ||
| 182 | $conf->set_conf( buildflags => 'uninst=1' ); | ||
| 183 | $conf->set_conf( enable_custom_sources => 0 ); | ||
| 184 | $conf->set_conf( show_startup_tip => 0 ); | ||
| 185 | $conf->set_conf( write_install_logs => 0 ); | ||
| 186 | $conf->set_conf( hosts => +; | ||
| 187 | 0 | $cpconf .= $self->_mirrors() . ');'; | |
| 188 | 0 | $cpconf .= q+ | |
| 189 | $conf->set_program( sudo => undef ); | ||
| 190 | $conf->save(); | ||
| 191 | exit 0; | ||
| 192 | +; | ||
| 193 | 0 | return $cpconf; | |
| 194 | } | ||
| 195 | |||
| 196 | 1 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 197 | |||
| 198 | 1 | __PACKAGE__->meta->make_immutable; | |
| 199 | |||
| 200 | 1 | qq[Smokin']; | |
| 201 | |||
| 202 | __END__ | ||