line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPANPLUS::Dist::Build; |
2
|
|
|
|
|
|
|
$CPANPLUS::Dist::Build::VERSION = '0.88'; |
3
|
|
|
|
|
|
|
#ABSTRACT: CPANPLUS plugin to install packages that use Build.PL |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
36885
|
use if $] > 5.017, 'deprecate'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
203
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
9
|
1
|
|
|
1
|
|
6
|
use vars qw[@ISA $STATUS]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
10
|
|
|
|
|
|
|
@ISA = qw[CPANPLUS::Dist]; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
10
|
use CPANPLUS::Internals::Constants; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
327
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
### these constants were exported by CPANPLUS::Internals::Constants |
15
|
|
|
|
|
|
|
### in previous versions.. they do the same though. If we want to have |
16
|
|
|
|
|
|
|
### a normal 'use' here, up the dependency to CPANPLUS 0.056 or higher |
17
|
|
|
|
|
|
|
BEGIN { |
18
|
1
|
|
|
1
|
|
416
|
require CPANPLUS::Dist::Build::Constants; |
19
|
1
|
50
|
33
|
|
|
57
|
CPANPLUS::Dist::Build::Constants->import() |
20
|
|
|
|
|
|
|
if not __PACKAGE__->can('BUILD') && __PACKAGE__->can('BUILD_DIR'); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
6
|
use CPANPLUS::Error; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use Config; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
26
|
1
|
|
|
1
|
|
5
|
use FileHandle; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
27
|
1
|
|
|
1
|
|
374
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
28
|
1
|
|
|
1
|
|
20
|
use version; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
72
|
use IPC::Cmd qw[run]; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
38
|
|
31
|
1
|
|
|
1
|
|
5
|
use Params::Check qw[check]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
32
|
1
|
|
|
1
|
|
5
|
use Module::Load::Conditional qw[can_load check_install]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
33
|
1
|
|
|
1
|
|
5
|
use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
local $Params::Check::VERBOSE = 1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
### check if the format is available ### |
40
|
|
|
|
|
|
|
sub format_available { |
41
|
4
|
|
|
4
|
1
|
1376419
|
my $mod = 'Module::Build'; |
42
|
4
|
50
|
|
|
|
33
|
unless( can_load( modules => { $mod => '0.2611' }, nocache => 1 ) ) { |
43
|
0
|
|
|
|
|
0
|
error( loc( "You do not have '%1' -- '%2' not available", |
44
|
|
|
|
|
|
|
$mod, __PACKAGE__ ) ); |
45
|
0
|
|
|
|
|
0
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
86256
|
return 1; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub init { |
54
|
3
|
|
|
3
|
1
|
34
|
my $dist = shift; |
55
|
3
|
|
|
|
|
31
|
my $status = $dist->status; |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
421
|
$status->mk_accessors(qw[build_pl build test created installed uninstalled |
58
|
|
|
|
|
|
|
_create_args _install_args _prepare_args |
59
|
|
|
|
|
|
|
_mb_object _buildflags _metadata |
60
|
|
|
|
|
|
|
]); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
### just in case 'format_available' didn't get called |
63
|
3
|
|
|
|
|
402
|
require Module::Build; |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
13
|
return 1; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub prepare { |
70
|
|
|
|
|
|
|
### just in case you already did a create call for this module object |
71
|
|
|
|
|
|
|
### just via a different dist object |
72
|
7
|
|
|
7
|
1
|
27695
|
my $dist = shift; |
73
|
7
|
|
|
|
|
44
|
my $self = $dist->parent; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
### we're also the cpan_dist, since we don't need to have anything |
76
|
|
|
|
|
|
|
### prepared from another installer |
77
|
7
|
50
|
|
|
|
682
|
$dist = $self->status->dist_cpan if $self->status->dist_cpan; |
78
|
7
|
50
|
|
|
|
1264
|
$self->status->dist_cpan( $dist ) unless $self->status->dist_cpan; |
79
|
|
|
|
|
|
|
|
80
|
7
|
|
|
|
|
656
|
my $cb = $self->parent; |
81
|
7
|
|
|
|
|
161
|
my $conf = $cb->configure_object; |
82
|
7
|
|
|
|
|
93
|
my %hash = @_; |
83
|
|
|
|
|
|
|
|
84
|
7
|
|
|
|
|
23
|
my $dir; |
85
|
7
|
50
|
|
|
|
26
|
unless( $dir = $self->status->extract ) { |
86
|
0
|
|
|
|
|
0
|
error( loc( "No dir found to operate on!" ) ); |
87
|
0
|
|
|
|
|
0
|
return; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
7
|
|
|
|
|
648
|
my $args; |
91
|
7
|
|
|
|
|
22
|
my( $force, $verbose, $buildflags, $perl, $prereq_target, $prereq_format, |
92
|
|
|
|
|
|
|
$prereq_build ); |
93
|
7
|
|
|
|
|
15
|
{ local $Params::Check::ALLOW_UNKNOWN = 1; |
|
7
|
|
|
|
|
20
|
|
94
|
7
|
|
|
|
|
48
|
my $tmpl = { |
95
|
|
|
|
|
|
|
force => { default => $conf->get_conf('force'), |
96
|
|
|
|
|
|
|
store => \$force }, |
97
|
|
|
|
|
|
|
verbose => { default => $conf->get_conf('verbose'), |
98
|
|
|
|
|
|
|
store => \$verbose }, |
99
|
|
|
|
|
|
|
perl => { default => $^X, store => \$perl }, |
100
|
|
|
|
|
|
|
buildflags => { default => $conf->get_conf('buildflags'), |
101
|
|
|
|
|
|
|
store => \$buildflags }, |
102
|
|
|
|
|
|
|
prereq_target => { default => '', store => \$prereq_target }, |
103
|
|
|
|
|
|
|
prereq_format => { default => '', |
104
|
|
|
|
|
|
|
store => \$prereq_format }, |
105
|
|
|
|
|
|
|
prereq_build => { default => 0, store => \$prereq_build }, |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
|
108
|
7
|
50
|
|
|
|
5628
|
$args = check( $tmpl, \%hash ) or return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
7
|
100
|
100
|
|
|
1759
|
return 1 if $dist->status->prepared && !$force; |
112
|
|
|
|
|
|
|
|
113
|
5
|
|
|
|
|
976
|
$dist->status->_prepare_args( $args ); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
### chdir to work directory ### |
116
|
5
|
|
|
|
|
19056
|
my $orig = cwd(); |
117
|
5
|
50
|
|
|
|
144
|
unless( $cb->_chdir( dir => $dir ) ) { |
118
|
0
|
|
|
|
|
0
|
error( loc( "Could not chdir to build directory '%1'", $dir ) ); |
119
|
0
|
|
|
|
|
0
|
return; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
### by now we've loaded module::build, and we're using the API, so |
123
|
|
|
|
|
|
|
### it's safe to remove CPANPLUS::inc from our inc path, especially |
124
|
|
|
|
|
|
|
### because it can trip up tests run under taint (just like EU::MM). |
125
|
|
|
|
|
|
|
### turn off our PERL5OPT so no modules from CPANPLUS::inc get |
126
|
|
|
|
|
|
|
### included in make test -- it should build without. |
127
|
|
|
|
|
|
|
### also, modules that run in taint mode break if we leave |
128
|
|
|
|
|
|
|
### our code ref in perl5opt |
129
|
|
|
|
|
|
|
### XXX we've removed the ENV settings from cp::inc, so only need |
130
|
|
|
|
|
|
|
### to reset the @INC |
131
|
|
|
|
|
|
|
#local $ENV{PERL5OPT} = CPANPLUS::inc->original_perl5opt; |
132
|
|
|
|
|
|
|
#local $ENV{PERL5LIB} = CPANPLUS::inc->original_perl5lib; |
133
|
|
|
|
|
|
|
#local @INC = CPANPLUS::inc->original_inc; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
### this will generate warnings under anything lower than M::B 0.2606 |
136
|
5
|
|
|
|
|
1447
|
my @buildflags = $dist->_buildflags_as_list( $buildflags ); |
137
|
5
|
|
|
|
|
1115
|
$dist->status->_buildflags( $buildflags ); |
138
|
|
|
|
|
|
|
|
139
|
5
|
|
|
|
|
1480
|
my $fail; my $prereq_fail; |
140
|
5
|
|
|
|
|
20
|
my $status = { }; |
141
|
|
|
|
|
|
|
RUN: { |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# 0.85_01 |
144
|
|
|
|
|
|
|
### we resolve 'configure requires' here, so we can run the 'perl |
145
|
|
|
|
|
|
|
### Makefile.PL' command |
146
|
|
|
|
|
|
|
### XXX for tests: mock f_c_r to something that *can* resolve and |
147
|
|
|
|
|
|
|
### something that *doesn't* resolve. Check the error log for ok |
148
|
|
|
|
|
|
|
### on this step or failure |
149
|
|
|
|
|
|
|
### XXX make a separate tarball to test for this scenario: simply |
150
|
|
|
|
|
|
|
### containing a makefile.pl/build.pl for test purposes? |
151
|
5
|
|
|
|
|
17
|
my $safe_ver = version->new('0.85_01'); |
|
5
|
|
|
|
|
84
|
|
152
|
5
|
50
|
|
|
|
100
|
if ( version->new($CPANPLUS::Internals::VERSION) >= $safe_ver ) |
153
|
5
|
|
|
|
|
58
|
{ my $configure_requires = $dist->find_configure_requires; |
154
|
5
|
|
|
|
|
19726
|
my $ok = $dist->_resolve_prereqs( |
155
|
|
|
|
|
|
|
format => $prereq_format, |
156
|
|
|
|
|
|
|
verbose => $verbose, |
157
|
|
|
|
|
|
|
prereqs => $configure_requires, |
158
|
|
|
|
|
|
|
target => $prereq_target, |
159
|
|
|
|
|
|
|
force => $force, |
160
|
|
|
|
|
|
|
prereq_build => $prereq_build, |
161
|
|
|
|
|
|
|
); |
162
|
|
|
|
|
|
|
|
163
|
5
|
50
|
|
|
|
7461
|
unless( $ok ) { |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
#### use $dist->flush to reset the cache ### |
166
|
0
|
|
|
|
|
0
|
error( loc( "Unable to satisfy '%1' for '%2' " . |
167
|
|
|
|
|
|
|
"-- aborting install", |
168
|
|
|
|
|
|
|
'configure_requires', $self->module ) ); |
169
|
0
|
|
|
|
|
0
|
$dist->status->prepared(0); |
170
|
0
|
|
|
|
|
0
|
$prereq_fail++; |
171
|
0
|
|
|
|
|
0
|
$fail++; |
172
|
0
|
|
|
|
|
0
|
last RUN; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
### end of prereq resolving ### |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Wrap the exception that may be thrown here (should likely be |
178
|
|
|
|
|
|
|
# done at a much higher level). |
179
|
5
|
|
|
|
|
23
|
my $prep_output; |
180
|
|
|
|
|
|
|
|
181
|
5
|
|
|
|
|
34
|
my $metadata = $dist->status->_metadata; |
182
|
5
|
50
|
33
|
|
|
972
|
my $x_use_unsafe_inc = ( defined $metadata && exists $metadata->{x_use_unsafe_inc} ? $metadata->{x_use_unsafe_inc} : undef ); |
183
|
5
|
50
|
|
|
|
23
|
$x_use_unsafe_inc = 1 unless defined $x_use_unsafe_inc; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
local $ENV{PERL_USE_UNSAFE_INC} = $x_use_unsafe_inc |
186
|
5
|
50
|
|
|
|
63
|
unless exists $ENV{PERL_USE_UNSAFE_INC}; |
187
|
|
|
|
|
|
|
|
188
|
5
|
|
|
|
|
23
|
my $env = ENV_CPANPLUS_IS_EXECUTING; |
189
|
5
|
|
|
|
|
31
|
local $ENV{$env} = BUILD_PL->( $dir ); |
190
|
5
|
|
|
|
|
121
|
my @run_perl = $dist->_perlrun(); |
191
|
5
|
|
|
|
|
24
|
my $cmd = [$perl, @run_perl, BUILD_PL->($dir), @buildflags]; |
192
|
|
|
|
|
|
|
|
193
|
5
|
100
|
|
|
|
100
|
unless ( scalar run( command => $cmd, |
194
|
|
|
|
|
|
|
buffer => \$prep_output, |
195
|
|
|
|
|
|
|
verbose => $verbose ) |
196
|
|
|
|
|
|
|
) { |
197
|
1
|
|
|
|
|
9630
|
error( loc( "Build.PL failed: %1", $prep_output ) ); |
198
|
1
|
50
|
|
|
|
1970
|
if ( $conf->get_conf('cpantest') ) { |
199
|
0
|
|
|
|
|
0
|
$status->{stage} = 'prepare'; |
200
|
0
|
|
|
|
|
0
|
$status->{capture} = $prep_output; |
201
|
|
|
|
|
|
|
} |
202
|
1
|
|
|
|
|
259
|
$fail++; last RUN; |
|
1
|
|
|
|
|
32
|
|
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
4
|
50
|
|
|
|
953501
|
unless ( -e BUILD->( $dir ) ) { |
206
|
0
|
|
|
|
|
0
|
error( loc( "Build.PL failed to generate a Build script: %1", $prep_output ) ); |
207
|
0
|
0
|
|
|
|
0
|
if ( $conf->get_conf('cpantest') ) { |
208
|
0
|
|
|
|
|
0
|
$status->{stage} = 'prepare'; |
209
|
0
|
|
|
|
|
0
|
$status->{capture} = $prep_output; |
210
|
|
|
|
|
|
|
} |
211
|
0
|
|
|
|
|
0
|
$fail++; last RUN; |
|
0
|
|
|
|
|
0
|
|
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
4
|
|
|
|
|
91
|
msg( $prep_output, 0 ); |
215
|
|
|
|
|
|
|
|
216
|
4
|
|
|
|
|
6914
|
my $prereqs = $self->status->prereqs; |
217
|
|
|
|
|
|
|
|
218
|
4
|
|
66
|
|
|
795
|
$prereqs ||= $dist->_find_prereqs( verbose => $verbose, |
219
|
|
|
|
|
|
|
dir => $dir, |
220
|
|
|
|
|
|
|
perl => $perl, |
221
|
|
|
|
|
|
|
buildflags => $buildflags ); |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
### send out test report? ### |
226
|
|
|
|
|
|
|
### there is no way to accurately know if it is a PASS/FAIL/ETC |
227
|
|
|
|
|
|
|
### CPANPLUS::Dist::MM doesn't bother why are we? |
228
|
5
|
|
|
|
|
24
|
if( 0 and $fail and $conf->get_conf('cpantest') and not $prereq_fail ) { |
229
|
|
|
|
|
|
|
$cb->_send_report( |
230
|
|
|
|
|
|
|
module => $self, |
231
|
|
|
|
|
|
|
failed => $fail, |
232
|
|
|
|
|
|
|
buffer => CPANPLUS::Error->stack_as_string, |
233
|
|
|
|
|
|
|
status => $status, |
234
|
|
|
|
|
|
|
verbose => $verbose, |
235
|
|
|
|
|
|
|
force => $force, |
236
|
|
|
|
|
|
|
) or error(loc("Failed to send test report for '%1'", |
237
|
|
|
|
|
|
|
$self->module ) ); |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
5
|
50
|
|
|
|
60
|
unless( $cb->_chdir( dir => $orig ) ) { |
241
|
0
|
|
|
|
|
0
|
error( loc( "Could not chdir back to start dir '%1'", $orig ) ); |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
### save where we wrote this stuff -- same as extract dir in normal |
245
|
|
|
|
|
|
|
### installer circumstances |
246
|
5
|
|
|
|
|
900
|
$dist->status->distdir( $self->status->extract ); |
247
|
|
|
|
|
|
|
|
248
|
5
|
100
|
|
|
|
1740
|
return $dist->status->prepared( $fail ? 0 : 1 ); |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub _find_prereqs { |
252
|
2
|
|
|
2
|
|
8
|
my $dist = shift; |
253
|
2
|
|
|
|
|
18
|
my $self = $dist->parent; |
254
|
2
|
|
|
|
|
237
|
my $cb = $self->parent; |
255
|
2
|
|
|
|
|
82
|
my $conf = $cb->configure_object; |
256
|
2
|
|
|
|
|
44
|
my %hash = @_; |
257
|
|
|
|
|
|
|
|
258
|
2
|
|
|
|
|
7
|
my ($verbose, $dir, $buildflags, $perl); |
259
|
2
|
|
|
|
|
32
|
my $tmpl = { |
260
|
|
|
|
|
|
|
verbose => { default => $conf->get_conf('verbose'), store => \$verbose }, |
261
|
|
|
|
|
|
|
dir => { default => $self->status->extract, store => \$dir }, |
262
|
|
|
|
|
|
|
perl => { default => $^X, store => \$perl }, |
263
|
|
|
|
|
|
|
buildflags => { default => $conf->get_conf('buildflags'), |
264
|
|
|
|
|
|
|
store => \$buildflags }, |
265
|
|
|
|
|
|
|
}; |
266
|
|
|
|
|
|
|
|
267
|
2
|
50
|
|
|
|
1135
|
my $args = check( $tmpl, \%hash ) or return; |
268
|
|
|
|
|
|
|
|
269
|
2
|
|
|
|
|
342
|
my $prereqs = {}; |
270
|
|
|
|
|
|
|
|
271
|
2
|
50
|
|
|
|
12
|
$prereqs = $dist->find_mymeta_requires() |
272
|
|
|
|
|
|
|
if $dist->can('find_mymeta_requires'); |
273
|
|
|
|
|
|
|
|
274
|
2
|
100
|
|
|
|
13583
|
if ( keys %$prereqs ) { |
275
|
|
|
|
|
|
|
# Ugly hack |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
else { |
278
|
1
|
|
|
|
|
24
|
my $safe_ver = version->new('0.31_03'); |
279
|
1
|
|
|
|
|
4
|
my $content; |
280
|
|
|
|
|
|
|
PREREQS: { |
281
|
1
|
50
|
33
|
|
|
3
|
if ( version->new( $Module::Build::VERSION ) >= $safe_ver and IPC::Cmd->can_capture_buffer ) { |
|
1
|
|
|
|
|
37
|
|
282
|
1
|
|
|
|
|
231
|
my @buildflags = $dist->_buildflags_as_list( $buildflags ); |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
# Use the new Build action 'prereq_data' |
285
|
1
|
|
|
|
|
153
|
my @run_perl = $dist->_perlrun(); |
286
|
|
|
|
|
|
|
|
287
|
1
|
50
|
|
|
|
7
|
unless ( scalar run( command => [$perl, @run_perl, BUILD->($dir), 'prereq_data', @buildflags], |
288
|
|
|
|
|
|
|
buffer => \$content, |
289
|
|
|
|
|
|
|
verbose => 0 ) |
290
|
|
|
|
|
|
|
) { |
291
|
0
|
|
|
|
|
0
|
error( loc( "Build 'prereq_data' failed: %1 %2", $!, $content ) ); |
292
|
|
|
|
|
|
|
#return; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
else { |
295
|
1
|
|
|
|
|
130444
|
last PREREQS; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
0
|
|
|
|
|
0
|
my $file = File::Spec->catfile( $dir, '_build', 'prereqs' ); |
301
|
0
|
0
|
|
|
|
0
|
return unless -f $file; |
302
|
|
|
|
|
|
|
|
303
|
0
|
|
|
|
|
0
|
my $fh = FileHandle->new(); |
304
|
|
|
|
|
|
|
|
305
|
0
|
0
|
|
|
|
0
|
unless( $fh->open( $file ) ) { |
306
|
0
|
|
|
|
|
0
|
error( loc( "Cannot open '%1': %2", $file, $! ) ); |
307
|
0
|
|
|
|
|
0
|
return; |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
0
|
$content = do { local $/; <$fh> }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
1
|
50
|
|
|
|
26
|
return unless $content; |
315
|
1
|
|
|
|
|
168
|
my $bphash = eval $content; |
316
|
1
|
50
|
33
|
|
|
15
|
return unless $bphash and ref $bphash eq 'HASH'; |
317
|
1
|
|
|
|
|
8
|
foreach my $type ('requires', 'build_requires', 'test_requires') { |
318
|
3
|
50
|
33
|
|
|
26
|
next unless $bphash->{$type} and ref $bphash->{$type} eq 'HASH'; |
319
|
0
|
|
|
|
|
0
|
$prereqs->{$_} = $bphash->{$type}->{$_} for keys %{ $bphash->{$type} }; |
|
0
|
|
|
|
|
0
|
|
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
{ |
324
|
2
|
50
|
|
|
|
5
|
delete $prereqs->{'perl'} |
|
2
|
|
|
|
|
57
|
|
325
|
|
|
|
|
|
|
unless version->new($CPANPLUS::Internals::VERSION) |
326
|
|
|
|
|
|
|
>= version->new('0.9102'); |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
### allows for a user defined callback to filter the prerequisite |
330
|
|
|
|
|
|
|
### list as they see fit, to remove (or add) any prereqs they see |
331
|
|
|
|
|
|
|
### fit. The default installed callback will return the hashref in |
332
|
|
|
|
|
|
|
### an unmodified form |
333
|
|
|
|
|
|
|
### this callback got added after cpanplus 0.0562, so use a 'can' |
334
|
|
|
|
|
|
|
### to find out if it's supported. For older versions, we'll just |
335
|
|
|
|
|
|
|
### return the hashref as is ourselves. |
336
|
2
|
50
|
|
|
|
33
|
my $href = $cb->_callbacks->can('filter_prereqs') |
337
|
|
|
|
|
|
|
? $cb->_callbacks->filter_prereqs->( $cb, $prereqs ) |
338
|
|
|
|
|
|
|
: $prereqs; |
339
|
|
|
|
|
|
|
|
340
|
2
|
|
|
|
|
4313
|
$self->status->prereqs( $href ); |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
### make sure it's not the same ref |
343
|
2
|
|
|
|
|
306
|
return { %$href }; |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
sub create { |
348
|
|
|
|
|
|
|
### just in case you already did a create call for this module object |
349
|
|
|
|
|
|
|
### just via a different dist object |
350
|
4
|
|
|
4
|
1
|
1352
|
my $dist = shift; |
351
|
4
|
|
|
|
|
31
|
my $self = $dist->parent; |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
### we're also the cpan_dist, since we don't need to have anything |
354
|
|
|
|
|
|
|
### prepared from another installer |
355
|
4
|
50
|
|
|
|
464
|
$dist = $self->status->dist_cpan if $self->status->dist_cpan; |
356
|
4
|
50
|
|
|
|
734
|
$self->status->dist_cpan( $dist ) unless $self->status->dist_cpan; |
357
|
|
|
|
|
|
|
|
358
|
4
|
|
|
|
|
400
|
my $cb = $self->parent; |
359
|
4
|
|
|
|
|
137
|
my $conf = $cb->configure_object; |
360
|
4
|
|
|
|
|
62
|
my %hash = @_; |
361
|
|
|
|
|
|
|
|
362
|
4
|
|
|
|
|
10
|
my $dir; |
363
|
4
|
50
|
|
|
|
14
|
unless( $dir = $self->status->extract ) { |
364
|
0
|
|
|
|
|
0
|
error( loc( "No dir found to operate on!" ) ); |
365
|
0
|
|
|
|
|
0
|
return; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
4
|
|
|
|
|
384
|
my $args; |
369
|
4
|
|
|
|
|
14
|
my( $force, $verbose, $buildflags, $skiptest, $prereq_target, |
370
|
|
|
|
|
|
|
$perl, $prereq_format, $prereq_build); |
371
|
4
|
|
|
|
|
8
|
{ local $Params::Check::ALLOW_UNKNOWN = 1; |
|
4
|
|
|
|
|
14
|
|
372
|
4
|
|
|
|
|
49
|
my $tmpl = { |
373
|
|
|
|
|
|
|
force => { default => $conf->get_conf('force'), |
374
|
|
|
|
|
|
|
store => \$force }, |
375
|
|
|
|
|
|
|
verbose => { default => $conf->get_conf('verbose'), |
376
|
|
|
|
|
|
|
store => \$verbose }, |
377
|
|
|
|
|
|
|
perl => { default => $^X, store => \$perl }, |
378
|
|
|
|
|
|
|
buildflags => { default => $conf->get_conf('buildflags'), |
379
|
|
|
|
|
|
|
store => \$buildflags }, |
380
|
|
|
|
|
|
|
skiptest => { default => $conf->get_conf('skiptest'), |
381
|
|
|
|
|
|
|
store => \$skiptest }, |
382
|
|
|
|
|
|
|
prereq_target => { default => '', store => \$prereq_target }, |
383
|
|
|
|
|
|
|
### don't set the default format to 'build' -- that is wrong! |
384
|
|
|
|
|
|
|
prereq_format => { #default => $self->status->installer_type, |
385
|
|
|
|
|
|
|
default => '', |
386
|
|
|
|
|
|
|
store => \$prereq_format }, |
387
|
|
|
|
|
|
|
prereq_build => { default => 0, store => \$prereq_build }, |
388
|
|
|
|
|
|
|
}; |
389
|
|
|
|
|
|
|
|
390
|
4
|
50
|
|
|
|
4381
|
$args = check( $tmpl, \%hash ) or return; |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
# restore the state as we have created this already. |
394
|
4
|
50
|
66
|
|
|
1037
|
if ( $dist->status->created && !$force ) { |
395
|
|
|
|
|
|
|
### add this directory to your lib ### |
396
|
0
|
|
|
|
|
0
|
$self->add_to_includepath(); |
397
|
0
|
|
|
|
|
0
|
return 1; |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
4
|
|
|
|
|
1129
|
$dist->status->_create_args( $args ); |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
### is this dist prepared? |
403
|
4
|
50
|
|
|
|
880
|
unless( $dist->status->prepared ) { |
404
|
0
|
|
|
|
|
0
|
error( loc( "You have not successfully prepared a '%2' distribution ". |
405
|
|
|
|
|
|
|
"yet -- cannot create yet", __PACKAGE__ ) ); |
406
|
0
|
|
|
|
|
0
|
return; |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
### chdir to work directory ### |
410
|
4
|
|
|
|
|
15558
|
my $orig = cwd(); |
411
|
4
|
50
|
|
|
|
83
|
unless( $cb->_chdir( dir => $dir ) ) { |
412
|
0
|
|
|
|
|
0
|
error( loc( "Could not chdir to build directory '%1'", $dir ) ); |
413
|
0
|
|
|
|
|
0
|
return; |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
### by now we've loaded module::build, and we're using the API, so |
417
|
|
|
|
|
|
|
### it's safe to remove CPANPLUS::inc from our inc path, especially |
418
|
|
|
|
|
|
|
### because it can trip up tests run under taint (just like EU::MM). |
419
|
|
|
|
|
|
|
### turn off our PERL5OPT so no modules from CPANPLUS::inc get |
420
|
|
|
|
|
|
|
### included in make test -- it should build without. |
421
|
|
|
|
|
|
|
### also, modules that run in taint mode break if we leave |
422
|
|
|
|
|
|
|
### our code ref in perl5opt |
423
|
|
|
|
|
|
|
### XXX we've removed the ENV settings from cp::inc, so only need |
424
|
|
|
|
|
|
|
### to reset the @INC |
425
|
|
|
|
|
|
|
#local $ENV{PERL5OPT} = CPANPLUS::inc->original_perl5opt; |
426
|
|
|
|
|
|
|
#local $ENV{PERL5LIB} = CPANPLUS::inc->original_perl5lib; |
427
|
|
|
|
|
|
|
#local @INC = CPANPLUS::inc->original_inc; |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
### but do it *before* the new_from_context, as M::B seems |
430
|
|
|
|
|
|
|
### to be actually running the file... |
431
|
|
|
|
|
|
|
### an unshift in the block seems to be ignored.. somehow... |
432
|
|
|
|
|
|
|
#{ my $lib = $self->best_path_to_module_build; |
433
|
|
|
|
|
|
|
# unshift @INC, $lib if $lib; |
434
|
|
|
|
|
|
|
#} |
435
|
4
|
50
|
|
|
|
1049
|
unshift @INC, $self->best_path_to_module_build |
436
|
|
|
|
|
|
|
if $self->best_path_to_module_build; |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
### this will generate warnings under anything lower than M::B 0.2606 |
439
|
4
|
|
|
|
|
65
|
my @buildflags = $dist->_buildflags_as_list( $buildflags ); |
440
|
4
|
|
|
|
|
784
|
$dist->status->_buildflags( $buildflags ); |
441
|
|
|
|
|
|
|
|
442
|
4
|
|
|
|
|
1051
|
my $fail; my $prereq_fail; my $test_fail; |
|
4
|
|
|
|
|
0
|
|
443
|
4
|
|
|
|
|
13
|
my $status = { }; |
444
|
|
|
|
|
|
|
RUN: { |
445
|
|
|
|
|
|
|
|
446
|
4
|
|
|
|
|
49
|
my @run_perl = $dist->_perlrun(); |
|
4
|
|
|
|
|
30
|
|
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
### this will set the directory back to the start |
449
|
|
|
|
|
|
|
### dir, so we must chdir /again/ |
450
|
4
|
|
|
|
|
40
|
my $ok = $dist->_resolve_prereqs( |
451
|
|
|
|
|
|
|
force => $force, |
452
|
|
|
|
|
|
|
format => $prereq_format, |
453
|
|
|
|
|
|
|
verbose => $verbose, |
454
|
|
|
|
|
|
|
prereqs => $self->status->prereqs, |
455
|
|
|
|
|
|
|
target => $prereq_target, |
456
|
|
|
|
|
|
|
prereq_build => $prereq_build, |
457
|
|
|
|
|
|
|
); |
458
|
|
|
|
|
|
|
|
459
|
4
|
|
|
|
|
15051
|
my $metadata = $dist->status->_metadata; |
460
|
4
|
50
|
33
|
|
|
848
|
my $x_use_unsafe_inc = ( defined $metadata && exists $metadata->{x_use_unsafe_inc} ? $metadata->{x_use_unsafe_inc} : undef ); |
461
|
4
|
50
|
|
|
|
25
|
$x_use_unsafe_inc = 1 unless defined $x_use_unsafe_inc; |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
local $ENV{PERL_USE_UNSAFE_INC} = $x_use_unsafe_inc |
464
|
4
|
50
|
|
|
|
41
|
unless exists $ENV{PERL_USE_UNSAFE_INC}; |
465
|
|
|
|
|
|
|
|
466
|
4
|
50
|
|
|
|
21
|
unless( $cb->_chdir( dir => $dir ) ) { |
467
|
0
|
|
|
|
|
0
|
error( loc( "Could not chdir to build directory '%1'", $dir ) ); |
468
|
0
|
|
|
|
|
0
|
return; |
469
|
|
|
|
|
|
|
} |
470
|
|
|
|
|
|
|
|
471
|
4
|
50
|
|
|
|
537
|
unless( $ok ) { |
472
|
|
|
|
|
|
|
#### use $dist->flush to reset the cache ### |
473
|
0
|
|
|
|
|
0
|
error( loc( "Unable to satisfy prerequisites for '%1' " . |
474
|
|
|
|
|
|
|
"-- aborting install", $self->module ) ); |
475
|
0
|
|
|
|
|
0
|
$dist->status->build(0); |
476
|
0
|
|
|
|
|
0
|
$fail++; $prereq_fail++; |
|
0
|
|
|
|
|
0
|
|
477
|
0
|
|
|
|
|
0
|
last RUN; |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
|
480
|
4
|
|
|
|
|
9
|
my ($captured, $cmd); |
481
|
4
|
|
|
|
|
12
|
if ( ON_VMS ) { |
482
|
|
|
|
|
|
|
$cmd = [$perl, BUILD->($dir), @buildflags]; |
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
else { |
485
|
4
|
|
|
|
|
32
|
$cmd = [$perl, @run_perl, BUILD->($dir), @buildflags]; |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
|
488
|
4
|
50
|
|
|
|
35
|
unless ( scalar run( command => $cmd, |
489
|
|
|
|
|
|
|
buffer => \$captured, |
490
|
|
|
|
|
|
|
verbose => $verbose ) |
491
|
|
|
|
|
|
|
) { |
492
|
0
|
|
|
|
|
0
|
error( loc( "MAKE failed:\n%1", $captured ) ); |
493
|
0
|
|
|
|
|
0
|
$dist->status->build(0); |
494
|
0
|
0
|
|
|
|
0
|
if ( $conf->get_conf('cpantest') ) { |
495
|
0
|
|
|
|
|
0
|
$status->{stage} = 'build'; |
496
|
0
|
|
|
|
|
0
|
$status->{capture} = $captured; |
497
|
|
|
|
|
|
|
} |
498
|
0
|
|
|
|
|
0
|
$fail++; last RUN; |
|
0
|
|
|
|
|
0
|
|
499
|
|
|
|
|
|
|
} |
500
|
|
|
|
|
|
|
|
501
|
4
|
|
|
|
|
1178717
|
msg( $captured, 0 ); |
502
|
|
|
|
|
|
|
|
503
|
4
|
|
|
|
|
6229
|
$dist->status->build(1); |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
### add this directory to your lib ### |
506
|
4
|
|
|
|
|
1069
|
$self->add_to_includepath(); |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
### this buffer will not include what tests failed due to a |
509
|
|
|
|
|
|
|
### M::B/Test::Harness bug. Reported as #9793 with patch |
510
|
|
|
|
|
|
|
### against 0.2607 on 26/1/2005 |
511
|
4
|
50
|
|
|
|
3365
|
unless( $skiptest ) { |
512
|
4
|
|
|
|
|
16
|
my $test_output; |
513
|
4
|
|
|
|
|
9
|
if ( ON_VMS ) { |
514
|
|
|
|
|
|
|
$cmd = [$perl, BUILD->($dir), "test", @buildflags]; |
515
|
|
|
|
|
|
|
} |
516
|
|
|
|
|
|
|
else { |
517
|
4
|
|
|
|
|
40
|
$cmd = [$perl, @run_perl, BUILD->($dir), "test", @buildflags]; |
518
|
|
|
|
|
|
|
} |
519
|
4
|
|
|
|
|
35
|
local $ENV{PERL_INSTALL_QUIET}; |
520
|
4
|
50
|
|
|
|
22
|
unless ( scalar run( command => $cmd, |
521
|
|
|
|
|
|
|
buffer => \$test_output, |
522
|
|
|
|
|
|
|
verbose => $verbose ) |
523
|
|
|
|
|
|
|
) { |
524
|
0
|
0
|
|
|
|
0
|
error( loc( "MAKE TEST failed:\n%1 ", $test_output ), ( $verbose ? 0 : 1 ) ); |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
### mark specifically *test* failure.. so we don't |
527
|
|
|
|
|
|
|
### send success on force... |
528
|
0
|
|
|
|
|
0
|
$test_fail++; |
529
|
|
|
|
|
|
|
|
530
|
0
|
0
|
0
|
|
|
0
|
if( !$force and !$cb->_callbacks->proceed_on_test_failure->( |
531
|
|
|
|
|
|
|
$self, $@ ) |
532
|
|
|
|
|
|
|
) { |
533
|
0
|
|
|
|
|
0
|
$dist->status->test(0); |
534
|
0
|
0
|
|
|
|
0
|
if ( $conf->get_conf('cpantest') ) { |
535
|
0
|
|
|
|
|
0
|
$status->{stage} = 'test'; |
536
|
0
|
|
|
|
|
0
|
$status->{capture} = $test_output; |
537
|
|
|
|
|
|
|
} |
538
|
0
|
|
|
|
|
0
|
$fail++; last RUN; |
|
0
|
|
|
|
|
0
|
|
539
|
|
|
|
|
|
|
} |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
} |
542
|
|
|
|
|
|
|
else { |
543
|
4
|
|
|
|
|
2141497
|
msg( loc( "MAKE TEST passed:\n%1", $test_output ), 0 ); |
544
|
4
|
|
|
|
|
6796
|
$dist->status->test(1); |
545
|
4
|
50
|
|
|
|
1202
|
if ( $conf->get_conf('cpantest') ) { |
546
|
0
|
|
|
|
|
0
|
$status->{stage} = 'test'; |
547
|
0
|
|
|
|
|
0
|
$status->{capture} = $test_output; |
548
|
|
|
|
|
|
|
} |
549
|
|
|
|
|
|
|
} |
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
else { |
552
|
0
|
|
|
|
|
0
|
msg(loc("Tests skipped"), $verbose); |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
|
556
|
4
|
50
|
|
|
|
1359
|
unless( $cb->_chdir( dir => $orig ) ) { |
557
|
0
|
|
|
|
|
0
|
error( loc( "Could not chdir back to start dir '%1'", $orig ) ); |
558
|
|
|
|
|
|
|
} |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
### send out test report? ### |
561
|
4
|
50
|
33
|
|
|
705
|
if( $conf->get_conf('cpantest') and not $prereq_fail ) { |
562
|
0
|
0
|
0
|
|
|
0
|
$cb->_send_report( |
563
|
|
|
|
|
|
|
module => $self, |
564
|
|
|
|
|
|
|
failed => $test_fail || $fail, |
565
|
|
|
|
|
|
|
buffer => CPANPLUS::Error->stack_as_string, |
566
|
|
|
|
|
|
|
status => $status, |
567
|
|
|
|
|
|
|
verbose => $verbose, |
568
|
|
|
|
|
|
|
force => $force, |
569
|
|
|
|
|
|
|
tests_skipped => $skiptest, |
570
|
|
|
|
|
|
|
) or error(loc("Failed to send test report for '%1'", |
571
|
|
|
|
|
|
|
$self->module ) ); |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
4
|
50
|
|
|
|
943
|
return $dist->status->created( $fail ? 0 : 1 ); |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
sub install { |
579
|
|
|
|
|
|
|
### just in case you already did a create call for this module object |
580
|
|
|
|
|
|
|
### just via a different dist object |
581
|
2
|
|
|
2
|
1
|
653
|
my $dist = shift; |
582
|
2
|
|
|
|
|
17
|
my $self = $dist->parent; |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
### we're also the cpan_dist, since we don't need to have anything |
585
|
|
|
|
|
|
|
### prepared from another installer |
586
|
2
|
50
|
|
|
|
220
|
$dist = $self->status->dist_cpan if $self->status->dist_cpan; |
587
|
|
|
|
|
|
|
|
588
|
2
|
|
|
|
|
412
|
my $cb = $self->parent; |
589
|
2
|
|
|
|
|
82
|
my $conf = $cb->configure_object; |
590
|
2
|
|
|
|
|
37
|
my %hash = @_; |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
|
593
|
2
|
|
|
|
|
16
|
my $verbose; my $perl; my $force; my $buildflags; |
|
2
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
0
|
|
594
|
2
|
|
|
|
|
5
|
{ local $Params::Check::ALLOW_UNKNOWN = 1; |
|
2
|
|
|
|
|
7
|
|
595
|
2
|
|
|
|
|
17
|
my $tmpl = { |
596
|
|
|
|
|
|
|
verbose => { default => $conf->get_conf('verbose'), |
597
|
|
|
|
|
|
|
store => \$verbose }, |
598
|
|
|
|
|
|
|
force => { default => $conf->get_conf('force'), |
599
|
|
|
|
|
|
|
store => \$force }, |
600
|
|
|
|
|
|
|
buildflags => { default => $conf->get_conf('buildflags'), |
601
|
|
|
|
|
|
|
store => \$buildflags }, |
602
|
|
|
|
|
|
|
perl => { default => $^X, store => \$perl }, |
603
|
|
|
|
|
|
|
}; |
604
|
|
|
|
|
|
|
|
605
|
2
|
50
|
|
|
|
1444
|
my $args = check( $tmpl, \%hash ) or return; |
606
|
2
|
|
|
|
|
340
|
$dist->status->_install_args( $args ); |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
|
609
|
2
|
|
|
|
|
350
|
my $dir; |
610
|
2
|
50
|
|
|
|
11
|
unless( $dir = $self->status->extract ) { |
611
|
0
|
|
|
|
|
0
|
error( loc( "No dir found to operate on!" ) ); |
612
|
0
|
|
|
|
|
0
|
return; |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
|
615
|
2
|
|
|
|
|
6156
|
my $orig = cwd(); |
616
|
|
|
|
|
|
|
|
617
|
2
|
50
|
|
|
|
44
|
unless( $cb->_chdir( dir => $dir ) ) { |
618
|
0
|
|
|
|
|
0
|
error( loc( "Could not chdir to build directory '%1'", $dir ) ); |
619
|
0
|
|
|
|
|
0
|
return; |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
### value set and false -- means failure ### |
623
|
2
|
0
|
33
|
|
|
452
|
if( defined $self->status->installed && |
|
|
|
33
|
|
|
|
|
624
|
|
|
|
|
|
|
!$self->status->installed && !$force |
625
|
|
|
|
|
|
|
) { |
626
|
0
|
|
|
|
|
0
|
error( loc( "Module '%1' has failed to install before this session " . |
627
|
|
|
|
|
|
|
"-- aborting install", $self->module ) ); |
628
|
0
|
|
|
|
|
0
|
return; |
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
|
631
|
2
|
|
|
|
|
286
|
my $fail; |
632
|
2
|
|
|
|
|
16
|
my @buildflags = $dist->_buildflags_as_list( $buildflags ); |
633
|
2
|
|
|
|
|
316
|
my @run_perl = $dist->_perlrun(); |
634
|
|
|
|
|
|
|
|
635
|
2
|
|
|
|
|
18
|
my $metadata = $dist->status->_metadata; |
636
|
2
|
50
|
33
|
|
|
372
|
my $x_use_unsafe_inc = ( defined $metadata && exists $metadata->{x_use_unsafe_inc} ? $metadata->{x_use_unsafe_inc} : undef ); |
637
|
2
|
50
|
|
|
|
15
|
$x_use_unsafe_inc = 1 unless defined $x_use_unsafe_inc; |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
local $ENV{PERL_USE_UNSAFE_INC} = $x_use_unsafe_inc |
640
|
2
|
50
|
|
|
|
22
|
unless exists $ENV{PERL_USE_UNSAFE_INC}; |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
### hmm, how is this going to deal with sudo? |
643
|
|
|
|
|
|
|
### for now, check effective uid, if it's not root, |
644
|
|
|
|
|
|
|
### shell out, otherwise use the method |
645
|
2
|
50
|
|
|
|
15
|
if( $> ) { |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
### don't worry about loading the right version of M::B anymore |
648
|
|
|
|
|
|
|
### the 'new_from_context' already added the 'right' path to |
649
|
|
|
|
|
|
|
### M::B at the top of the build.pl |
650
|
0
|
|
|
|
|
0
|
my $cmd; |
651
|
0
|
|
|
|
|
0
|
if ( ON_VMS ) { |
652
|
|
|
|
|
|
|
$cmd = [$perl, BUILD->($dir), "install", @buildflags]; |
653
|
|
|
|
|
|
|
} |
654
|
|
|
|
|
|
|
else { |
655
|
0
|
|
|
|
|
0
|
$cmd = [$perl, @run_perl, BUILD->($dir), "install", @buildflags]; |
656
|
|
|
|
|
|
|
} |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
### Detect local::lib type behaviour. Do not use 'sudo' in these cases |
659
|
0
|
|
|
|
|
0
|
my $sudo = $conf->get_program('sudo'); |
660
|
|
|
|
|
|
|
SUDO: { |
661
|
|
|
|
|
|
|
### Actual local::lib in use |
662
|
0
|
0
|
0
|
|
|
0
|
last SUDO if defined $ENV{PERL_MB_OPT} and $ENV{PERL_MB_OPT} =~ m!install_base!; |
|
0
|
|
|
|
|
0
|
|
663
|
|
|
|
|
|
|
### 'buildflags' is configured with '--install_base' |
664
|
0
|
0
|
|
|
|
0
|
last SUDO if scalar grep { m!install_base! } @buildflags; |
|
0
|
|
|
|
|
0
|
|
665
|
|
|
|
|
|
|
### oh well 'sudo make me a sandwich' |
666
|
0
|
|
|
|
|
0
|
unshift @$cmd, $sudo; |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
|
669
|
0
|
|
|
|
|
0
|
my $buffer; |
670
|
0
|
0
|
|
|
|
0
|
unless( scalar run( command => $cmd, |
671
|
|
|
|
|
|
|
buffer => \$buffer, |
672
|
|
|
|
|
|
|
verbose => $verbose ) |
673
|
|
|
|
|
|
|
) { |
674
|
0
|
|
|
|
|
0
|
error(loc("Could not run '%1': %2", 'Build install', $buffer)); |
675
|
0
|
|
|
|
|
0
|
$fail++; |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
} else { |
678
|
2
|
|
|
|
|
7
|
my ($install_output, $cmd); |
679
|
2
|
|
|
|
|
4
|
if ( ON_VMS ) { |
680
|
|
|
|
|
|
|
$cmd = [$perl, BUILD->($dir), "install", @buildflags]; |
681
|
|
|
|
|
|
|
} |
682
|
|
|
|
|
|
|
else { |
683
|
2
|
|
|
|
|
17
|
$cmd = [$perl, @run_perl, BUILD->($dir), "install", @buildflags]; |
684
|
|
|
|
|
|
|
} |
685
|
2
|
50
|
|
|
|
19
|
unless( scalar run( command => $cmd, |
686
|
|
|
|
|
|
|
buffer => \$install_output, |
687
|
|
|
|
|
|
|
verbose => $verbose ) |
688
|
|
|
|
|
|
|
) { |
689
|
0
|
|
|
|
|
0
|
error(loc("Could not run '%1': %2", 'Build install', $install_output)); |
690
|
0
|
|
|
|
|
0
|
$fail++; |
691
|
|
|
|
|
|
|
} |
692
|
|
|
|
|
|
|
else { |
693
|
2
|
|
|
|
|
540627
|
msg( $install_output, 0 ); |
694
|
|
|
|
|
|
|
} |
695
|
|
|
|
|
|
|
} |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
|
698
|
2
|
50
|
|
|
|
2756
|
unless( $cb->_chdir( dir => $orig ) ) { |
699
|
0
|
|
|
|
|
0
|
error( loc( "Could not chdir back to start dir '%1'", $orig ) ); |
700
|
|
|
|
|
|
|
} |
701
|
|
|
|
|
|
|
|
702
|
2
|
50
|
|
|
|
357
|
return $dist->status->installed( $fail ? 0 : 1 ); |
703
|
|
|
|
|
|
|
} |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
### returns the string 'foo=bar --zot quux' |
706
|
|
|
|
|
|
|
### as the list 'foo=bar', '--zot', 'qux' |
707
|
|
|
|
|
|
|
sub _buildflags_as_list { |
708
|
12
|
|
|
12
|
|
48
|
my $self = shift; |
709
|
12
|
50
|
|
|
|
79
|
my $flags = shift or return; |
710
|
|
|
|
|
|
|
|
711
|
12
|
|
|
|
|
206
|
return Module::Build->split_like_shell($flags); |
712
|
|
|
|
|
|
|
} |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
{ |
715
|
|
|
|
|
|
|
my $afe_ver = version->new($CPANPLUS::Internals::VERSION) >= version->new("0.9166"); |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
sub _perlrun { |
718
|
12
|
|
|
12
|
|
41
|
my $self = shift; |
719
|
12
|
50
|
|
|
|
66
|
if ( $afe_ver ) { |
720
|
12
|
|
|
|
|
69
|
return ( '-MCPANPLUS::Internals::Utils::Autoflush' ); |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
else { |
723
|
0
|
|
|
|
|
|
return ( '-e', CPDB_PERL_WRAPPER ); |
724
|
|
|
|
|
|
|
} |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
} |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
qq[Putting the Module::Build into CPANPLUS]; |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
# Local variables: |
733
|
|
|
|
|
|
|
# c-indentation-style: bsd |
734
|
|
|
|
|
|
|
# c-basic-offset: 4 |
735
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
736
|
|
|
|
|
|
|
# End: |
737
|
|
|
|
|
|
|
# vim: expandtab shiftwidth=4: |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
__END__ |