lib/CPANPLUS/Config.pm

filter: Statementstmt 84.5% 131 / 155 Branchbran 35.4% 17 / 48 Conditioncond 20.3% 12 / 59 MC/DCmcdc 0.0% 0 / 31 Subroutinesub 100% 19 / 19 Podpod 100% 1 / 1 totaltotal 57.5% 180 / 313 SCAR 39.9
CC
23
Cov
61%
__ANON__
90.0
_clean_up_paths
25.1
new
3.0
CRAP 54.2
« blib/lib/CPANPLUS/Internals/Source/SQLite.pm ↑ Summary lib/CPANPLUS/Module/Checksums.pm »
1 package CPANPLUS::Config;
2  
3 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 20 ▶use base 'Object::Accessor';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 ▶use base 'CPANPLUS::Internals::Utils';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 20 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 20 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 20 ▶use Module::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 20 ▶use CPANPLUS;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 20 ▶use CPANPLUS::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 20 ▶use CPANPLUS::Internals::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 20 ▶use File::Basename qw[dirname];
Subroutine BEGIN: called CC=1 SCAR=0.0
17 20 ▶use IPC::Cmd qw[can_run];
Subroutine BEGIN: called CC=1 SCAR=0.0
18 20 ▶use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 20 ▶use Module::Load::Conditional qw[check_install];
Subroutine BEGIN: called CC=1 SCAR=0.0
20 20 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 20 ▶use vars qw[$VERSION];
Subroutine BEGIN: called CC=1 SCAR=0.0
23 20 $VERSION = "0.9912";
24  
25 =pod
26  
27 =head1 NAME
28  
29 CPANPLUS::Config - configuration defaults and heuristics for CPANPLUS
30  
31 =head1 SYNOPSIS
32  
33 ### conf object via CPANPLUS::Backend;
34 $cb = CPANPLUS::Backend->new;
35 $conf = $cb->configure_object;
36  
37 ### or as a standalone object
38 $conf = CPANPLUS::Configure->new;
39  
40 ### values in 'conf' section
41 $verbose = $conf->get_conf( 'verbose' );
42 $conf->set_conf( verbose => 1 );
43  
44 ### values in 'program' section
45 $editor = $conf->get_program( 'editor' );
46 $conf->set_program( editor => '/bin/vi' );
47  
48 =head1 DESCRIPTION
49  
50 This module contains defaults and heuristics for configuration
51 information for CPANPLUS. To change any of these values, please
52 see the documentation in C<CPANPLUS::Configure>.
53  
54 Below you'll find a list of configuration types and keys, and
55 their meaning.
56  
57 =head1 CONFIGURATION
58  
59 =cut
60  
61 ### BAH! you can't have POD interleaved with a hash
62 ### declaration.. so declare every entry separately :(
63 20 my $Conf = {
64 '_fetch' => {
65 'blacklist' => [ 'ftp' ],
66 },
67  
68 ### _source, _build and _mirror are supposed to be static
69 ### no changes should be needed unless pause/cpan changes
70 '_source' => {
71 'hosts' => 'MIRRORED.BY',
72 'auth' => '01mailrc.txt.gz',
73 'stored' => 'sourcefiles',
74 'dslip' => '03modlist.data.gz',
75 'update' => '86400',
76 'mod' => '02packages.details.txt.gz',
77 'custom_index' => 'packages.txt',
78 },
79 '_build' => {
80 'plugins' => 'plugins',
81 'moddir' => 'build',
82 'startdir' => '',
83 'distdir' => 'dist',
84 'autobundle' => 'autobundle',
85 'autobundle_prefix' => 'Snapshot',
86 'autdir' => 'authors',
87 'install_log_dir' => 'install-logs',
88 'custom_sources' => 'custom-sources',
89 'sanity_check' => 1,
90 },
91 '_mirror' => {
92 'base' => 'authors/id/',
93 'auth' => 'authors/01mailrc.txt.gz',
94 'dslip' => 'modules/03modlist.data.gz',
95 'mod' => 'modules/02packages.details.txt.gz'
96 },
97 };
98  
99 =head2 Section 'conf'
100  
101 =over 4
102  
103 =item hosts
104  
105 An array ref containing hosts entries to be queried for packages.
106  
107 An example entry would like this:
108  
109 { 'scheme' => 'ftp',
110 'path' => '/pub/CPAN/',
111 'host' => 'ftp.cpan.org'
112 },
113  
114 =cut
115  
116 ### default host list
117 20 $Conf->{'conf'}->{'hosts'} = [
118 {
119 'scheme' => 'http',
120 'path' => '/',
121 'host' => 'www.cpan.org'
122 },
123 ];
124  
125 =item allow_build_interactivity
126  
127 Boolean flag to indicate whether 'perl Makefile.PL' and similar
128 are run interactively or not. Defaults to 'true'.
129  
130 =cut
131  
132 20 $Conf->{'conf'}->{'allow_build_interactivity'} = 1;
133  
134 =item allow_unknown_prereqs
135  
136 Boolean flag to indicate that unresolvable prereqs are acceptable.
137 If C<true> then only warnings will be issued (the behaviour before 0.9114)
138 when a module is unresolvable from any our sources (CPAN and/or
139 C<custom_sources>). If C<false> then an unresolvable prereq will fail
140 during the C<prepare> stage of distribution installation.
141 Defaults to C<true>.
142  
143 =cut
144  
145 20 $Conf->{'conf'}->{'allow_unknown_prereqs'} = 1;
146  
147 =item base
148  
149 The directory CPANPLUS keeps all its build and state information in.
150 Defaults to ~/.cpanplus. If L<File::HomeDir> is available, that will
151 be used to work out your C<HOME> directory. This may be overridden by
152 setting the C<PERL5_CPANPLUS_HOME> environment variable, see
153 L<CPANPLUS::Config::HomeEnv> for more details.
154  
155 =cut
156  
157 20 $Conf->{'conf'}->{'base'} = File::Spec->catdir(
158 __PACKAGE__->_home_dir, DOT_CPANPLUS );
159  
160 =item buildflags
161  
162 Any flags to be passed to 'perl Build.PL'. See C<perldoc Module::Build>
163 for details. Defaults to an empty string.
164  
165 =cut
166  
167 20 $Conf->{'conf'}->{'buildflags'} = '';
168  
169 =item cpantest
170  
171 Boolean flag to indicate whether or not to mail test results of module
172 installations to C<http://testers.cpan.org>. Defaults to 'false'.
173  
174 =cut
175  
176 20 $Conf->{'conf'}->{'cpantest'} = 0;
177  
178 =item cpantest_mx
179  
180 String holding an explicit mailserver to use when sending out emails
181 for C<http://testers.cpan.org>. An empty string will use your system
182 settings. Defaults to an empty string.
183  
184 =cut
185  
186 20 $Conf->{'conf'}->{'cpantest_mx'} = '';
187  
188 =item debug
189  
190 Boolean flag to enable or disable extensive debugging information.
191 Defaults to 'false'.
192  
193 =cut
194  
195 20 $Conf->{'conf'}->{'debug'} = 0;
196  
197 =item dist_type
198  
199 Default distribution type to use when building packages. See C<cpan2dist>
200 or C<CPANPLUS::Dist> for details. An empty string will not use any
201 package building software. Defaults to an empty string.
202  
203 =cut
204  
205 20 $Conf->{'conf'}->{'dist_type'} = '';
206  
207 =item email
208  
209 Email address to use for anonymous ftp access and as C<from> address
210 when sending emails. Defaults to an C<example.com> address.
211  
212 =cut
213  
214 20 $Conf->{'conf'}->{'email'} = DEFAULT_EMAIL;
215  
216 =item enable_custom_sources
217  
218 Boolean flag indicating whether custom sources should be enabled or
219 not. See the C<CUSTOM MODULE SOURCES> in C<CPANPLUS::Backend> for
220 details on how to use them.
221  
222 Defaults to C<true>
223  
224 =cut
225  
226 ### this addresses #32248 which requests a possibility to
227 ### turn off custom sources
228 20 $Conf->{'conf'}->{'enable_custom_sources'} = 1;
229  
230 =item extractdir
231  
232 String containing the directory where fetched archives should be
233 extracted. An empty string will use a directory under your C<base>
234 directory. Defaults to an empty string.
235  
236 =cut
237  
238 20 $Conf->{'conf'}->{'extractdir'} = '';
239  
240 =item fetchdir
241  
242 String containing the directory where fetched archives should be
243 stored. An empty string will use a directory under your C<base>
244 directory. Defaults to an empty string.
245  
246 =cut
247  
248 20 $Conf->{'conf'}->{'fetchdir'} = '';
249  
250 =item flush
251  
252 Boolean indicating whether build failures, cache dirs etc should
253 be flushed after every operation or not. Defaults to 'true'.
254  
255 =cut
256  
257 20 $Conf->{'conf'}->{'flush'} = 1;
258  
259 =item force
260  
261 Boolean indicating whether files should be forcefully overwritten
262 if they exist, modules should be installed when they fail tests,
263 etc. Defaults to 'false'.
264  
265 =cut
266  
267 20 $Conf->{'conf'}->{'force'} = 0;
268  
269 =item histfile
270  
271 A string containing the history filename of the CPANPLUS readline instance.
272  
273 =cut
274  
275 20 $Conf->{'conf'}->{'histfile'} = File::Spec->catdir(
276 __PACKAGE__->_home_dir, DOT_CPANPLUS, 'history' );
277  
278 =item lib
279  
280 An array ref holding directories to be added to C<@INC> when CPANPLUS
281 starts up. Defaults to an empty array reference.
282  
283 =cut
284  
285 20 $Conf->{'conf'}->{'lib'} = [];
286  
287 =item makeflags
288  
289 A string holding flags that will be passed to the C<make> program
290 when invoked. Defaults to an empty string.
291  
292 =cut
293  
294 20 $Conf->{'conf'}->{'makeflags'} = '';
295  
296 =item makemakerflags
297  
298 A string holding flags that will be passed to C<perl Makefile.PL>
299 when invoked. Defaults to an empty string.
300  
301 =cut
302  
303 20 $Conf->{'conf'}->{'makemakerflags'} = '';
304  
305 =item md5
306  
307 A boolean indicating whether or not sha256 checks should be done when
308 an archive is fetched. Defaults to 'true' if you have C<Digest::SHA>
309 installed, 'false' otherwise.
310  
311 =cut
312  
313 20 ▶ $Conf->{'conf'}->{'md5'} = (
Branch: 1 branch
BranchTrueFalseTotal
check_install('module', 'Digest::SHA') ? : 20 0 20
314 check_install( module => 'Digest::SHA' ) ? 1 : 0 );
315  
316 =item no_update
317  
318 A boolean indicating whether or not C<CPANPLUS>' source files should be
319 updated or not. Defaults to 'false'.
320  
321 =cut
322  
323 20 $Conf->{'conf'}->{'no_update'} = 0;
324  
325 =item passive
326  
327 A boolean indicating whether or not to use passive ftp connections.
328 Defaults to 'true'.
329  
330 =cut
331  
332 20 $Conf->{'conf'}->{'passive'} = 1;
333  
334 =item prefer_bin
335  
336 A boolean indicating whether or not to prefer command line programs
337 over perl modules. Defaults to 'false' unless you do not have
338 C<Compress::Zlib> installed (as that would mean we could not extract
339 C<.tar.gz> files)
340  
341 =cut
342  
343 ### if we don't have c::zlib, we'll need to use /bin/tar or we
344 ### can not extract any files. Good time to change the default
345 $Conf->{'conf'}->{'prefer_bin'} =
346 20 ▶ (eval {require Compress::Zlib; 1} ? 0 : 1 );
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Compress::Zlib; 1 } } ? : 20 0 20
347  
348 =item prefer_makefile
349  
350 A boolean indicating whether or not prefer a C<Makefile.PL> over a
351 C<Build.PL> file if both are present. Defaults to 'true', unless
352 the perl version is at least 5.10.1 or appropriate versions of L<Module::Build>
353 and L<CPANPLUS::Dist::Build> are available.
354  
355 =cut
356  
357 20 ▶ $Conf->{'conf'}->{'prefer_makefile'} =
Branch: 1 branch
BranchTrueFalseTotal
check_install('module', 'Module::Build', 'version', '0.32') && check_install('module', 'CPANPLUS::Dist::Build', 'version', '0.60') ? : 0 0 0
Condition16%1/6
$] >= 5.010001 || (check_install('module', 'Module::Build', 'version', '0.32') && check_install('module', 'CPANPLUS::Dist::Build', 'version', '0.60') ? 0 : 1)
l!l&&r!l&&!r
2000
check_install("module", "Module::Build", "version", "0.32") and check_install("module", "CPANPLUS::Dist::Build", "version", "0.60")
!ll&&!rl&&r
000
MC/DC0%0/3
$] >= 5.010001 || (check_install('module', 'Module::Build', 'version', '0.32') && check_install('module', 'CPANPLUS::Dist::Build', 'version', '0.60') ? 0 : 1)
$] >= 5.010001 check_install("module", "Module::Build", "version", "0.32") check_install("module", "CPANPLUS::Dist::Build", "version", "0.60")
Truth table0%0/4
A || B and C
A= $] >= 5.010001B= check_install("module", "Module::Build", "version", "0.32")C= check_install("module", "CPANPLUS::Dist::Build", "version", "0.60")
ABCresult
1XX1
0111
00X0
0100
358 ( $] >= 5.010001 or
359 ( check_install( module => 'Module::Build', version => '0.32' ) and
360 check_install( module => INSTALLER_BUILD, version => '0.60' ) )
361 ? 0 : 1 );
362  
363 =item prereqs
364  
365 A digit indicating what to do when a package you are installing has a
366 prerequisite. Options are:
367  
368 0 Do not install
369 1 Install
370 2 Ask
371 3 Ignore (dangerous, install will probably fail!)
372  
373 The default is to ask.
374  
375 =cut
376  
377 20 $Conf->{'conf'}->{'prereqs'} = PREREQ_ASK;
378  
379 =item shell
380  
381 A string holding the shell class you wish to start up when starting
382 C<CPANPLUS> in interactive mode.
383  
384 Defaults to C<CPANPLUS::Shell::Default>, the default CPANPLUS shell.
385  
386 =cut
387  
388 20 $Conf->{'conf'}->{'shell'} = 'CPANPLUS::Shell::Default';
389  
390 =item show_startup_tip
391  
392 A boolean indicating whether or not to show start up tips in the
393 interactive shell. Defaults to 'true'.
394  
395 =cut
396  
397 20 $Conf->{'conf'}->{'show_startup_tip'} = 1;
398  
399 =item signature
400  
401 A boolean indicating whether or not check signatures if packages are
402 signed. Defaults to 'true' if you have C<gpg> or C<Crypt::OpenPGP>
403 installed, 'false' otherwise.
404  
405 =cut
406  
407 20 ▶ $Conf->{'conf'}->{'signature'} = do {
Branch: 1 branch
BranchTrueFalseTotal
do { check_install('module', 'Module::Signature', 'version', '0.06') and can_run('gpg') || check_install('module', 'Crypt::OpenPGP') } ? : 0 20 20
408 20 ▶ check_install( module => 'Module::Signature', version => '0.06' )
Branch: 1 branch
BranchTrueFalseTotal
check_install("module", "Module::Signature", "version", "0.06") and can_run("gpg") || check_install("module", "Crypt::OpenPGP") 0 20 20
Condition16%1/6
check_install('module', 'Module::Signature', 'version', '0.06') && (can_run('gpg') || check_install('module', 'Crypt::OpenPGP'))
!ll&&!rl&&r
2000
can_run("gpg") or check_install("module", "Crypt::OpenPGP")
l!l&&r!l&&!r
000
MC/DC0%0/3
check_install('module', 'Module::Signature', 'version', '0.06') && (can_run('gpg') || check_install('module', 'Crypt::OpenPGP'))
check_install('module', 'Module::Signature', 'version', '0.06') can_run("gpg") check_install("module", "Crypt::OpenPGP")
Truth table0%0/4
A && B or C
A= check_install('module', 'Module::Signature', 'version', '0.06')B= can_run("gpg")C= check_install("module", "Crypt::OpenPGP")
ABCresult
0XX0
1000
11X1
1011
409 and ( can_run('gpg') ||
410 check_install(module => 'Crypt::OpenPGP')
411 );
412 } ? 1 : 0;
413  
414 =item skiptest
415  
416 A boolean indicating whether or not to skip tests when installing modules.
417 Defaults to 'false'.
418  
419 =cut
420  
421 20 $Conf->{'conf'}->{'skiptest'} = 0;
422  
423 =item storable
424  
425 A boolean indicating whether or not to use C<Storable> to write compiled
426 source file information to disk. This makes for faster startup and look
427 up times, but takes extra diskspace. Defaults to 'true' if you have
428 C<Storable> installed and 'false' if you don't.
429  
430 =cut
431  
432 20 ▶ $Conf->{'conf'}->{'storable'} =
Branch: 1 branch
BranchTrueFalseTotal
check_install('module', 'Storable') ? : 20 0 20
433 ( check_install( module => 'Storable' ) ? 1 : 0 );
434  
435 =item timeout
436  
437 Digit indicating the time before a fetch request times out (in seconds).
438 Defaults to 300.
439  
440 =cut
441  
442 20 $Conf->{'conf'}->{'timeout'} = 300;
443  
444 =item verbose
445  
446 A boolean indicating whether or not C<CPANPLUS> runs in verbose mode.
447 Defaults to 'true' if you have the environment variable
448 C<PERL5_CPANPLUS_VERBOSE> set to true, 'false' otherwise.
449  
450 It is recommended you run with verbose enabled, but it is disabled
451 for historical reasons.
452  
453 =cut
454  
455 20 ▶ $Conf->{'conf'}->{'verbose'} = $ENV{PERL5_CPANPLUS_VERBOSE} || 0;
Condition50%1/2
$ENV{'PERL5_CPANPLUS_VERBOSE'} || 0
l!l
020
MC/DC0%0/1
$ENV{'PERL5_CPANPLUS_VERBOSE'} || 0
$ENV{'PERL5_CPANPLUS_VERBOSE'}
Truth table50%1/2
A
A= $ENV{'PERL5_CPANPLUS_VERBOSE'}
Aresult
11
00
456  
457 =item write_install_log
458  
459 A boolean indicating whether or not to write install logs after installing
460 a module using the interactive shell. Defaults to 'true'.
461  
462  
463 =cut
464  
465 20 $Conf->{'conf'}->{'write_install_logs'} = 1;
466  
467 =item source_engine
468  
469 Class to use as the source engine, which is generally a subclass of
470 C<CPANPLUS::Internals::Source>. Default to C<CPANPLUS::Internals::Source::Memory>.
471  
472 =cut
473  
474 20 $Conf->{'conf'}->{'source_engine'} = DEFAULT_SOURCE_ENGINE;
475  
476 =item cpantest_reporter_args
477  
478 A hashref of key => value pairs that are passed to the constructor
479 of C<Test::Reporter>. If you'd want to enable TLS for example, you'd
480 set it to:
481  
482 { transport => 'Net::SMTP::TLS',
483 transport_args => [ User => 'Joe', Password => '123' ],
484 }
485  
486 =cut
487  
488 20 $Conf->{'conf'}->{'cpantest_reporter_args'} = {};
489  
490 =back
491  
492 =head2 Section 'program'
493  
494 =cut
495  
496 ### Paths get stripped of whitespace on win32 in the constructor
497 ### sudo gets emptied if there's no need for it in the constructor
498  
499 =over 4
500  
501 =item editor
502  
503 A string holding the path to your editor of choice. Defaults to your
504 $ENV{EDITOR}, $ENV{VISUAL}, 'vi' or 'pico' programs, in that order.
505  
506 =cut
507  
508 20 $Conf->{'program'}->{'editor'} = do {
509 20 ▶ $ENV{'EDITOR'} || $ENV{'VISUAL'} ||
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"EDITOR"} or $ENV{"VISUAL"} or can_run("vi") or can_run("pico") 20 0 20
Condition33%2/6
$ENV{"EDITOR"} or $ENV{"VISUAL"} or can_run("vi")
l!l&&r!l&&!r
0020
$ENV{"EDITOR"} or $ENV{"VISUAL"}
l!l&&r!l&&!r
0020
MC/DC0%0/3
$ENV{"EDITOR"} or $ENV{"VISUAL"} or can_run("vi")
$ENV{"EDITOR"} $ENV{"VISUAL"} can_run("vi")
Truth table0%0/4
A or B or C
A= $ENV{"EDITOR"}B= $ENV{"VISUAL"}C= can_run("vi")
ABCresult
1XX1
01X1
0011
0000
510 can_run('vi') || can_run('pico')
511 };
512  
513 =item make
514  
515 A string holding the path to your C<make> binary. Looks for the C<make>
516 program used to build perl or failing that, a C<make> in your path.
517  
518 =cut
519  
520 $Conf->{'program'}->{'make'} =
521 20 ▶ can_run($Config{'make'}) || can_run('make');
Condition33%1/3
can_run($CPANPLUS::Config::Config{'make'}) || can_run('make')
l!l&&r!l&&!r
2000
MC/DC0%0/2
can_run($CPANPLUS::Config::Config{'make'}) || can_run('make')
can_run($CPANPLUS::Config::Config{'make'}) can_run('make')
Truth table33%1/3
A || B
A= can_run($CPANPLUS::Config::Config{'make'})B= can_run('make')
ABresult
1X1
011
000
522  
523 =item pager
524  
525 A string holding the path to your pager of choice. Defaults to your
526 $ENV{PAGER}, 'less' or 'more' programs, in that order.
527  
528 =cut
529  
530 $Conf->{'program'}->{'pager'} =
531 20 ▶ $ENV{'PAGER'} || can_run('less') || can_run('more');
Condition33%2/6
$ENV{'PAGER'} || can_run('less') || can_run('more')
l!l&&r!l&&!r
0200
$ENV{"PAGER"} or can_run("less")
l!l&&r!l&&!r
0020
MC/DC0%0/3
$ENV{'PAGER'} || can_run('less') || can_run('more')
$ENV{"PAGER"} can_run("less") can_run('more')
Truth table0%0/4
A or B || C
A= $ENV{"PAGER"}B= can_run("less")C= can_run('more')
ABCresult
1XX1
01X1
0011
0000
532  
533 ### no one uses this feature anyway, and it's only working for EU::MM
534 ### and not for module::build
535 #'perl' => '',
536  
537 =item shell
538  
539 A string holding the path to your login shell of choice. Defaults to your
540 $ENV{SHELL} setting, or $ENV{COMSPEC} on Windows.
541  
542 =cut
543  
544 $Conf->{'program'}->{'shell'} = $^O eq 'MSWin32'
545 ? $ENV{COMSPEC}
546 20 ▶ : $ENV{SHELL};
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 20 20
547  
548 =item sudo
549  
550 A string holding the path to your C<sudo> binary if your install path
551 requires super user permissions. Looks for C<sudo> in your path, or
552 remains empty if you do not require super user permissions to install.
553  
554 =cut
555  
556 20 $Conf->{'program'}->{'sudo'} = do {
557 ### let's assume you don't need sudo,
558 ### unless one of the below criteria tells us otherwise
559 20 my $sudo = undef;
560  
561 ### you're a normal user, you might need sudo
562 20 ▶ if( $> ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($>) 20 0 20
563  
564 ### check for all install dirs!
565 ### you have write permissions to the installdir,
566 ### you don't need sudo
567 20 ▶ if( -w $Config{'installsitelib'} && -w $Config{'installsitebin'} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (-w $CPANPLUS::Config::Config{'installsitelib'} and -w $CPANPLUS::Config::Config{'installsitebin'}) { } 20 0 20
elsif ($ENV{'PERL_MM_OPT'} and $ENV{'PERL_MM_OPT'} =~ /INSTALL|LIB|PREFIX/) { } 0 0 0
Condition33%1/3
-w $CPANPLUS::Config::Config{"installsitelib"} and -w $CPANPLUS::Config::Config{"installsitebin"}
!ll&&!rl&&r
0020
MC/DC0%0/2
-w $CPANPLUS::Config::Config{"installsitelib"} and -w $CPANPLUS::Config::Config{"installsitebin"}
-w $CPANPLUS::Config::Config{"installsitelib"} -w $CPANPLUS::Config::Config{"installsitebin"}
Truth table33%1/3
A and B
A= -w $CPANPLUS::Config::Config{"installsitelib"}B= -w $CPANPLUS::Config::Config{"installsitebin"}
ABresult
0X0
100
111
568  
569 ### installsiteman3dir is a 5.8'ism.. don't check
570 ### it on 5.6.x...
571 20 ▶ if( defined $Config{'installsiteman3dir'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $CPANPLUS::Config::Config{'installsiteman3dir'}) { } 20 0 20
572 20 ▶ $sudo = -w $Config{'installsiteman3dir'}
Branch: 1 branch
BranchTrueFalseTotal
-w $CPANPLUS::Config::Config{'installsiteman3dir'} ? : 0 20 20
573 ? undef
574 : can_run('sudo');
575 } else {
576 0 $sudo = undef;
577 }
578  
579 ### you have PERL_MM_OPT set to some alternate
580 ### install place. You probably have write permissions
581 ### to that
582 ▶ } elsif ( $ENV{'PERL_MM_OPT'} and
Condition0%0/3
$ENV{"PERL_MM_OPT"} and $ENV{"PERL_MM_OPT"} =~ /INSTALL|LIB|PREFIX/
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"PERL_MM_OPT"} and $ENV{"PERL_MM_OPT"} =~ /INSTALL|LIB|PREFIX/
$ENV{"PERL_MM_OPT"} $ENV{"PERL_MM_OPT"} =~ /INSTALL|LIB|PREFIX/
Truth table0%0/3
A and B
A= $ENV{"PERL_MM_OPT"}B= $ENV{"PERL_MM_OPT"} =~ /INSTALL|LIB|PREFIX/
ABresult
0X0
100
111
583 $ENV{'PERL_MM_OPT'} =~ /INSTALL|LIB|PREFIX/
584 ) {
585 0 $sudo = undef;
586  
587 ### you probably don't have write permissions
588 } else {
589 0 $sudo = can_run('sudo');
590 }
591 }
592  
593 ### and return the value
594 20 $sudo;
595 };
596  
597 =item perlwrapper
598  
599 B<DEPRECATED>
600  
601 A string holding the path to the C<cpanp-run-perl> utility bundled
602 with CPANPLUS, which is used to enable autoflushing in spawned processes.
603  
604 =cut
605  
606 ### perlwrapper that allows us to turn on autoflushing
607 $Conf->{'program'}->{'perlwrapper'} = sub {
608 20 ▶ my $name = 'cpanp-run-perl';
Subroutine __ANON__: called CC=16 SCAR=45.0
609  
610 20 my @bins = do{
611 20 require Config;
612 20 my $ver = $Config::Config{version};
613  
614 ### if we are running with 'versiononly' enabled,
615 ### all binaries will have the perlversion appended
616 ### ie, cpanp will become cpanp5.9.5
617 ### so prefer the versioned binary in that case
618 $Config::Config{versiononly}
619 20 ▶ ? ($name.$ver, $name)
Branch: 1 branch
BranchTrueFalseTotal
$Config::Config{'versiononly'} ? : 0 20 20
620 : ($name, $name.$ver);
621 };
622  
623 ### patch from Steve Hay Fri 29 Jun 2007 14:26:02 GMT+02:00
624 ### Msg-Id: <4684FA5A.7030506@uk.radan.com>
625 ### look for files with a ".bat" extension as well on Win32
626 20 ▶ @bins = map { $_, "$_.bat" } @bins if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 20 20
627  
628 20 my $path;
629 20 BIN: for my $bin (@bins) {
630  
631 ### parallel to your cpanp/cpanp-boxed
632 20 my $maybe = File::Spec->rel2abs(
633 File::Spec->catfile( dirname($0), $bin )
634 );
635 20 ▶ $path = $maybe and last BIN if -f $maybe;
Branch: 1 branch
BranchTrueFalseTotal
if -f $maybe 0 20 20
Condition25%1/4
-f $maybe && (($path = $maybe) && (last BIN))
!ll
200
$path = $maybe and last BIN
!ll
00
MC/DC0%0/2
-f $maybe && (($path = $maybe) && (last BIN))
-f $maybe $path = $maybe
Truth table33%1/3
A && B
A= -f $maybeB= $path = $maybe
ABresult
0X0
100
111
636  
637 ### parallel to your CPANPLUS.pm:
638 ### $INC{cpanplus}/../bin/cpanp-run-perl
639 $maybe = File::Spec->rel2abs(
640 File::Spec->catfile(
641 20 dirname($INC{'CPANPLUS.pm'}),
642 '..', # lib dir
643 'bin', # bin dir
644 $bin, # script
645 )
646 );
647 20 ▶ $path = $maybe and last BIN if -f $maybe;
Branch: 1 branch
BranchTrueFalseTotal
if -f $maybe 20 0 20
Condition50%2/4
-f $maybe && (($path = $maybe) && (last BIN))
!ll
020
$path = $maybe and last BIN
!ll
020
MC/DC0%0/2
-f $maybe && (($path = $maybe) && (last BIN))
-f $maybe $path = $maybe
Truth table0%0/3
A && B
A= -f $maybeB= $path = $maybe
ABresult
0X0
100
111
648  
649 ### you installed CPANPLUS in a custom prefix,
650 ### so go parallel to /that/. PREFIX=/tmp/cp
651 ### would put cpanp-run-perl in /tmp/cp/bin and
652 ### CPANPLUS.pm in
653 ### /tmp/cp/lib/perl5/site_perl/5.8.8
654 $maybe = File::Spec->rel2abs(
655 File::Spec->catfile(
656 0 dirname( $INC{'CPANPLUS.pm'} ),
657 '..', '..', '..', '..', # 4x updir
658 'bin', # bin dir
659 $bin, # script
660 )
661 );
662 0 ▶ $path = $maybe and last BIN if -f $maybe;
Branch: 1 branch
BranchTrueFalseTotal
if -f $maybe 0 0 0
Condition0%0/5
-f $maybe && (($path = $maybe) && (last BIN))
!ll&&!rl&&r
000
$path = $maybe and last BIN
!ll
00
MC/DC0%0/2
-f $maybe && (($path = $maybe) && (last BIN))
-f $maybe $path = $maybe
Truth table0%0/3
A && B
A= -f $maybeB= $path = $maybe
ABresult
0X0
100
111
663  
664 ### in your path -- take this one last, the
665 ### previous two assume extracted tarballs
666 ### or user installs
667 ### note that we don't use 'can_run' as it's
668 ### not an executable, just a wrapper...
669 ### prefer anything that's found in the path parallel to your $^X
670 0 for my $dir (File::Spec->rel2abs( dirname($^X) ),
671 split(/\Q$Config::Config{path_sep}\E/, $ENV{PATH}),
672 File::Spec->curdir,
673 ) {
674  
675 ### On VMS the path could be in UNIX format, and we
676 ### currently need it to be in VMS format
677 0 $dir = VMS::Filespec::vmspath($dir) if ON_VMS;
678  
679 0 $maybe = File::Spec->catfile( $dir, $bin );
680 0 ▶ $path = $maybe and last BIN if -f $maybe;
Branch: 1 branch
BranchTrueFalseTotal
if -f $maybe 0 0 0
Condition0%0/5
-f $maybe && (($path = $maybe) && (last BIN))
!ll&&!rl&&r
000
$path = $maybe and last BIN
!ll
00
MC/DC0%0/2
-f $maybe && (($path = $maybe) && (last BIN))
-f $maybe $path = $maybe
Truth table0%0/3
A && B
A= -f $maybeB= $path = $maybe
ABresult
0X0
100
111
681 }
682 }
683  
684 ### we should have a $path by now ideally, if so return it
685 20 ▶ return $path if defined $path;
Branch: 1 branch
BranchTrueFalseTotal
if defined $path 20 0 20
686  
687 ### CPANPLUS::Dist::MM doesn't require this anymore
688 ### but CPANPLUS::Dist::Build might if it is less than 0.60
689 0 my $cpdb = check_install( module => INSTALLER_BUILD );
690 return '' unless
691 0 ▶ $cpdb and eval { version->parse($cpdb->{version}) < version->parse('0.60') };
Branch: 1 branch
BranchTrueFalseTotal
unless $cpdb and eval { do { "version"->parse($cpdb->{"version"}) < "version"->parse("0.60") } } 0 0 0
Condition0%0/3
$cpdb and eval { do { "version"->parse($cpdb->{"version"}) < "version"->parse("0.60") } }
!ll&&!rl&&r
000
MC/DC0%0/2
$cpdb and eval { do { "version"->parse($cpdb->{"version"}) < "version"->parse("0.60") } }
$cpdb eval { do { "version"->parse($cpdb->{"version"}) < "version"->parse("0.60") } }
Truth table0%0/3
A and B
A= $cpdbB= eval { do { "version"->parse($cpdb->{"version"}) < "version"->parse("0.60") } }
ABresult
0X0
100
111
692  
693 ### if not, warn about it and give sensible default.
694 ### XXX try to be a no-op instead then..
695 ### cross your fingers...
696 ### pass '-P' to perl: "run program through C
697 ### preprocessor before compilation"
698 ### XXX using -P actually changes the way some Makefile.PLs
699 ### are executed, so don't do that... --kane
700 0 error(loc(
701 "Could not find the '%1' binary in your path".
702 "--this may be a problem.\n".
703 "Please locate this program and set ".
704 "your '%2' config entry to its path.\n".
705 "From the default shell, you can do this by typing:\n\n".
706 " %3\n".
707 " %4\n",
708 $name, 'perlwrapper',
709 's program perlwrapper FULL_PATH_TO_CPANP_RUN_PERL',
710 's save'
711 ));
712 0 return '';
713 20 }->();
714  
715 =back
716  
717 =cut
718  
719 sub new {
720 17 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=11.0
Pod documented
721 17 my $obj = $class->SUPER::new;
722  
723 17 $obj->mk_accessors( keys %$Conf );
724  
725 17 for my $acc ( keys %$Conf ) {
726 102 my $subobj = Object::Accessor->new;
727 102 $subobj->mk_accessors( keys %{$Conf->{$acc}} );
728  
729 ### read in all the settings from the sub accessors;
730 102 for my $subacc ( $subobj->ls_accessors ) {
731 1071 $subobj->$subacc( $Conf->{$acc}->{$subacc} );
732 }
733  
734 ### now store it in the parent object
735 102 $obj->$acc( $subobj );
736 }
737  
738 17 $obj->_clean_up_paths;
739  
740 ### shut up IPC::Cmd warning about not finding IPC::Run on win32
741 17 $IPC::Cmd::WARN = 0;
742  
743 17 return $obj;
744 }
745  
746 sub _clean_up_paths {
747 21 ▶ my $self = shift;
Subroutine _clean_up_paths: called CC=6 SCAR=32.2
748  
749 ### clean up paths if we are on win32
750 21 ▶ if( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 21 21
751 0 for my $pgm ( $self->program->ls_accessors ) {
752 0 my $path = $self->program->$pgm;
753  
754 ### paths with whitespace needs to be shortened
755 ### for shell outs.
756 0 ▶ if ($path and $path =~ /\s+/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path and $path =~ /\s+/) 0 0 0
Condition0%0/3
$path and $path =~ /\s+/
!ll&&!rl&&r
000
MC/DC0%0/2
$path and $path =~ /\s+/
$path $path =~ /\s+/
Truth table0%0/3
A and B
A= $pathB= $path =~ /\s+/
ABresult
0X0
100
111
757 0 my($prog, $args);
758  
759 ### patch from Steve Hay, 13th of June 2007
760 ### msg-id: <467012A4.6060705@uk.radan.com>
761 ### windows directories are not allowed to end with
762 ### a space, so any occurrence of '\w\s+/\w+' means
763 ### we're dealing with arguments, not directory
764 ### names.
765 0 ▶ if ($path =~ /^(.*?)(\s+\/.*$)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ m[^(.*?)(\s+/.*$)]) { } 0 0 0
766 0 ($prog, $args) = ($1, $2);
767  
768 ### otherwise, there are no arguments
769 } else {
770 0 ($prog, $args) = ($path, '');
771 }
772  
773 0 $prog = Win32::GetShortPathName( $prog );
774 0 $self->program->$pgm( $prog . $args );
775 }
776 }
777 }
778  
779 21 return 1;
780 }
781  
782 20 1;
783  
784 =pod
785  
786 =head1 BUG REPORTS
787  
788 Please report bugs or other issues to E<lt>bug-cpanplus@rt.cpan.org<gt>.
789  
790 =head1 AUTHOR
791  
792 This module by Jos Boumans E<lt>kane@cpan.orgE<gt>.
793  
794 =head1 COPYRIGHT
795  
796 The CPAN++ interface (of which this module is a part of) is copyright (c)
797 2001 - 2007, Jos Boumans E<lt>kane@cpan.orgE<gt>. All rights reserved.
798  
799 This library is free software; you may redistribute and/or modify it
800 under the same terms as Perl itself.
801  
802 =head1 SEE ALSO
803  
804 L<CPANPLUS::Backend>, L<CPANPLUS::Configure::Setup>, L<CPANPLUS::Configure>
805  
806 =cut
807  
808 # Local variables:
809 # c-indentation-style: bsd
810 # c-basic-offset: 4
811 # indent-tabs-mode: nil
812 # End:
813 # vim: expandtab shiftwidth=4:
« blib/lib/CPANPLUS/Internals/Source/SQLite.pm ↑ Summary lib/CPANPLUS/Module/Checksums.pm »