lib/App/perlbrew.pm

filter: Statementstmt 68.2% 971 / 1422 Branchbran 53.5% 361 / 674 Conditioncond 45.2% 123 / 272 MC/DCmcdc 15.5% 25 / 161 Subroutinesub 76.3% 110 / 144 Podpod 0.0% 0 / 120 totaltotal 56.9% 1590 / 2793 CC 492 SCAR 35.0
CC
492
Cov
61%
check_and_calculate_variations
182.0
run_command_install_multiple
132.0
run_command_alias
127.5
CRAP 33.2
↑ Summary lib/App/Perlbrew/HTTP.pm »
1 package App::perlbrew;
2 70 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 70 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 70 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 70 our $VERSION = "1.03";
6 70 ▶use Config qw( %Config );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 70 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 # Special treat for Cwd to prevent it to be loaded from somewhere binary-incompatible with system perl.
10 70 my @oldinc = @INC;
11  
12 @INC = (
13 $Config{sitelibexp} . "/" . $Config{archname},
14 70 $Config{sitelibexp}, @Config{qw<vendorlibexp vendorarchexp archlibexp privlibexp>},
15 );
16  
17 70 require Cwd;
18 70 @INC = @oldinc;
19 }
20  
21 70 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 70 ▶use CPAN::Perl::Releases ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 70 ▶use JSON::PP qw( decode_json );
Subroutine BEGIN: called CC=1 SCAR=0.0
24 70 ▶use File::Copy qw( copy move );
Subroutine BEGIN: called CC=1 SCAR=0.0
25 70 ▶use Capture::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 70 ▶use App::Perlbrew::Util qw( files_are_the_same uniq find_similar_tokens looks_like_url_of_skaji_relocatable_perl looks_like_sys_would_be_compatible_with_skaji_relocatable_perl make_skaji_relocatable_perl_url prompt );
Subroutine BEGIN: called CC=1 SCAR=0.0
28 70 ▶use App::Perlbrew::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29 70 ▶use App::Perlbrew::Path::Root ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30 70 ▶use App::Perlbrew::HTTP qw( http_download http_get );
Subroutine BEGIN: called CC=1 SCAR=0.0
31 70 ▶use App::Perlbrew::Patchperl qw( maybe_patchperl );
Subroutine BEGIN: called CC=1 SCAR=0.0
32 70 ▶use App::Perlbrew::Sys;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 ### global variables
35  
36 # set $ENV{SHELL} to executable path of parent process (= shell) if it's missing
37 # (e.g. if this script was executed by a daemon started with "service xxx start")
38 # ref: https://github.com/gugod/App-perlbrew/pull/404
39 70 ▶$ENV{SHELL} ||= App::Perlbrew::Path->new( "/proc", getppid, "exe" )->readlink if -d "/proc";
Branch: 1 branch
BranchTrueFalseTotal
if -d "/proc" 70 0 70
Condition66%2/3
$ENV{"SHELL"} ||= "App::Perlbrew::Path"->new("/proc", getppid, "exe")->readlink
l!l&&r!l&&!r
11590
MC/DC0%0/2
$ENV{"SHELL"} ||= "App::Perlbrew::Path"->new("/proc", getppid, "exe")->readlink
$ENV{"SHELL"} "App::Perlbrew::Path"->new("/proc", getppid, "exe")->readlink
Truth table66%2/3
A ||= B
A= $ENV{"SHELL"}B= "App::Perlbrew::Path"->new("/proc", getppid, "exe")->readlink
ABresult
1X1
011
000
40  
41 0 ▶local $SIG{__DIE__} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 my $message = shift;
43 0 warn $message;
44 0 exit(1);
45 70 };
46  
47 70 our $CONFIG;
48 70 our $PERLBREW_ROOT;
49 70 our $PERLBREW_HOME;
50  
51 70 my @flavors = (
52 {
53 d_option => 'usethreads',
54 implies => 'multi',
55 common => 1,
56 opt => 'thread|threads'
57 }, # threads is for backward compatibility
58  
59 {
60 d_option => 'usemultiplicity',
61 opt => 'multi'
62 },
63  
64 {
65 d_option => 'uselongdouble',
66 common => 1,
67 opt => 'ld'
68 },
69  
70 {
71 d_option => 'use64bitint',
72 common => 1,
73 opt => '64int'
74 },
75  
76 {
77 d_option => 'use64bitall',
78 implies => '64int',
79 opt => '64all'
80 },
81  
82 {
83 d_option => 'DEBUGGING',
84 opt => 'debug'
85 },
86  
87 {
88 d_option => 'cc=clang',
89 opt => 'clang'
90 },
91 );
92  
93 70 my %flavor;
94 70 my $flavor_ix = 0;
95 70 for (@flavors) {
96 490 my ($name) = $_->{opt} =~ /([^|]+)/;
97 490 $_->{name} = $name;
98 490 $_->{ix} = ++$flavor_ix;
99 490 $flavor{$name} = $_;
100 }
101 70 for (@flavors) {
102 490 ▶ if ( my $implies = $_->{implies} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $implies = $_->{"implies"}) 140 350 490
103 140 $flavor{$implies}{implied_by} = $_->{name};
104 }
105 }
106  
107 70 my %command_aliases = (
108 'rm' => 'uninstall',
109 'delete' => 'uninstall',
110 );
111  
112 5 ▶sub resolve_command_alias {
Subroutine resolve_command_alias: called CC=1 SCAR=0.0
Pod undocumented
113 5 my $x = shift;
114 5 $command_aliases{$x};
115 }
116  
117 ### methods
118 245 ▶sub new {
Subroutine new: called CC=8 SCAR=20.8
Pod undocumented
119 245 my ( $class, @argv ) = @_;
120  
121 245 my %opt = (
122 original_argv => \@argv,
123 args => [],
124 yes => 0,
125 force => 0,
126 quiet => 0,
127 D => [],
128 U => [],
129 A => [],
130 sitecustomize => '',
131 destdir => '',
132 noman => '',
133 variation => '',
134 both => [],
135 append => '',
136 reverse => 0,
137 verbose => 0,
138 );
139  
140 245 $opt{$_} = '' for keys %flavor;
141  
142 245 ▶ if (@argv) {
Branch: 1 branch
BranchTrueFalseTotal
if (@argv) 160 85 245
143  
144 # build a local @ARGV to allow us to use an older
145 # Getopt::Long API in case we are building on an older system
146 160 local (@ARGV) = @argv;
147  
148 160 Getopt::Long::Configure(
149 'pass_through',
150 'no_ignore_case',
151 'bundling',
152 'permute', # default behaviour except 'exec'
153 );
154  
155 160 $class->parse_cmdline( \%opt );
156  
157 160 $opt{args} = \@ARGV;
158  
159 # fix up the effect of 'bundling'
160 160 foreach my $flags ( @opt{qw(D U A)} ) {
161 480 foreach my $value ( @{$flags} ) {
162 13 $value =~ s/^=//;
163 }
164 }
165 }
166  
167 245 my $self = bless \%opt, $class;
168  
169 # Treat --root option same way as env variable PERLBREW_ROOT (with higher priority)
170 245 ▶ if ( $opt{root} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"root"}) 3 242 245
171 3 $ENV{PERLBREW_ROOT} = $self->root( $opt{root} );
172 }
173  
174 245 ▶ if ( $opt{builddir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"builddir"}) 1 244 245
175 1 $self->{builddir} = App::Perlbrew::Path->new( $opt{builddir} );
176 }
177  
178 # Ensure propagation of $PERLBREW_HOME and $PERLBREW_ROOT
179 245 $self->root;
180 245 $self->home;
181  
182 245 ▶ if ( $self->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verbose"}) 3 242 245
183 3 $App::Perlbrew::HTTP::HTTP_VERBOSE = 1;
184 }
185  
186 245 return $self;
187 }
188  
189 194 ▶sub parse_cmdline {
Subroutine parse_cmdline: called CC=2 SCAR=7.4
Pod undocumented
190 194 my ( $self, $params, @ext ) = @_;
191  
192 194 ▶ my @f = map { $flavor{$_}{opt} || $_ } keys %flavor;
Condition33%1/3
$flavor{$_}{'opt'} || $_
l!l&&r!l&&!r
135800
MC/DC0%0/2
$flavor{$_}{'opt'} || $_
$flavor{$_}{'opt'} $_
Truth table33%1/3
A || B
A= $flavor{$_}{'opt'}B= $_
ABresult
1X1
011
000
193  
194 194 return Getopt::Long::GetOptions(
195 $params,
196  
197 'yes',
198 'force|f',
199 'reverse',
200 'notest|n',
201 'quiet|q',
202 'verbose|v',
203 'input|i=s',
204 'output|o=s',
205 'as=s',
206 'append=s',
207 'help|h',
208 'version',
209 'root=s',
210 'switch',
211 'all',
212 'shell=s',
213 'no-patchperl',
214 'no-decoration',
215  
216 "builddir=s",
217  
218 # options passed directly to Configure
219 'D=s@',
220 'U=s@',
221 'A=s@',
222  
223 'j=i',
224  
225 # options that affect Configure and customize post-build
226 'sitecustomize=s',
227 'destdir=s',
228 'noman',
229  
230 # flavors support
231 'both|b=s@',
232 'all-variations',
233 'common-variations',
234 @f,
235  
236 @ext
237 );
238 }
239  
240 67 ▶sub sys { App::Perlbrew::Sys:: }
Subroutine sys: called CC=1 SCAR=0.0
Pod undocumented
241  
242 840 ▶sub root {
Subroutine root: called CC=8 SCAR=21.2
Pod undocumented
243 840 my ( $self, $new_root ) = @_;
244  
245 $new_root ||=
246 $PERLBREW_ROOT
247 || $ENV{PERLBREW_ROOT}
248 || App::Perlbrew::Path->new( $ENV{HOME}, "perl5", "perlbrew" )->stringify
249 840 ▶ unless $self->{root};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"root"} 242 598 840
Condition66%6/9
$new_root ||= $App::perlbrew::PERLBREW_ROOT || $ENV{"PERLBREW_ROOT"} || "App::Perlbrew::Path"->new($ENV{"HOME"}, "perl5", "perlbrew")->stringify
l!l&&r!l&&!r
02420
$App::perlbrew::PERLBREW_ROOT || $ENV{'PERLBREW_ROOT'} || 'App::Perlbrew::Path'->new($ENV{'HOME'}, 'perl5', 'perlbrew')->stringify
l!l&&r!l&&!r
230120
$App::perlbrew::PERLBREW_ROOT or $ENV{"PERLBREW_ROOT"}
l!l&&r!l&&!r
2201012
MC/DC0%0/4
$new_root ||= $App::perlbrew::PERLBREW_ROOT || $ENV{"PERLBREW_ROOT"} || "App::Perlbrew::Path"->new($ENV{"HOME"}, "perl5", "perlbrew")->stringify
$new_root $App::perlbrew::PERLBREW_ROOT $ENV{"PERLBREW_ROOT"} 'App::Perlbrew::Path'->new($ENV{'HOME'}, 'perl5', 'perlbrew')->stringify
Truth table0%0/5
A ||= B or C || D
A= $new_rootB= $App::perlbrew::PERLBREW_ROOTC= $ENV{"PERLBREW_ROOT"}D= 'App::Perlbrew::Path'->new($ENV{'HOME'}, 'perl5', 'perlbrew')->stringify
ABCDresult
1XXX1
01XX1
001X1
00011
00000
250  
251 840 ▶ $self->{root} = $PERLBREW_ROOT = $new_root
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_root 247 593 840
252 if defined $new_root;
253  
254 $self->{root} = App::Perlbrew::Path::Root->new( $self->{root} )
255 840 ▶ unless ref $self->{root};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"root"} 247 593 840
256  
257 $self->{root} = App::Perlbrew::Path::Root->new( $self->{root}->stringify )
258 840 ▶ unless $self->{root}->isa('App::Perlbrew::Path::Root');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"root"}->isa("App::Perlbrew::Path::Root") 0 840 840
259  
260 840 return $self->{root};
261 }
262  
263 855 ▶sub home {
Subroutine home: called CC=7 SCAR=19.7
Pod undocumented
264 855 my ( $self, $new_home ) = @_;
265  
266 $new_home ||=
267 $PERLBREW_HOME
268 || $ENV{PERLBREW_HOME}
269 || App::Perlbrew::Path->new( $ENV{HOME}, ".perlbrew" )->stringify
270 855 ▶ unless $self->{home};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"home"} 245 610 855
Condition66%6/9
$new_home ||= $App::perlbrew::PERLBREW_HOME || $ENV{"PERLBREW_HOME"} || "App::Perlbrew::Path"->new($ENV{"HOME"}, ".perlbrew")->stringify
l!l&&r!l&&!r
02450
$App::perlbrew::PERLBREW_HOME || $ENV{'PERLBREW_HOME'} || 'App::Perlbrew::Path'->new($ENV{'HOME'}, '.perlbrew')->stringify
l!l&&r!l&&!r
224210
$App::perlbrew::PERLBREW_HOME or $ENV{"PERLBREW_HOME"}
l!l&&r!l&&!r
222221
MC/DC0%0/4
$new_home ||= $App::perlbrew::PERLBREW_HOME || $ENV{"PERLBREW_HOME"} || "App::Perlbrew::Path"->new($ENV{"HOME"}, ".perlbrew")->stringify
$new_home $App::perlbrew::PERLBREW_HOME $ENV{"PERLBREW_HOME"} 'App::Perlbrew::Path'->new($ENV{'HOME'}, '.perlbrew')->stringify
Truth table0%0/5
A ||= B or C || D
A= $new_homeB= $App::perlbrew::PERLBREW_HOMEC= $ENV{"PERLBREW_HOME"}D= 'App::Perlbrew::Path'->new($ENV{'HOME'}, '.perlbrew')->stringify
ABCDresult
1XXX1
01XX1
001X1
00011
00000
271  
272 855 ▶ $self->{home} = $PERLBREW_HOME = $new_home
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_home 246 609 855
273 if defined $new_home;
274  
275 $self->{home} = App::Perlbrew::Path->new( $self->{home} )
276 855 ▶ unless ref $self->{home};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"home"} 245 610 855
277  
278 855 return $self->{home};
279 }
280  
281 4 ▶sub builddir {
Subroutine builddir: called CC=2 SCAR=7.1
Pod undocumented
282 4 my ($self) = @_;
283  
284 4 ▶ return $self->{builddir} || $self->root->build;
Condition66%2/3
$self->{'builddir'} || $self->root->build
l!l&&r!l&&!r
130
MC/DC0%0/2
$self->{'builddir'} || $self->root->build
$self->{'builddir'} $self->root->build
Truth table66%2/3
A || B
A= $self->{'builddir'}B= $self->root->build
ABresult
1X1
011
000
285 }
286  
287 701 ▶sub current_perl {
Subroutine current_perl: called CC=4 SCAR=13.9
Pod undocumented
288 701 my ( $self, $v ) = @_;
289 701 ▶ $self->{current_perl} = $v if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 6 695 701
290 701 ▶ return $self->{current_perl} || $self->env('PERLBREW_PERL') || '';
Condition100%5/5
$self->{'current_perl'} || $self->env('PERLBREW_PERL') || ''
l!l
46655
$self->{"current_perl"} or $self->env("PERLBREW_PERL")
l!l&&r!l&&!r
2125655
MC/DC100%2/2
$self->{'current_perl'} || $self->env('PERLBREW_PERL') || ''
$self->{"current_perl"} $self->env("PERLBREW_PERL")
Truth table100%3/3
A or B
A= $self->{"current_perl"}B= $self->env("PERLBREW_PERL")
ABresult
1X1
011
000
291 }
292  
293 512 ▶sub current_lib {
Subroutine current_lib: called CC=4 SCAR=14.2
Pod undocumented
294 512 my ( $self, $v ) = @_;
295 512 ▶ $self->{current_lib} = $v if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 0 512 512
296 512 ▶ return $self->{current_lib} || $self->env('PERLBREW_LIB') || '';
Condition80%4/5
$self->{'current_lib'} || $self->env('PERLBREW_LIB') || ''
l!l
15497
$self->{"current_lib"} or $self->env("PERLBREW_LIB")
l!l&&r!l&&!r
015497
MC/DC50%1/2
$self->{'current_lib'} || $self->env('PERLBREW_LIB') || ''
$self->{"current_lib"} $self->env("PERLBREW_LIB")
Truth table66%2/3
A or B
A= $self->{"current_lib"}B= $self->env("PERLBREW_LIB")
ABresult
1X1
011
000
297 }
298  
299 4 ▶sub current_shell_is_bashish {
Subroutine current_shell_is_bashish: called CC=2 SCAR=6.9
Pod undocumented
300 4 my ($self) = @_;
301 4 ▶ return ( $self->current_shell eq 'bash' ) || ( $self->current_shell eq 'zsh' );
Condition100%3/3
$self->current_shell eq 'bash' || $self->current_shell eq 'zsh'
l!l&&r!l&&!r
112
MC/DC100%2/2
$self->current_shell eq 'bash' || $self->current_shell eq 'zsh'
$self->current_shell eq 'bash' $self->current_shell eq 'zsh'
Truth table100%3/3
A || B
A= $self->current_shell eq 'bash'B= $self->current_shell eq 'zsh'
ABresult
1X1
011
000
302 }
303  
304 24 ▶sub current_shell {
Subroutine current_shell: called CC=4 SCAR=14.2
Pod undocumented
305 24 my ( $self, $x ) = @_;
306 24 ▶ $self->{current_shell} = $x if $x;
Branch: 1 branch
BranchTrueFalseTotal
if $x 10 14 24
307 24 ▶ return $self->{current_shell} ||= do {
Condition66%2/3
$self->{"current_shell"} ||= do { my $shell_name = "App::Perlbrew::Path"->new($self->{"shell"} || $self->env("SHELL"))->basename; $shell_name =~ s/\d+$//; $shell_name }
l!l&&r!l&&!r
2220
MC/DC0%0/2
$self->{"current_shell"} ||= do { my $shell_name = "App::Perlbrew::Path"->new($self->{"shell"} || $self->env("SHELL"))->basename; $shell_name =~ s/\d+$//; $shell_name }
$self->{"current_shell"} do { my $shell_name = "App::Perlbrew::Path"->new($self->{"shell"} || $self->env("SHELL"))->basename; $shell_name =~ s/\d+$//; $shell_name }
Truth table66%2/3
A ||= B
A= $self->{"current_shell"}B= do { my $shell_name = "App::Perlbrew::Path"->new($self->{"shell"} || $self->env("SHELL"))->basename; $shell_name =~ s/\d+$//; $shell_name }
ABresult
1X1
011
000
308 2 ▶ my $shell_name = App::Perlbrew::Path->new( $self->{shell} || $self->env('SHELL') )->basename;
Condition33%1/3
$self->{'shell'} || $self->env('SHELL')
l!l&&r!l&&!r
020
MC/DC0%0/2
$self->{'shell'} || $self->env('SHELL')
$self->{'shell'} $self->env('SHELL')
Truth table33%1/3
A || B
A= $self->{'shell'}B= $self->env('SHELL')
ABresult
1X1
011
000
309 2 $shell_name =~ s/\d+$//;
310 2 $shell_name;
311 };
312 }
313  
314 467 ▶sub current_env {
Subroutine current_env: called CC=2 SCAR=6.9
Pod undocumented
315 467 my ($self) = @_;
316 467 my $l = $self->current_lib;
317 467 ▶ $l = "@" . $l if $l;
Branch: 1 branch
BranchTrueFalseTotal
if $l 12 455 467
318 467 return $self->current_perl . $l;
319 }
320  
321 1 ▶sub installed_perl_executable {
Subroutine installed_perl_executable: called CC=3 SCAR=12.0
Pod undocumented
322 1 my ( $self, $name ) = @_;
323 1 ▶ die unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 1 1
324  
325 1 my $executable = $self->root->perls($name)->perl;
326 1 ▶ return $executable if -e $executable;
Branch: 1 branch
BranchTrueFalseTotal
if -e $executable 1 0 1
327 0 return "";
328 }
329  
330 0 ▶sub configure_args {
Subroutine configure_args: not called CC=3 SCAR=24.8
Pod undocumented
331 0 my ( $self, $name ) = @_;
332  
333 0 my $perl_cmd = $self->installed_perl_executable($name);
334 0 my $code = 'while(($_,$v)=each(%Config)){print"$_ $v" if /config_arg/}';
335  
336 0 my @output = split "\n" => $self->do_capture( $perl_cmd, '-MConfig', '-wle', $code );
337  
338 0 my %arg;
339 0 for (@output) {
340 0 my ( $k, $v ) = split " ", $_, 2;
341 0 $arg{$k} = $v;
342 }
343  
344 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
345 0 return map { $arg{"config_arg$_"} } ( 1 .. $arg{config_argc} );
346 }
347  
348 0 return $arg{config_args};
349 }
350  
351 11 ▶sub cpan_mirror {
Subroutine cpan_mirror: called CC=4 SCAR=13.9
Pod undocumented
352 11 my ( $self, $v ) = @_;
353  
354 11 ▶ $self->{cpan_mirror} = $v if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 1 10 11
355  
356 11 ▶ unless ( $self->{cpan_mirror} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"cpan_mirror"}) 5 6 11
357 5 ▶ $self->{cpan_mirror} = $self->env("PERLBREW_CPAN_MIRROR") || "https://cpan.metacpan.org";
Condition50%1/2
$self->env('PERLBREW_CPAN_MIRROR') || 'https://cpan.metacpan.org'
l!l
05
MC/DC0%0/1
$self->env('PERLBREW_CPAN_MIRROR') || 'https://cpan.metacpan.org'
$self->env('PERLBREW_CPAN_MIRROR')
Truth table50%1/2
A
A= $self->env('PERLBREW_CPAN_MIRROR')
Aresult
11
00
358 5 $self->{cpan_mirror} =~ s{/+$}{};
359 }
360  
361 11 return $self->{cpan_mirror};
362 }
363  
364 1310 ▶sub env {
Subroutine env: called CC=2 SCAR=8.1
Pod undocumented
365 1310 my ( $self, $name ) = @_;
366 1310 ▶ return $ENV{$name} if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 1310 0 1310
367 0 return \%ENV;
368 }
369  
370 0 ▶sub is_shell_csh {
Subroutine is_shell_csh: not called CC=2 SCAR=17.9
Pod undocumented
371 0 my ($self) = @_;
372 0 ▶ return 1 if $self->env('SHELL') =~ /(t?csh)/;
Branch: 1 branch
BranchTrueFalseTotal
if $self->env("SHELL") =~ /(t?csh)/ 0 0 0
373 0 return 0;
374 }
375  
376 # Entry point method: handles all the arguments
377 # and dispatches to an appropriate internal
378 # method to execute the corresponding command.
379 154 ▶sub run {
Subroutine run: called CC=1 SCAR=0.0
Pod undocumented
380 154 my ($self) = @_;
381 154 $self->run_command( $self->args );
382 }
383  
384 158 ▶sub args {
Subroutine args: called CC=3 SCAR=12.0
Pod undocumented
385 158 my ($self) = @_;
386  
387 # keep 'force' and 'yes' coherent across commands
388 158 ▶ $self->{force} = $self->{yes} = 1 if ( $self->{force} || $self->{yes} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"force"} or $self->{"yes"} 0 158 158
Condition33%1/3
$self->{"force"} or $self->{"yes"}
l!l&&r!l&&!r
00158
MC/DC0%0/2
$self->{"force"} or $self->{"yes"}
$self->{"force"} $self->{"yes"}
Truth table33%1/3
A or B
A= $self->{"force"}B= $self->{"yes"}
ABresult
1X1
011
000
389  
390 158 return @{ $self->{args} };
391 }
392  
393 11 ▶sub commands {
Subroutine commands: called CC=6 SCAR=17.9
Pod undocumented
394 11 my ($self) = @_;
395  
396 11 ▶ my $package = ref $self ? ref $self : $self;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 11 0 11
397  
398 11 my @commands;
399 11 my $symtable = do {
400 70 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
401 11 \%{ $package . '::' };
402 };
403  
404 11 foreach my $sym ( keys %$symtable ) {
405 1611 ▶ if ( $sym =~ /^run_command_/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sym =~ /^run_command_/) 466 1145 1611
406 466 my $glob = $symtable->{$sym};
407 466 ▶ if ( ref($glob) eq 'CODE' || defined *$glob{CODE} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $glob eq "CODE" or defined *$glob{"CODE"}) 462 4 466
Condition66%2/3
ref $glob eq "CODE" or defined *$glob{"CODE"}
l!l&&r!l&&!r
04624
MC/DC50%1/2
ref $glob eq "CODE" or defined *$glob{"CODE"}
ref $glob eq "CODE" defined *$glob{"CODE"}
Truth table66%2/3
A or B
A= ref $glob eq "CODE"B= defined *$glob{"CODE"}
ABresult
1X1
011
000
408  
409 # with perl >= 5.27 stash entry can points to a CV directly
410 462 $sym =~ s/^run_command_//;
411 462 $sym =~ s/_/-/g;
412 462 push @commands, $sym;
413 }
414 }
415 }
416  
417 11 return @commands;
418 }
419  
420 5 ▶sub find_similar_commands {
Subroutine find_similar_commands: called CC=1 SCAR=0.0
Pod undocumented
421 5 my ( $self, $command ) = @_;
422  
423 5 $command =~ s/_/-/g;
424  
425 5 return @{ find_similar_tokens($command, [ sort $self->commands ]) };
426 }
427  
428 # This method is called in the 'run' loop
429 # and executes every specific action depending
430 # on the type of command.
431 #
432 # The first argument to this method is a self reference,
433 # while the first "real" argument is the command to execute.
434 # Other parameters after the command to execute are
435 # considered as arguments for the command itself.
436 #
437 # In general the command is executed via a method named after the
438 # command itself and with the 'run_command' prefix. For instance
439 # the command 'exec' is handled by a method
440 # `run_command_exec`
441 #
442 # If no candidates can be found, an execption is thrown
443 # and a similar command is shown to the user.
444 154 ▶sub run_command {
Subroutine run_command: called CC=11 SCAR=25.3
Pod undocumented
445 154 my ( $self, $x, @args ) = @_;
446 154 my $command = $x;
447  
448 154 ▶ if ( $self->{version} ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'version'}) { } 0 154 154
elsif (not $x) { } 2 152 154
elsif ($x eq 'help') { } 4 148 152
449 0 $x = 'version';
450 }
451 elsif ( !$x ) {
452 2 $x = 'help';
453 2 @args = ( 0, 0 );
454 }
455 elsif ( $x eq 'help' ) {
456 4 ▶ @args = ( 0, 2 ) unless @args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 3 1 4
457 }
458  
459 154 my $s = $self->can("run_command_$x");
460 154 ▶ unless ($s) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s) 26 128 154
461 26 $x =~ y/-/_/;
462 26 $s = $self->can("run_command_$x");
463 }
464  
465 154 ▶ unless ($s) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s) 2 152 154
466 2 ▶ if (my $x = resolve_command_alias($x)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $x = resolve_command_alias($x)) 0 2 2
467 0 $s = $self->can("run_command_$x")
468 }
469 }
470  
471 154 ▶ unless ($s) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s) 2 152 154
472 2 my @commands = $self->find_similar_commands($x);
473  
474 2 ▶ if ( @commands > 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@commands > 1) { } 0 2 2
elsif (@commands == 1) { } 0 2 2
475 0 @commands = map { ' ' . $_ } @commands;
476 0 die "Unknown command: `$command`. Did you mean one of the following?\n" . join( "\n", @commands ) . "\n";
477 }
478 elsif ( @commands == 1 ) {
479 0 die "Unknown command: `$command`. Did you mean `$commands[0]`?\n";
480 }
481 else {
482 2 die "Unknown command: `$command`. Typo?\n";
483 }
484 }
485  
486 152 $self->$s(@args);
487 }
488  
489 2 ▶sub run_command_version {
Subroutine run_command_version: called CC=1 SCAR=0.0
Pod undocumented
490 2 my ($self) = @_;
491 2 my $package = ref $self;
492 2 my $version = $self->VERSION;
493 2 print "$0 - $package/$version\n";
494 }
495  
496 # Provides help information about a command.
497 # The idea is similar to the 'run_command' and 'run_command_$x' chain:
498 # this method dispatches to a 'run_command_help_$x' method
499 # if found in the class, otherwise it tries to extract the help
500 # documentation via the POD of the class itself using the
501 # section 'COMMAND: $x' with uppercase $x.
502 8 ▶sub run_command_help {
Subroutine run_command_help: called CC=9 SCAR=22.4
Pod undocumented
503 8 my ( $self, $command, $verbose, $return_text ) = @_;
504  
505 8 require Pod::Usage;
506  
507 8 ▶ if ( $command && !defined($verbose) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command and not defined $verbose) { } 3 5 8
Condition66%2/3
$command and not defined $verbose
!ll&&!rl&&r
503
MC/DC50%1/2
$command and not defined $verbose
$command not defined $verbose
Truth table66%2/3
A and not(B)
A= $commandB= not defined $verbose
ABresult
0X0
100
111
508 3 ▶ if ( $self->can("run_command_help_$command") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can("run_command_help_$command")) { } 0 3 3
509 0 $self->can("run_command_help_$command")->($self);
510 }
511 else {
512 3 my $out = "";
513 3 open my $fh, ">", \$out;
514  
515 3 ▶ if (my $x = resolve_command_alias($command)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $x = resolve_command_alias($command)) 0 3 3
516 0 $command = $x;
517 }
518  
519 Pod::Usage::pod2usage(
520 3 -exitval => "NOEXIT",
521 -verbose => 99,
522 -sections => "COMMAND: " . uc($command),
523 -output => $fh,
524 -noperldoc => 1
525 );
526 3 $out =~ s/\A[^\n]+\n//s;
527 3 $out =~ s/^ //gm;
528  
529 3 ▶ if ( $out =~ /\A\s*\Z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($out =~ /\A\s*\Z/) 2 1 3
530 2 $out = "Cannot find documentation for '$command'\n\n";
531 }
532  
533 3 ▶ return "\n$out" if ($return_text);
Branch: 1 branch
BranchTrueFalseTotal
if $return_text 2 1 3
534 1 print "\n$out";
535 1 close $fh;
536 }
537 }
538 else {
539 5 ▶ Pod::Usage::pod2usage(
Branch: 1 branch
BranchTrueFalseTotal
defined $command ? : 5 0 5
Condition100%2/2
$verbose || 0
l!l
32
MC/DC100%1/1
$verbose || 0
$verbose
Truth table100%2/2
A
A= $verbose
Aresult
11
00
540 -noperldoc => 1,
541 -verbose => $verbose || 0,
542 -exitval => ( defined $command ? $command : 1 )
543 );
544 }
545 }
546  
547 # introspection for compgen
548 70 my %comp_installed = (
549 use => 1,
550 switch => 1,
551 );
552  
553 7 ▶sub run_command_compgen {
Subroutine run_command_compgen: called CC=9 SCAR=24.6
Pod undocumented
554 7 my ( $self, $cur, @args ) = @_;
555  
556 7 ▶ $cur = 0 unless defined($cur);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cur 1 6 7
557  
558 # do `tail -f bashcomp.log` for debugging
559 7 ▶ if ( $self->env('PERLBREW_DEBUG_COMPLETION') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->env("PERLBREW_DEBUG_COMPLETION")) 0 7 7
560 0 open my $log, '>>', 'bashcomp.log';
561 0 print $log "[$$] $cur of [@args]\n";
562 }
563 7 my $subcommand = $args[1];
564 7 my $subcommand_completed = ( $cur >= 2 );
565  
566 7 ▶ if ( !$subcommand_completed ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $subcommand_completed) { } 3 4 7
567 3 $self->_compgen( $subcommand, $self->commands );
568 }
569 else { # complete args of a subcommand
570 4 ▶ if ( $comp_installed{$subcommand} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($comp_installed{$subcommand}) { } 4 0 4
elsif ($subcommand eq 'help') { } 0 0 0
571 4 ▶ if ( $cur <= 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur <= 2) 4 0 4
572 4 my $part;
573 4 ▶ if ( defined( $part = $args[2] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($part = $args[2])) 2 2 4
574 2 $part = qr/ \Q$part\E /xms;
575 }
576 4 $self->_compgen( $part, map { $_->{name} } $self->installed_perls() );
577 }
578 }
579 elsif ( $subcommand eq 'help' ) {
580 0 ▶ if ( $cur <= 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur <= 2) 0 0 0
581 0 $self->_compgen( $args[2], $self->commands() );
582 }
583 }
584 else {
585 # TODO
586 }
587 }
588 }
589  
590 5 ▶sub _firstrcfile {
Subroutine _firstrcfile: called CC=3 SCAR=11.1
591 5 my ( $self, @files ) = @_;
592 5 foreach my $path (@files) {
593 16 ▶ return $path if -f App::Perlbrew::Path->new( $self->env('HOME'), $path );
Branch: 1 branch
BranchTrueFalseTotal
if -f "App::Perlbrew::Path"->new($self->env("HOME"), $path) 5 11 16
594 }
595 0 return;
596 }
597  
598 7 ▶sub _compgen {
Subroutine _compgen: called CC=4 SCAR=13.9
599 7 my ( $self, $part, @reply ) = @_;
600 7 ▶ if ( defined $part ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $part) 4 3 7
601 4 ▶ $part = qr/\A \Q$part\E /xms if ref($part) ne ref(qr//);
Branch: 1 branch
BranchTrueFalseTotal
if ref $part ne ref qr// 2 2 4
602 4 @reply = grep { /$part/ } @reply;
603 }
604 7 foreach my $word (@reply) {
605 61 print $word, "\n";
606 }
607 }
608  
609 # Internal utility function.
610 # Given a specific perl version, e.g., perl-5.27.4
611 # returns a string with a formatted version number such
612 # as 05027004. Such string can be used as a number
613 # in order to make either a string comparison
614 # or a numeric comparison.
615 #
616 # In the case of cperl the major number is added by 6
617 # so that it would match the project claim of being
618 # Perl 5+6 = 11. The final result is then
619 # multiplied by a negative factor (-1) in order
620 # to make cperl being "less" in the ordered list
621 # than a normal Perl installation.
622 #
623 # The returned string is made by four pieces of two digits each:
624 # MMmmppbb
625 # where:
626 # MM is the major Perl version (e.g., 5 -> 05)
627 # mm is the minor Perl version (e.g. 27 -> 27)
628 # pp is the patch level (e.g., 4 -> 04)
629 # bb is the blead flag: it is 00 for a "normal" release, or 01 for a blead one
630 629 ▶sub comparable_perl_version {
Subroutine comparable_perl_version: called CC=9 SCAR=30.0
Pod undocumented
631 629 my ( $self, $perl_version ) = @_;
632 629 my ( $is_cperl, $is_blead ) = ( 0, 0 );
633 629 my ( $major, $minor, $patch ) = ( 0, 0, 0 );
634 629 ▶ if ( $perl_version =~ /^(?:(c?perl)-?)?(\d)\.(\d+).(\d+).*/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($perl_version =~ /^(?:(c?perl)-?)?(\d)\.(\d+).(\d+).*/) { } 629 0 629
elsif ($perl_version =~ /^(?:(c?perl)-?)?-?(blead)$/) { } 0 0 0
635 629 ▶ $is_cperl = $1 && ( $1 eq 'cperl' );
Condition66%2/3
$1 && $1 eq 'cperl'
!ll&&!rl&&r
590390
MC/DC0%0/2
$1 && $1 eq 'cperl'
$1 $1 eq 'cperl'
Truth table66%2/3
A && B
A= $1B= $1 eq 'cperl'
ABresult
0X0
100
111
636 629 ▶ $major = $2 + ( $is_cperl ? 6 : 0 ); # major version
Branch: 1 branch
BranchTrueFalseTotal
$is_cperl ? : 0 629 629
637 629 $minor = $3; # minor version
638 629 $patch = $4; # patch level
639  
640 }
641 elsif ( $perl_version =~ /^(?:(c?perl)-?)?-?(blead)$/ ) {
642  
643 # in the case of a blead release use a fake high number
644 # to assume it is the "latest" release number available
645 0 ▶ $is_cperl = $1 && ( $1 eq 'cperl' );
Condition0%0/3
$1 && $1 eq 'cperl'
!ll&&!rl&&r
000
MC/DC0%0/2
$1 && $1 eq 'cperl'
$1 $1 eq 'cperl'
Truth table0%0/3
A && B
A= $1B= $1 eq 'cperl'
ABresult
0X0
100
111
646 0 ▶ $is_blead = $2 && ( $2 eq 'blead' );
Condition0%0/3
$2 && $2 eq 'blead'
!ll&&!rl&&r
000
MC/DC0%0/2
$2 && $2 eq 'blead'
$2 $2 eq 'blead'
Truth table0%0/3
A && B
A= $2B= $2 eq 'blead'
ABresult
0X0
100
111
647 0 ( $major, $minor, $patch ) = ( 5, 99, 99 );
648 }
649  
650 629 ▶ return ( $is_cperl ? -1 : 1 ) * sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$is_cperl ? : 0 629 629
$is_cperl ? : 0 629 629
651 '%02d%02d%02d%02d',
652 $major + ( $is_cperl ? 6 : 0 ), # major version
653 $minor, # minor version
654 $patch, # patch level
655 $is_blead
656 ); # blead
657 }
658  
659 # Internal method.
660 # Performs a comparable sort of the perl versions specified as
661 # list.
662 3 ▶sub sort_perl_versions {
Subroutine sort_perl_versions: called CC=2 SCAR=7.0
Pod undocumented
663 3 my ( $self, @perls ) = @_;
664  
665 39 return map { $_->[0] }
666 100 ▶ sort { ( $self->{reverse} ? $a->[1] <=> $b->[1] : $b->[1] <=> $a->[1] ) }
Branch: 1 branch
BranchTrueFalseTotal
$self->{'reverse'} ? : 0 100 100
667 3 map { [$_, $self->comparable_perl_version($_)] } @perls;
668 }
669  
670 3 ▶sub run_command_available {
Subroutine run_command_available: called CC=9 SCAR=22.2
Pod undocumented
671 3 my ($self) = @_;
672  
673 3 my @installed = $self->installed_perls(@_);
674 3 my $is_verbose = $self->{verbose};
675  
676 3 my @sections = ( ['perl', 'available_perl_distributions'] );
677  
678 3 for (@sections) {
679 3 my ( $header, $method ) = @$_;
680  
681 3 print "# $header\n";
682  
683 3 my $perls = $self->$method;
684  
685 # sort the keys of Perl installation (Randal to the rescue!)
686 2 my @sorted_perls = $self->sort_perl_versions( keys %$perls );
687  
688 2 for my $available (@sorted_perls) {
689 28 my $url = $perls->{$available};
690 28 my $ctime;
691  
692 28 for my $installed (@installed) {
693 28 my $name = $installed->{name};
694 28 my $cur = $installed->{is_current};
695 28 ▶ if ( $available eq $installed->{name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($available eq $installed->{"name"}) 1 27 28
696 1 $ctime = $installed->{ctime};
697 1 last;
698 }
699 }
700  
701 28 ▶ printf "%1s %12s %s %s\n", $ctime ? 'i' : '', $available,
Branch: 4 branches
BranchTrueFalseTotal
$ctime ? : 0 28 28
$is_verbose ? : 28 0 28
$ctime ? : 0 28 28
$is_verbose ? : 28 0 28
702 (
703 $is_verbose
704 ? $ctime
705 ? "INSTALLED on $ctime via"
706 : 'available from '
707 : ''
708 ),
709 ( $is_verbose ? "<$url>" : '' );
710 }
711 2 print "\n\n";
712 }
713  
714 2 return;
715 }
716  
717 0 ▶sub available_perls {
Subroutine available_perls: not called CC=1 SCAR=6.9
Pod undocumented
718 0 my ($self) = @_;
719 0 my %dists = ( %{ $self->available_perl_distributions } );
720 0 return $self->sort_perl_versions( keys %dists );
721 }
722  
723 # -> Map[ NameVersion => URL ]
724 3 ▶sub available_perl_distributions {
Subroutine available_perl_distributions: called CC=5 SCAR=16.1
Pod undocumented
725 3 my ($self) = @_;
726 3 my $perls = {};
727 3 my @perllist;
728  
729 # we got impatient waiting for cpan.org to get updated to show 5.28...
730 # So, we also fetch from metacpan for anything that looks perlish,
731 # and we do our own processing to filter out the development
732 # releases and minor versions when needed (using
733 # filter_perl_available)
734 3 ▶ my $json = http_get('https://fastapi.metacpan.org/v1/release/versions/perl')
Branch: 1 branch
BranchTrueFalseTotal
my $json = http_get("https://fastapi.metacpan.org/v1/release/versions/perl") or die "\nERROR: Unable to retrieve list of perls from Metacpan.\n\n" 1 2 3
735 or die "\nERROR: Unable to retrieve list of perls from Metacpan.\n\n";
736  
737 1 my $decoded = decode_json($json);
738 1 for my $release ( @{ $decoded->{releases} } ) {
739 next
740 250 ▶ if !$release->{authorized};
Branch: 1 branch
BranchTrueFalseTotal
unless $release->{"authorized"} 0 250 250
741 250 push @perllist, [$release->{name}, $release->{download_url}];
742 }
743 1 foreach my $perl ( $self->filter_perl_available( \@perllist ) ) {
744 11 $perls->{ $perl->[0] } = $perl->[1];
745 }
746  
747 1 return $perls;
748 }
749  
750 # $perllist is an arrayref of arrayrefs. The inner arrayrefs are of the
751 # format: [ <perl_name>, <perl_url> ]
752 # perl_name = something like perl-5.28.0
753 # perl_url = URL the Perl is available from.
754 #
755 # If $self->{all} is true, this just returns a list of the contents of
756 # the list referenced by $perllist
757 #
758 # Otherwise, this looks for even middle numbers in the version and no
759 # suffix (like -RC1) following the URL, and returns the list of
760 # arrayrefs that so match
761 #
762 # If any "newest" Perl has a
763 1 ▶sub filter_perl_available {
Subroutine filter_perl_available: called CC=6 SCAR=18.0
Pod undocumented
764 1 my ( $self, $perllist ) = @_;
765  
766 0 ▶ if ( $self->{all} ) { return @$perllist; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"all"}) 0 1 1
767  
768 1 my %max_release;
769 1 foreach my $perl (@$perllist) {
770 250 my $ver = $perl->[0];
771 250 ▶ if ( $ver !~ m/^perl-5\.[0-9]*[02468]\.[0-9]+$/ ) { next; } # most likely TRIAL or RC, or a DEV release
Branch: 1 branch
BranchTrueFalseTotal
unless ($ver =~ /^perl-5\.[0-9]*[02468]\.[0-9]+$/) 204 46 250
772  
773 46 my ( $release_line, $minor ) = $ver =~ m/^perl-5\.([0-9]+)\.([0-9]+)/;
774 46 ▶ if ( exists $max_release{$release_line} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $max_release{$release_line}) 35 11 46
775 35 ▶ if ( $max_release{$release_line}->[0] > $minor ) { next; } # We have a newer release
Branch: 1 branch
BranchTrueFalseTotal
if ($max_release{$release_line}[0] > $minor) 35 0 35
776 }
777  
778 11 $max_release{$release_line} = [$minor, $perl];
779 }
780  
781 1 return map { $_->[1] } values %max_release;
782 }
783  
784 5 ▶sub perl_release {
Subroutine perl_release: called CC=10 SCAR=24.2
Pod undocumented
785 5 my ( $self, $version ) = @_;
786 5 my $mirror = $self->cpan_mirror();
787  
788 # try CPAN::Perl::Releases
789 5 my $tarballs = CPAN::Perl::Releases::perl_tarballs($version);
790  
791 5 my $x = ( values %$tarballs )[0];
792 5 ▶ if ($x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x) 4 1 5
793 4 my $dist_tarball = ( split( "/", $x ) )[-1];
794 4 my $dist_tarball_url = "$mirror/authors/id/$x";
795 4 return ( $dist_tarball, $dist_tarball_url );
796 }
797  
798 # try src/5.0 symlinks, either perl-5.X or perl5.X; favor .tar.bz2 over .tar.gz
799 1 my $index = http_get("https://cpan.metacpan.org/src/5.0/");
800 1 ▶ if ($index) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index) 1 0 1
801 1 for my $prefix ( "perl-", "perl" ) {
802 2 for my $suffix ( ".tar.bz2", ".tar.gz" ) {
803 4 my $dist_tarball = "$prefix$version$suffix";
804 4 my $dist_tarball_url = "$mirror/src/5.0/$dist_tarball";
805 4 ▶ return ( $dist_tarball, $dist_tarball_url )
Branch: 1 branch
BranchTrueFalseTotal
if $index =~ /href\s*=\s*"\Q$dist_tarball\E"/ms 0 4 4
806 if ( $index =~ /href\s*=\s*"\Q$dist_tarball\E"/ms );
807 }
808 }
809 }
810  
811 1 my $json = http_get("https://fastapi.metacpan.org/v1/release/_search?size=1&q=name:perl-${version}");
812  
813 1 my $result;
814 1 ▶ unless ( $json and $result = decode_json($json)->{hits}{hits}[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($json and $result = decode_json($json)->{"hits"}{"hits"}[0]) 0 1 1
Condition33%1/3
$json and $result = decode_json($json)->{"hits"}{"hits"}[0]
!ll&&!rl&&r
001
MC/DC0%0/2
$json and $result = decode_json($json)->{"hits"}{"hits"}[0]
$json $result = decode_json($json)->{"hits"}{"hits"}[0]
Truth table33%1/3
A and B
A= $jsonB= $result = decode_json($json)->{"hits"}{"hits"}[0]
ABresult
0X0
100
111
815 0 die "ERROR: Failed to locate perl-${version} tarball.";
816 }
817  
818 my ( $dist_path, $dist_tarball ) =
819 1 $result->{_source}{download_url} =~ m[(/authors/id/.+/(perl-${version}.tar.(gz|bz2|xz)))$];
820 1 ▶ die "ERROR: Cannot find the tarball for perl-$version\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $dist_path or $dist_tarball 0 1 1
Condition33%1/3
$dist_path or $dist_tarball
l!l&&r!l&&!r
100
MC/DC0%0/2
$dist_path or $dist_tarball
$dist_path $dist_tarball
Truth table33%1/3
A or B
A= $dist_pathB= $dist_tarball
ABresult
1X1
011
000
821 if !$dist_path and !$dist_tarball;
822 1 my $dist_tarball_url = "https://cpan.metacpan.org${dist_path}";
823 1 return ( $dist_tarball, $dist_tarball_url );
824 }
825  
826 5 ▶sub release_detail_perl_local {
Subroutine release_detail_perl_local: called CC=5 SCAR=16.3
Pod undocumented
827 5 my ( $self, $dist, $rd ) = @_;
828 5 ▶ $rd ||= {};
Condition50%1/2
$rd ||= {}
l!l
50
MC/DC0%0/1
$rd ||= {}
$rd
Truth table50%1/2
A
A= $rd
Aresult
11
00
829 5 my $error = 1;
830 5 my $mirror = $self->cpan_mirror();
831 5 my $tarballs = CPAN::Perl::Releases::perl_tarballs( $rd->{version} );
832 5 ▶ if ( keys %$tarballs ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$tarballs) 5 0 5
833 5 for ( "tar.bz2", "tar.gz" ) {
834 5 ▶ if ( my $x = $tarballs->{$_} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $x = $tarballs->{$_}) 5 0 5
835 5 $rd->{tarball_name} = ( split( "/", $x ) )[-1];
836 5 $rd->{tarball_url} = "$mirror/authors/id/$x";
837 5 $error = 0;
838 5 last;
839 }
840 }
841 }
842 5 return ( $error, $rd );
843 }
844  
845 0 ▶sub release_detail_perl_remote {
Subroutine release_detail_perl_remote: not called CC=10 SCAR=47.0
Pod undocumented
846 0 my ( $self, $dist, $rd ) = @_;
847 0 ▶ $rd ||= {};
Condition0%0/2
$rd ||= {}
l!l
00
MC/DC0%0/1
$rd ||= {}
$rd
Truth table0%0/2
A
A= $rd
Aresult
11
00
848 0 my $error = 1;
849 0 my $mirror = $self->cpan_mirror();
850  
851 0 my $version = $rd->{version};
852  
853 # try src/5.0 symlinks, either perl-5.X or perl5.X; favor .tar.bz2 over .tar.gz
854 0 my $index = http_get("https://cpan.metacpan.org/src/5.0/");
855 0 ▶ if ($index) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index) 0 0 0
856 0 for my $prefix ( "perl-", "perl" ) {
857 0 for my $suffix ( ".tar.bz2", ".tar.gz" ) {
858 0 my $dist_tarball = "$prefix$version$suffix";
859 0 my $dist_tarball_url = "$mirror/src/5.0/$dist_tarball";
860 0 ▶ if ( $index =~ /href\s*=\s*"\Q$dist_tarball\E"/ms ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index =~ /href\s*=\s*"\Q$dist_tarball\E"/ms) 0 0 0
861 0 $rd->{tarball_url} = $dist_tarball_url;
862 0 $rd->{tarball_name} = $dist_tarball;
863 0 $error = 0;
864 0 return ( $error, $rd );
865 }
866 }
867 }
868 }
869  
870 0 my $json = http_get("https://fastapi.metacpan.org/v1/release/_search?size=1&q=name:perl-${version}");
871  
872 0 my $result;
873 0 ▶ unless ( $json and $result = decode_json($json)->{hits}{hits}[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($json and $result = decode_json($json)->{"hits"}{"hits"}[0]) 0 0 0
Condition0%0/3
$json and $result = decode_json($json)->{"hits"}{"hits"}[0]
!ll&&!rl&&r
000
MC/DC0%0/2
$json and $result = decode_json($json)->{"hits"}{"hits"}[0]
$json $result = decode_json($json)->{"hits"}{"hits"}[0]
Truth table0%0/3
A and B
A= $jsonB= $result = decode_json($json)->{"hits"}{"hits"}[0]
ABresult
0X0
100
111
874 0 die "ERROR: Failed to locate perl-${version} tarball.";
875 }
876  
877 my ( $dist_path, $dist_tarball ) =
878 0 $result->{_source}{download_url} =~ m[(/authors/id/.+/(perl-${version}.tar.(gz|bz2|xz)))$];
879 0 ▶ die "ERROR: Cannot find the tarball for perl-$version\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $dist_path or $dist_tarball 0 0 0
Condition0%0/3
$dist_path or $dist_tarball
l!l&&r!l&&!r
000
MC/DC0%0/2
$dist_path or $dist_tarball
$dist_path $dist_tarball
Truth table0%0/3
A or B
A= $dist_pathB= $dist_tarball
ABresult
1X1
011
000
880 if !$dist_path and !$dist_tarball;
881 0 my $dist_tarball_url = "https://cpan.metacpan.org${dist_path}";
882  
883 0 $rd->{tarball_name} = $dist_tarball;
884 0 $rd->{tarball_url} = $dist_tarball_url;
885 0 $error = 0;
886  
887 0 return ( $error, $rd );
888 }
889  
890 4 ▶sub release_detail {
Subroutine release_detail: called CC=7 SCAR=21.0
Pod undocumented
891 4 my ( $self, $dist ) = @_;
892 4 my ( $dist_type, $dist_version );
893  
894 4 ( $dist_type, $dist_version ) = $dist =~ /^ (?: (perl) -? )? ( [\d._]+ (?:-RC\d+)? |git|stable|blead)$/x;
895 4 ▶ $dist_type = "perl" if $dist_version && !$dist_type;
Branch: 1 branch
BranchTrueFalseTotal
if $dist_version and not $dist_type 1 3 4
Condition66%2/3
$dist_version and not $dist_type
!ll&&!rl&&r
031
MC/DC50%1/2
$dist_version and not $dist_type
$dist_version not $dist_type
Truth table66%2/3
A and not(B)
A= $dist_versionB= not $dist_type
ABresult
0X0
100
111
896  
897 4 my $rd = {
898 type => $dist_type,
899 version => $dist_version,
900 tarball_url => undef,
901 tarball_name => undef,
902 };
903  
904 # dynamic methods: release_detail_perl_local, release_detail_perl_remote
905 4 my $m_local = "release_detail_${dist_type}_local";
906 4 my $m_remote = "release_detail_${dist_type}_remote";
907  
908 4 ▶ unless ($self->can($m_local) && $self->can($m_remote)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->can($m_local) and $self->can($m_remote)) 0 4 4
Condition33%1/3
$self->can($m_local) and $self->can($m_remote)
!ll&&!rl&&r
004
MC/DC0%0/2
$self->can($m_local) and $self->can($m_remote)
$self->can($m_local) $self->can($m_remote)
Truth table33%1/3
A and B
A= $self->can($m_local)B= $self->can($m_remote)
ABresult
0X0
100
111
909 0 die "ERROR: Unknown dist type: $dist_type\n";
910 }
911  
912 4 my ($error) = $self->$m_local( $dist, $rd );
913 4 ▶ ($error) = $self->$m_remote( $dist, $rd ) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 4 4
914  
915 4 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 4 4
916 0 die "ERROR: Fail to get the tarball URL for dist: $dist\n";
917 }
918  
919 4 return $rd;
920 }
921  
922 6 ▶sub run_command_init {
Subroutine run_command_init: called CC=19 SCAR=33.2
Pod undocumented
923 6 my $self = shift;
924 6 my @args = @_;
925  
926 6 ▶ if ( @args && $args[0] eq '-' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args and $args[0] eq "-") 0 6 6
Condition33%1/3
@args and $args[0] eq "-"
!ll&&!rl&&r
600
MC/DC0%0/2
@args and $args[0] eq "-"
@args $args[0] eq "-"
Truth table33%1/3
A and B
A= @argsB= $args[0] eq "-"
ABresult
0X0
100
111
927 0 ▶ if ( $self->current_shell_is_bashish ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->current_shell_is_bashish) 0 0 0
928 0 $self->run_command_init_in_bash;
929 }
930 0 exit 0;
931 }
932  
933 6 $_->mkpath for ( grep { !-d $_ } map { $self->root->$_ } qw(perls dists build etc bin) );
934  
935 6 my ( $f, $fh ) = @_;
936  
937 6 my $etc_dir = $self->root->etc;
938  
939 6 for (
940 ["bashrc", "BASHRC_CONTENT"],
941 ["cshrc", "CSHRC_CONTENT"],
942 ["csh_reinit", "CSH_REINIT_CONTENT"],
943 ["csh_wrapper", "CSH_WRAPPER_CONTENT"],
944 ["csh_set_path", "CSH_SET_PATH_CONTENT"],
945 ["perlbrew-completion.bash", "BASH_COMPLETION_CONTENT"],
946 ["perlbrew.fish", "PERLBREW_FISH_CONTENT"],
947 )
948 {
949 42 my ( $file_name, $method ) = @$_;
950 42 my $path = $etc_dir->child($file_name);
951 42 ▶ if ( !-f $path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -f $path) { } 14 28 42
952 14 ▶ open( $fh, ">", $path )
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">", $path or die "Fail to create $path. Please check the permission of $etc_dir and try `perlbrew init` again." 14 0 14
953 or die "Fail to create $path. Please check the permission of $etc_dir and try `perlbrew init` again.";
954 14 print $fh $self->$method;
955 14 close $fh;
956 }
957 else {
958 28 ▶ if ( -w $path && open( $fh, ">", $path ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-w $path and open $fh, '>', $path) { } 28 0 28
Condition33%1/3
-w $path and open $fh, ">", $path
!ll&&!rl&&r
0028
MC/DC0%0/2
-w $path and open $fh, ">", $path
-w $path open $fh, ">", $path
Truth table33%1/3
A and B
A= -w $pathB= open $fh, ">", $path
ABresult
0X0
100
111
959 28 print $fh $self->$method;
960 28 close $fh;
961 }
962 else {
963 0 ▶ print "NOTICE: $path already exists and not updated.\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
964 }
965 }
966 }
967  
968 6 my $root_dir = $self->root->stringify_with_tilde;
969  
970 # Skip this if we are running in a shell that already 'source's perlbrew.
971 # This is true during a self-install/self-init.
972 # Ref. https://github.com/gugod/App-perlbrew/issues/525
973 6 ▶ if ( $ENV{PERLBREW_SHELLRC_VERSION} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'PERLBREW_SHELLRC_VERSION'}) { } 0 6 6
974 0 print("\nperlbrew root ($root_dir) is initialized.\n");
975 }
976 else {
977 6 my $shell = $self->current_shell;
978 6 my ( $code, $yourshrc );
979 6 ▶ if ( $shell =~ m/(t?csh)/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($shell =~ /(t?csh)/) { } 0 6 6
elsif ($shell =~ /zsh\d?$/) { } 1 5 6
elsif ($shell =~ /fish/) { } 1 4 5
980 0 $code = "source $root_dir/etc/cshrc";
981 0 $yourshrc = $1 . "rc";
982 }
983 elsif ( $shell =~ m/zsh\d?$/ ) {
984 1 $code = "source $root_dir/etc/bashrc";
985 1 ▶ $yourshrc = $self->_firstrcfile(
Condition50%1/2
$self->_firstrcfile('.zshenv', '.bash_profile', '.bash_login', '.profile') || '.zshenv'
l!l
10
MC/DC0%0/1
$self->_firstrcfile('.zshenv', '.bash_profile', '.bash_login', '.profile') || '.zshenv'
$self->_firstrcfile('.zshenv', '.bash_profile', '.bash_login', '.profile')
Truth table50%1/2
A
A= $self->_firstrcfile('.zshenv', '.bash_profile', '.bash_login', '.profile')
Aresult
11
00
986 qw(
987 .zshenv
988 .bash_profile
989 .bash_login
990 .profile
991 )
992 ) || ".zshenv";
993 }
994 elsif ( $shell =~ m/fish/ ) {
995 1 $code = ". $root_dir/etc/perlbrew.fish";
996 1 $yourshrc = '.config/fish/config.fish';
997 }
998 else {
999 4 $code = "source $root_dir/etc/bashrc";
1000 4 ▶ $yourshrc = $self->_firstrcfile(
Condition50%1/2
$self->_firstrcfile('.bash_profile', '.bash_login', '.profile') || '.bash_profile'
l!l
40
MC/DC0%0/1
$self->_firstrcfile('.bash_profile', '.bash_login', '.profile') || '.bash_profile'
$self->_firstrcfile('.bash_profile', '.bash_login', '.profile')
Truth table50%1/2
A
A= $self->_firstrcfile('.bash_profile', '.bash_login', '.profile')
Aresult
11
00
1001 qw(
1002 .bash_profile
1003 .bash_login
1004 .profile
1005 )
1006 ) || ".bash_profile";
1007 }
1008  
1009 6 ▶ if ( $self->home ne App::Perlbrew::Path->new( $self->env('HOME'), ".perlbrew" ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->home ne "App::Perlbrew::Path"->new($self->env("HOME"), ".perlbrew")) 5 1 6
1010 5 my $pb_home_dir = $self->home->stringify_with_tilde;
1011 5 ▶ if ( $shell =~ m/fish/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($shell =~ /fish/) { } 1 4 5
1012 1 $code = "set -x PERLBREW_HOME $pb_home_dir\n $code";
1013 }
1014 else {
1015 4 $code = "export PERLBREW_HOME=$pb_home_dir\n $code";
1016 }
1017 }
1018  
1019 6 print <<INSTRUCTION;
1020  
1021 perlbrew root ($root_dir) is initialized.
1022  
1023 Append the following piece of code to the end of your ~/${yourshrc} and start a
1024 new shell, perlbrew should be up and fully functional from there:
1025  
1026 $code
1027  
1028 Simply run `perlbrew` for usage details.
1029  
1030 Happy brewing!
1031  
1032 INSTRUCTION
1033 }
1034  
1035 }
1036  
1037 0 ▶sub run_command_init_in_bash {
Subroutine run_command_init_in_bash: not called CC=1 SCAR=6.9
Pod undocumented
1038 0 print BASHRC_CONTENT();
1039 }
1040  
1041 6 ▶sub run_command_self_install {
Subroutine run_command_self_install: called CC=5 SCAR=16.5
Pod undocumented
1042 6 my $self = shift;
1043  
1044 6 my $executable = $0;
1045 6 my $target = $self->root->bin("perlbrew");
1046  
1047 6 ▶ if ( files_are_the_same( $executable, $target ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (files_are_the_same($executable, $target)) 0 6 6
1048 0 print "You are already running the installed perlbrew:\n\n $executable\n";
1049 0 exit;
1050 }
1051  
1052 6 $self->root->bin->mkpath;
1053  
1054 6 open my $fh, "<", $executable;
1055  
1056 6 my $head;
1057 6 read( $fh, $head, 3, 0 );
1058  
1059 6 ▶ if ( $head eq "#!/" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($head eq '#!/') { } 6 0 6
1060 6 seek( $fh, 0, 0 );
1061 6 my @lines = <$fh>;
1062 6 close $fh;
1063  
1064 6 $lines[0] = $self->system_perl_shebang . "\n";
1065  
1066 6 open $fh, ">", $target;
1067 6 print $fh $_ for @lines;
1068 6 close $fh;
1069 }
1070 else {
1071 0 close($fh);
1072  
1073 0 copy( $executable, $target );
1074 }
1075  
1076 6 chmod( 0755, $target );
1077  
1078 6 my $path = $target->stringify_with_tilde;
1079  
1080 6 ▶ print "perlbrew is installed: $path\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 5 1 6
1081  
1082 6 $self->run_command_init();
1083 6 return;
1084 }
1085  
1086 2 ▶sub do_install_git {
Subroutine do_install_git: called CC=4 SCAR=14.2
Pod undocumented
1087 2 my ( $self, $dist ) = @_;
1088 2 my $dist_name;
1089 my $dist_git_describe;
1090 2 my $dist_version;
1091  
1092 2 opendir my $cwd_orig, ".";
1093  
1094 2 chdir $dist;
1095  
1096 2 ▶ if ( `git describe` =~ /v((5\.\d+\.\d+(?:-RC\d)?)(-\d+-\w+)?)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (`git describe` =~ /v((5\.\d+\.\d+(?:-RC\d)?)(-\d+-\w+)?)$/) 0 2 2
1097 0 $dist_name = 'perl';
1098 0 $dist_git_describe = "v$1";
1099 0 $dist_version = $2;
1100 }
1101  
1102 2 chdir $cwd_orig;
1103  
1104 2 ▶ unless ( $dist_version ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist_version) 2 0 2
1105 die "Unable to determine Perl version from 'git describe'. "
1106 . "Please use --as to specify an installation name.\n"
1107 2 ▶ unless $self->{as};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"as"} 1 1 2
1108 1 $dist_name = 'perl';
1109 1 $dist_version = 'git';
1110 }
1111  
1112 1 require File::Spec;
1113 1 my $dist_extracted_dir = File::Spec->rel2abs($dist);
1114 1 $self->do_install_this( App::Perlbrew::Path->new($dist_extracted_dir), $dist_version, "$dist_name-$dist_version" );
1115 1 return;
1116 }
1117  
1118 3 ▶sub do_install_url {
Subroutine do_install_url: called CC=5 SCAR=16.4
Pod undocumented
1119 3 my ( $self, $dist ) = @_;
1120 3 my $dist_name = 'perl';
1121  
1122 # need the period to account for the file extension
1123 3 my ($dist_version) = $dist =~ m/-([\d.]+(?:-RC\d+)?|git)\./;
1124 3 my ($dist_tarball) = $dist =~ m{/([^/]*)$};
1125  
1126 3 ▶ if ( !$dist_version && $dist =~ /blead\.tar.gz$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dist_version and $dist =~ /blead\.tar.gz$/) 2 1 3
Condition66%2/3
not $dist_version and $dist =~ /blead\.tar.gz$/
!ll&&!rl&&r
102
MC/DC50%1/2
not $dist_version and $dist =~ /blead\.tar.gz$/
not $dist_version $dist =~ /blead\.tar.gz$/
Truth table66%2/3
not(A) and B
A= not $dist_versionB= $dist =~ /blead\.tar.gz$/
ABresult
0X0
100
111
1127 2 $dist_version = "blead";
1128 }
1129  
1130 3 my $dist_tarball_path = $self->root->dists($dist_tarball);
1131 3 my $dist_tarball_url = $dist;
1132 3 $dist = "$dist_name-$dist_version"; # we install it as this name later
1133  
1134 3 ▶ if ( $dist_tarball_url =~ m/^file/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist_tarball_url =~ /^file/) { } 0 3 3
1135 0 print "Installing $dist from local archive $dist_tarball_url\n";
1136 0 $dist_tarball_url =~ s/^file:\/+/\//;
1137 0 $dist_tarball_path = $dist_tarball_url;
1138 }
1139 else {
1140 3 print "Fetching $dist as $dist_tarball_path\n";
1141 3 my $error = http_download( $dist_tarball_url, $dist_tarball_path );
1142 3 ▶ die "ERROR: Failed to download $dist_tarball_url\n$error\n" if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 2 1 3
1143 }
1144  
1145 1 my $dist_extracted_path = $self->do_extract_tarball($dist_tarball_path);
1146 1 $self->do_install_this( $dist_extracted_path, $dist_version, $dist );
1147 1 return;
1148 }
1149  
1150 1 ▶sub do_extract_tarball {
Subroutine do_extract_tarball: called CC=10 SCAR=26.5
Pod undocumented
1151 1 my ( $self, $dist_tarball ) = @_;
1152  
1153 # Assuming the dir extracted from the tarball is named after the tarball.
1154 1 my $dist_tarball_basename = $dist_tarball->basename(qr/\.tar\.(?:gz|bz2|xz)$/);
1155  
1156 1 my $workdir;
1157 1 ▶ if ( $self->{as} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'as'}) { } 0 1 1
1158  
1159 # TODO: Should we instead use the installation_name (see run_command_install()):
1160 # $destdir = $self->{as} . $self->{variation} . $self->{append};
1161 0 $workdir = $self->builddir->child( $self->{as} );
1162 }
1163 else {
1164 # Note that this is incorrect for blead.
1165 1 $workdir = $self->builddir->child($dist_tarball_basename);
1166 }
1167 1 $workdir->rmpath;
1168 1 $workdir->mkpath;
1169 1 my $extracted_dir;
1170  
1171 1 my $tarx = do {
1172 1 ▶ if ($^O eq 'cygwin') {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O eq 'cygwin') { } 0 1 1
elsif ($^O =~ /solaris|aix/) { } 0 1 1
1173 # https://github.com/gugod/App-perlbrew/issues/832
1174 # https://github.com/gugod/App-perlbrew/issues/833
1175 0 'tar --force-local -'
1176 } elsif ($^O =~ /solaris|aix/) {
1177 # On Solaris, GNU tar is installed as 'gtar' - RT #61042
1178 # https://rt.cpan.org/Ticket/Display.html?id=61042
1179 0 'gtar '
1180 } else {
1181 1 'tar '
1182 }
1183 };
1184  
1185 1 $tarx .= do {
1186 1 ▶ if ($dist_tarball =~ m/xz$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dist_tarball =~ /xz$/) { } 0 1 1
elsif ($dist_tarball =~ /bz2$/) { } 0 1 1
1187 0 'xJf'
1188 } elsif ($dist_tarball =~ m/bz2$/) {
1189 0 'xjf'
1190 } else {
1191 1 'xzf'
1192 }
1193 };
1194  
1195 1 my $extract_command = "cd $workdir; $tarx $dist_tarball";
1196 1 ▶ die "Failed to extract $dist_tarball" if system($extract_command);
Branch: 1 branch
BranchTrueFalseTotal
if system $extract_command 0 1 1
1197  
1198 1 my @things = $workdir->children;
1199 1 ▶ if ( @things == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@things == 1) 1 0 1
1200 1 $extracted_dir = App::Perlbrew::Path->new( $things[0] );
1201 }
1202  
1203 1 ▶ unless ( defined($extracted_dir) && -d $extracted_dir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $extracted_dir and -d $extracted_dir) 0 1 1
Condition33%1/3
defined $extracted_dir and -d $extracted_dir
!ll&&!rl&&r
001
MC/DC0%0/2
defined $extracted_dir and -d $extracted_dir
defined $extracted_dir -d $extracted_dir
Truth table33%1/3
A and B
A= defined $extracted_dirB= -d $extracted_dir
ABresult
0X0
100
111
1204 0 die "Failed to find the extracted directory under $workdir";
1205 }
1206  
1207 1 return $extracted_dir;
1208 }
1209  
1210 2 ▶sub do_install_blead {
Subroutine do_install_blead: called CC=2 SCAR=7.0
Pod undocumented
1211 2 my ($self) = @_;
1212  
1213 # We always blindly overwrite anything that's already there,
1214 # because blead is a moving target.
1215 2 my $dist_tarball_path = $self->root->dists("blead.tar.gz");
1216 2 ▶ unlink($dist_tarball_path) if -f $dist_tarball_path;
Branch: 1 branch
BranchTrueFalseTotal
if -f $dist_tarball_path 0 2 2
1217  
1218 2 $self->do_install_url("https://github.com/Perl/perl5/archive/blead.tar.gz");
1219 }
1220  
1221 2 ▶sub resolve_stable_version {
Subroutine resolve_stable_version: called CC=6 SCAR=17.9
Pod undocumented
1222 2 my ($self) = @_;
1223  
1224 2 my ( $latest_ver, $latest_minor );
1225 2 for my $cand ( $self->available_perls ) {
1226 11 ▶ my ( $ver, $minor ) = $cand =~ m/^perl-(5\.(6|8|[0-9]+[02468])\.[0-9]+)$/
Branch: 1 branch
BranchTrueFalseTotal
() = $cand =~ /^perl-(5\.(6|8|[0-9]+[02468])\.[0-9]+)$/ or next 9 2 11
1227 or next;
1228 9 ▶ ( $latest_ver, $latest_minor ) = ( $ver, $minor )
Branch: 1 branch
BranchTrueFalseTotal
if not defined $latest_minor or $latest_minor < $minor 3 6 9
Condition100%3/3
not defined $latest_minor or $latest_minor < $minor
l!l&&r!l&&!r
216
MC/DC100%2/2
not defined $latest_minor or $latest_minor < $minor
not defined $latest_minor $latest_minor < $minor
Truth table100%3/3
not(A) or B
A= not defined $latest_minorB= $latest_minor < $minor
ABresult
1X1
011
000
1229 if !defined $latest_minor
1230 || $latest_minor < $minor;
1231 }
1232  
1233 2 ▶ die "Can't determine latest stable Perl release\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $latest_ver 0 2 2
1234 if !defined $latest_ver;
1235  
1236 2 return $latest_ver;
1237 }
1238  
1239 1 ▶sub do_install_release {
Subroutine do_install_release: called CC=6 SCAR=22.0
Pod undocumented
1240 1 my ( $self, $dist, $dist_version ) = @_;
1241  
1242 1 my $rd = $self->release_detail($dist);
1243 1 my $dist_type = $rd->{type};
1244  
1245 1 ▶ die "\"$dist\" does not look like a perl distribution name. " unless $dist_type && $dist_version =~ /^\d\./;
Branch: 1 branch
BranchTrueFalseTotal
unless $dist_type and $dist_version =~ /^\d\./ 0 1 1
Condition33%1/3
$dist_type and $dist_version =~ /^\d\./
!ll&&!rl&&r
001
MC/DC0%0/2
$dist_type and $dist_version =~ /^\d\./
$dist_type $dist_version =~ /^\d\./
Truth table33%1/3
A and B
A= $dist_typeB= $dist_version =~ /^\d\./
ABresult
0X0
100
111
1246  
1247 1 my $dist_tarball = $rd->{tarball_name};
1248 1 my $dist_tarball_url = $rd->{tarball_url};
1249 1 my $dist_tarball_path = $self->root->dists($dist_tarball);
1250  
1251 1 ▶ if ( -f $dist_tarball_path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $dist_tarball_path) { } 0 1 1
1252 print "Using the previously fetched ${dist_tarball}\n"
1253 0 ▶ if $self->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} 0 0 0
1254 }
1255 else {
1256 1 ▶ print "Fetching perl $dist_version as $dist_tarball_path\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 1 0 1
1257 1 $self->run_command_download($dist);
1258 }
1259  
1260 0 my $dist_extracted_path = $self->do_extract_tarball($dist_tarball_path);
1261 0 $self->do_install_this( $dist_extracted_path, $dist_version, $dist );
1262 0 return;
1263 }
1264  
1265 63 ▶sub run_command_install {
Subroutine run_command_install: called CC=19 SCAR=31.7
Pod undocumented
1266 63 my ( $self, $dist, $opts ) = @_;
1267  
1268 63 ▶ unless ( $self->root->exists ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->root->exists) 1 62 63
1269 1 die( "ERROR: perlbrew root " . $self->root . " does not exist. Run `perlbrew init` to prepare it first.\n" );
1270 }
1271  
1272 62 ▶ unless ($dist) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist) 0 62 62
1273 0 $self->run_command_help("install");
1274 0 exit(-1);
1275 }
1276  
1277 62 ▶ if ( my $url = make_skaji_relocatable_perl_url($dist, $self->sys) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $url = make_skaji_relocatable_perl_url($dist, $self->sys)) 0 62 62
1278 0 return $self->run_command_install($url);
1279 }
1280  
1281 62 ▶ if ( my $detail = looks_like_url_of_skaji_relocatable_perl($dist) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $detail = looks_like_url_of_skaji_relocatable_perl($dist)) 0 62 62
1282 0 ▶ if (looks_like_sys_would_be_compatible_with_skaji_relocatable_perl($detail, $self->sys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (looks_like_sys_would_be_compatible_with_skaji_relocatable_perl($detail, $self->sys)) { } 0 0 0
1283 0 return $self->do_install_skaji_relocatable_perl($detail);
1284 } else {
1285 0 die "ERROR: The given url points to a tarball for different os/arch.\n";
1286 }
1287 }
1288  
1289 62 $self->{dist_name} = $dist; # for help msg generation, set to non
1290 # normalized name
1291  
1292 62 my ( $dist_type, $dist_version );
1293 62 ▶ if ( ( $dist_type, $dist_version ) = $dist =~ /^(?:(c?perl)-?)?([\d._]+(?:-RC\d+)?|git|stable|blead)$/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if (() = $dist =~ /^(?:(c?perl)-?)?([\d._]+(?:-RC\d+)?|git|stable|blead)$/) { } 47 15 62
elsif (-d "$dist/.git") { } 1 14 15
elsif (-f $dist) { } 13 1 14
elsif ($dist =~ /^(?:https?|ftp|file)/) { } 1 0 1
1294 47 ▶ $dist_version = $self->resolve_stable_version if $dist_version eq 'stable';
Branch: 1 branch
BranchTrueFalseTotal
if $dist_version eq "stable" 2 45 47
1295 47 ▶ $dist_type ||= "perl";
Condition100%2/2
$dist_type ||= "perl"
l!l
461
MC/DC100%1/1
$dist_type ||= "perl"
$dist_type
Truth table100%2/2
A
A= $dist_type
Aresult
11
00
1296 47 $dist = "${dist_type}-${dist_version}"; # normalize dist name
1297  
1298 47 ▶ my $installation_name = ( $self->{as} || $dist ) . $self->{variation} . $self->{append};
Condition66%2/3
$self->{'as'} || $dist
l!l&&r!l&&!r
4430
MC/DC0%0/2
$self->{'as'} || $dist
$self->{'as'} $dist
Truth table66%2/3
A || B
A= $self->{'as'}B= $dist
ABresult
1X1
011
000
1299 47 ▶ if ( not $self->{force} and $self->is_installed($installation_name) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"force"} and $self->is_installed($installation_name)) 2 45 47
Condition66%2/3
not $self->{"force"} and $self->is_installed($installation_name)
!ll&&!rl&&r
0452
MC/DC50%1/2
not $self->{"force"} and $self->is_installed($installation_name)
not $self->{"force"} $self->is_installed($installation_name)
Truth table66%2/3
not(A) and B
A= not $self->{"force"}B= $self->is_installed($installation_name)
ABresult
0X0
100
111
1300 2 die "\nABORT: $installation_name is already installed.\n\n";
1301 }
1302  
1303 45 ▶ if ( $dist_type eq 'perl' && $dist_version eq 'blead' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist_type eq 'perl' and $dist_version eq 'blead') { } 3 42 45
Condition100%3/3
$dist_type eq "perl" and $dist_version eq "blead"
!ll&&!rl&&r
1413
MC/DC100%2/2
$dist_type eq "perl" and $dist_version eq "blead"
$dist_type eq "perl" $dist_version eq "blead"
Truth table100%3/3
A and B
A= $dist_type eq "perl"B= $dist_version eq "blead"
ABresult
0X0
100
111
1304 3 $self->do_install_blead();
1305 }
1306 else {
1307 42 $self->do_install_release( $dist, $dist_version );
1308 }
1309  
1310 }
1311  
1312 # else it is some kind of special install:
1313 elsif ( -d "$dist/.git" ) {
1314 1 $self->do_install_git($dist);
1315 }
1316 elsif ( -f $dist ) {
1317 13 $self->do_install_archive( App::Perlbrew::Path->new($dist) );
1318 }
1319 elsif ( $dist =~ m/^(?:https?|ftp|file)/ ) { # more protocols needed?
1320 1 $self->do_install_url($dist);
1321 }
1322 else {
1323 0 die "Unknown installation target \"$dist\", abort.\nPlease see `perlbrew help` "
1324 . "for the instruction on using the install command.\n\n";
1325 }
1326  
1327 57 ▶ if ( $self->{switch} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"switch"}) 1 56 57
1328 1 ▶ if ( defined( my $installation_name = $self->{installation_name} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $installation_name = $self->{'installation_name'})) { } 1 0 1
1329 1 $self->switch_to($installation_name);
1330 }
1331 else {
1332 0 warn "can't switch, unable to infer final destination name.\n\n";
1333 }
1334 }
1335 57 return;
1336 }
1337  
1338 0 ▶sub check_and_calculate_variations {
Subroutine check_and_calculate_variations: not called CC=13 SCAR=52.0
Pod undocumented
1339 0 my $self = shift;
1340 0 my @both = @{ $self->{both} };
1341  
1342 0 ▶ if ( $self->{'all-variations'} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'all-variations'}) { } 0 0 0
elsif ($self->{'common-variations'}) { } 0 0 0
1343 0 @both = keys %flavor;
1344 }
1345 elsif ( $self->{'common-variations'} ) {
1346 0 push @both, grep $flavor{$_}{common}, keys %flavor;
1347 }
1348  
1349 # check the validity of the varitions given via 'both'
1350 0 for my $both (@both) {
1351 0 ▶ $flavor{$both} or die "$both is not a supported flavor.\n\n";
Branch: 1 branch
BranchTrueFalseTotal
$flavor{$both} or die "$both is not a supported flavor.\n\n" 0 0 0
1352 0 ▶ $self->{$both} and die "options --both $both and --$both can not be used together";
Branch: 1 branch
BranchTrueFalseTotal
$self->{$both} and die "options --both $both and --$both can not be used together" 0 0 0
1353 0 ▶ if ( my $implied_by = $flavor{$both}{implied_by} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $implied_by = $flavor{$both}{"implied_by"}) 0 0 0
1354 0 ▶ $self->{$implied_by} and die "options --both $both and --$implied_by can not be used together";
Branch: 1 branch
BranchTrueFalseTotal
$self->{$implied_by} and die "options --both $both and --$implied_by can not be used together" 0 0 0
1355 }
1356 }
1357  
1358 # flavors selected always
1359 0 my $start = '';
1360 0 $start .= "-$_" for grep $self->{$_}, keys %flavor;
1361  
1362 # make variations
1363 0 my @var = $start;
1364 0 for my $both (@both) {
1365 0 my $append = join( '-', $both, grep defined, $flavor{$both}{implies} );
1366 0 push @var, map "$_-$append", @var;
1367 }
1368  
1369 # normalize the variation names
1370 @var = map {
1371 0 join '-', '', sort { $flavor{$a}{ix} <=> $flavor{$b}{ix} } grep length, split /-+/, $_
1372 } @var;
1373 0 s/(\b\w+\b)(?:-\1)+/$1/g for @var; # remove duplicate flavors
1374  
1375 # After inspecting perl Configure script this seems to be the most
1376 # reliable heuristic to determine if perl would have 64bit IVs by
1377 # default or not:
1378 0 ▶ if ( $Config::Config{longsize} >= 8 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Config::Config{"longsize"} >= 8) 0 0 0
1379  
1380 # We are in a 64bit platform. 64int and 64all are always set but
1381 # we don't want them to appear on the final perl name
1382 0 s/-64\w+//g for @var;
1383 }
1384  
1385 # remove duplicated variations
1386 0 my %var = map { $_ => 1 } @var;
1387 0 sort keys %var;
1388 }
1389  
1390 0 ▶sub run_command_install_multiple {
Subroutine run_command_install_multiple: not called CC=11 SCAR=48.8
Pod undocumented
1391 0 my ( $self, @dists ) = @_;
1392  
1393 0 ▶ unless (@dists) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@dists) 0 0 0
1394 0 $self->run_command_help("install-multiple");
1395 0 exit(-1);
1396 }
1397  
1398 die "--switch can not be used with command install-multiple.\n\n"
1399 0 ▶ if $self->{switch};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"switch"} 0 0 0
1400 die "--as can not be used when more than one distribution is given.\n\n"
1401 0 ▶ if $self->{as} and @dists > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"as"} and @dists > 1 0 0 0
Condition0%0/3
$self->{"as"} and @dists > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"as"} and @dists > 1
$self->{"as"} @dists > 1
Truth table0%0/3
A and B
A= $self->{"as"}B= @dists > 1
ABresult
0X0
100
111
1402  
1403 0 my @variations = $self->check_and_calculate_variations;
1404 0 ▶ print join( "\n",
Branch: 1 branch
BranchTrueFalseTotal
/-(.*)/ ? : 0 0 0
1405 "Compiling the following distributions:",
1406 map( " $_$self->{append}", @dists ),
1407 " with the following variations:",
1408 map( ( /-(.*)/ ? " $1" : " default" ), @variations ),
1409 "", "" );
1410  
1411 0 my @ok;
1412 0 for my $dist (@dists) {
1413 0 for my $variation (@variations) {
1414 0 local $@;
1415 0 eval {
1416 0 $self->{$_} = '' for keys %flavor;
1417 0 $self->{$_} = 1 for split /-/, $variation;
1418 0 $self->{variation} = $variation;
1419 0 $self->{installation_name} = undef;
1420  
1421 0 $self->run_command_install($dist);
1422 0 push @ok, $self->{installation_name};
1423 };
1424 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1425 0 $@ =~ s/\n+$/\n/;
1426 0 print "Installation of $dist$variation failed: $@";
1427 }
1428 }
1429 }
1430  
1431 0 print join( "\n", "", "The following perls have been installed:", map ( " $_", grep defined, @ok ), "", "" );
1432 0 return;
1433 }
1434  
1435 1 ▶sub run_command_download {
Subroutine run_command_download: called CC=7 SCAR=22.0
Pod undocumented
1436 1 my ( $self, $dist ) = @_;
1437  
1438 1 ▶ $dist = $self->resolve_stable_version
Branch: 1 branch
BranchTrueFalseTotal
if $dist and $dist eq "stable" 0 1 1
Condition33%1/3
$dist and $dist eq "stable"
!ll&&!rl&&r
010
MC/DC0%0/2
$dist and $dist eq "stable"
$dist $dist eq "stable"
Truth table33%1/3
A and B
A= $distB= $dist eq "stable"
ABresult
0X0
100
111
1439 if $dist && $dist eq 'stable';
1440  
1441 1 my $rd = $self->release_detail($dist);
1442  
1443 1 my $dist_tarball = $rd->{tarball_name};
1444 1 my $dist_tarball_url = $rd->{tarball_url};
1445 1 my $dist_tarball_path = $self->root->dists($dist_tarball);
1446  
1447 1 ▶ if ( -f $dist_tarball_path && !$self->{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $dist_tarball_path and not $self->{'force'}) { } 0 1 1
Condition33%1/3
-f $dist_tarball_path and not $self->{"force"}
!ll&&!rl&&r
100
MC/DC0%0/2
-f $dist_tarball_path and not $self->{"force"}
-f $dist_tarball_path not $self->{"force"}
Truth table33%1/3
A and not(B)
A= -f $dist_tarball_pathB= not $self->{"force"}
ABresult
0X0
100
111
1448 0 print "$dist_tarball already exists\n";
1449 }
1450 else {
1451 1 ▶ print "Download $dist_tarball_url to $dist_tarball_path\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 1 0 1
1452 1 my $error = http_download( $dist_tarball_url, $dist_tarball_path );
1453 1 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 1 0 1
1454 1 die "ERROR: Failed to download $dist_tarball_url\n$error\n";
1455 }
1456 }
1457 }
1458  
1459 7 ▶sub purify {
Subroutine purify: called CC=3 SCAR=12.0
Pod undocumented
1460 7 my ( $self, $envname ) = @_;
1461 7 ▶ my @paths = grep { index( $_, $self->home ) < 0 && index( $_, $self->root ) < 0 } split /:/, $self->env($envname);
Condition33%1/3
index($_, $self->home) == -1 && index($_, $self->root) == -1
!ll&&!rl&&r
0070
MC/DC0%0/2
index($_, $self->home) == -1 && index($_, $self->root) == -1
index($_, $self->home) == -1 index($_, $self->root) == -1
Truth table33%1/3
A && B
A= index($_, $self->home) == -1B= index($_, $self->root) == -1
ABresult
0X0
100
111
1462 7 ▶ return wantarray ? @paths : join( ":", @paths );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 7 7
1463 }
1464  
1465 7 ▶sub system_perl_executable {
Subroutine system_perl_executable: called CC=1 SCAR=0.0
Pod undocumented
1466 7 my ($self) = @_;
1467  
1468 7 my $system_perl_executable = do {
1469 7 local $ENV{PATH} = $self->pristine_path;
1470 7 `perl -MConfig -e 'print \$Config{perlpath}'`;
1471 };
1472  
1473 7 return $system_perl_executable;
1474 }
1475  
1476 7 ▶sub system_perl_shebang {
Subroutine system_perl_shebang: called CC=1 SCAR=0.0
Pod undocumented
1477 7 my ($self) = @_;
1478 7 return $Config{sharpbang} . $self->system_perl_executable;
1479 }
1480  
1481 7 ▶sub pristine_path {
Subroutine pristine_path: called CC=1 SCAR=0.0
Pod undocumented
1482 7 my ($self) = @_;
1483 7 return $self->purify("PATH");
1484 }
1485  
1486 0 ▶sub pristine_manpath {
Subroutine pristine_manpath: not called CC=1 SCAR=6.9
Pod undocumented
1487 0 my ($self) = @_;
1488 0 return $self->purify("MANPATH");
1489 }
1490  
1491 0 ▶sub run_command_display_system_perl_executable {
Subroutine run_command_display_system_perl_executable: not called CC=1 SCAR=6.9
Pod undocumented
1492 0 print $_[0]->system_perl_executable . "\n";
1493 }
1494  
1495 0 ▶sub run_command_display_system_perl_shebang {
Subroutine run_command_display_system_perl_shebang: not called CC=1 SCAR=6.9
Pod undocumented
1496 0 print $_[0]->system_perl_shebang . "\n";
1497 }
1498  
1499 0 ▶sub run_command_display_pristine_path {
Subroutine run_command_display_pristine_path: not called CC=1 SCAR=6.9
Pod undocumented
1500 0 print $_[0]->pristine_path . "\n";
1501 }
1502  
1503 0 ▶sub run_command_display_pristine_manpath {
Subroutine run_command_display_pristine_manpath: not called CC=1 SCAR=6.9
Pod undocumented
1504 0 print $_[0]->pristine_manpath . "\n";
1505 }
1506  
1507 9 ▶sub do_install_archive {
Subroutine do_install_archive: called CC=4 SCAR=14.6
Pod undocumented
1508 9 require File::Basename;
1509  
1510 9 my $self = shift;
1511 9 my $dist_tarball_path = shift;
1512 9 my $dist_version;
1513 my $installation_name;
1514  
1515 9 ▶ if ( $dist_tarball_path->basename =~ m{(c?perl)-?(5.+)\.tar\.(gz|bz2|xz)\Z} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist_tarball_path->basename =~ /(c?perl)-?(5.+)\.tar\.(gz|bz2|xz)\Z/) 9 0 9
1516 9 my $perl_variant = $1;
1517 9 $dist_version = $2;
1518 9 $installation_name = "${perl_variant}-${dist_version}";
1519 }
1520  
1521 9 ▶ unless ( $dist_version && $installation_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist_version and $installation_name) 0 9 9
Condition33%1/3
$dist_version and $installation_name
!ll&&!rl&&r
009
MC/DC0%0/2
$dist_version and $installation_name
$dist_version $installation_name
Truth table33%1/3
A and B
A= $dist_versionB= $installation_name
ABresult
0X0
100
111
1522 0 die
1523 "Unable to determine perl version from archive filename.\n\nThe archive name should look like perl-5.x.y.tar.gz or perl-5.x.y.tar.bz2 or perl-5.x.y.tar.xz\n";
1524 }
1525  
1526 9 my $dist_extracted_path = $self->do_extract_tarball($dist_tarball_path);
1527  
1528 9 $self->do_install_this( $dist_extracted_path, $dist_version, $installation_name );
1529 }
1530  
1531 4 ▶sub do_install_this {
Subroutine do_install_this: called CC=44 SCAR=46.1
Pod undocumented
1532 4 my ( $self, $dist_extracted_dir, $dist_version, $installation_name ) = @_;
1533  
1534 4 my $variation = $self->{variation};
1535 4 my $append = $self->{append};
1536 4 my $looks_like_we_are_installing_cperl = $dist_extracted_dir =~ /\/ cperl- /x;
1537  
1538 4 $self->{dist_extracted_dir} = $dist_extracted_dir;
1539 4 $self->{log_file} = $self->root->child("build.${installation_name}${variation}${append}.log");
1540  
1541 4 my @d_options = @{ $self->{D} };
1542 4 my @u_options = @{ $self->{U} };
1543 4 my @a_options = @{ $self->{A} };
1544 4 my $sitecustomize = $self->{sitecustomize};
1545 4 my $destdir = $self->{destdir};
1546 4 ▶ $installation_name = $self->{as} if $self->{as};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"as"} 0 4 4
1547 4 $installation_name .= "$variation$append";
1548  
1549 4 $self->{installation_name} = $installation_name;
1550  
1551 4 ▶ if ($sitecustomize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sitecustomize) 2 2 4
1552 2 ▶ die "Could not read sitecustomize file '$sitecustomize'\n"
Branch: 1 branch
BranchTrueFalseTotal
unless -r $sitecustomize 0 2 2
1553 unless -r $sitecustomize;
1554 2 push @d_options, "usesitecustomize";
1555 }
1556  
1557 4 ▶ if ( $self->{noman} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"noman"}) 0 4 4
1558 0 push @d_options, qw/man1dir=none man3dir=none/;
1559 }
1560  
1561 4 for my $flavor ( keys %flavor ) {
1562 28 ▶ $self->{$flavor} and push @d_options, $flavor{$flavor}{d_option};
Branch: 1 branch
BranchTrueFalseTotal
$self->{$flavor} and push @d_options, $flavor{$flavor}{"d_option"} 0 28 28
1563 }
1564  
1565 4 my $perlpath = $self->root->perls($installation_name);
1566  
1567 4 unshift @d_options, qq(prefix=$perlpath);
1568 4 ▶ push @d_options, "usedevel" if $dist_version =~ /5\.\d[13579]|git|blead/;
Branch: 1 branch
BranchTrueFalseTotal
if $dist_version =~ /5\.\d[13579]|git|blead/ 0 4 4
1569  
1570 4 ▶ push @d_options, "usecperl" if $looks_like_we_are_installing_cperl;
Branch: 1 branch
BranchTrueFalseTotal
if $looks_like_we_are_installing_cperl 0 4 4
1571  
1572 4 my $version = $self->comparable_perl_version($dist_version);
1573 4 ▶ if ( defined $version and $version < $self->comparable_perl_version('5.6.0') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $version and $version < $self->comparable_perl_version('5.6.0')) { } 0 4 4
Condition33%1/3
defined $version and $version < $self->comparable_perl_version("5.6.0")
!ll&&!rl&&r
040
MC/DC0%0/2
defined $version and $version < $self->comparable_perl_version("5.6.0")
defined $version $version < $self->comparable_perl_version("5.6.0")
Truth table33%1/3
A and B
A= defined $versionB= $version < $self->comparable_perl_version("5.6.0")
ABresult
0X0
100
111
1574  
1575 # ancient perls do not support -A for Configure
1576 0 @a_options = ();
1577 }
1578 else {
1579 0 ▶ unless ( grep { /eval:scriptdir=/ } @a_options ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {/eval:scriptdir=/;} @a_options) 4 0 4
1580 4 push @a_options, "'eval:scriptdir=${perlpath}/bin'";
1581 }
1582 }
1583  
1584 4 print "Installing $dist_extracted_dir into "
1585 . $self->root->perls($installation_name)->stringify_with_tilde . "\n\n";
1586 4 ▶ print <<INSTALL if !$self->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"verbose"} 4 0 4
1587 This could take a while. You can run the following command on another shell to track the status:
1588  
1589 4 tail -f ${\ $self->{log_file}->stringify_with_tilde }
1590  
1591 INSTALL
1592  
1593 4 my @preconfigure_commands = ( "cd $dist_extracted_dir", "rm -f config.sh Policy.sh", );
1594  
1595 4 ▶ if ((not $self->{"no-patchperl"})
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"no-patchperl"} || $looks_like_we_are_installing_cperl and my $patchperl = maybe_patchperl($self->root)) 4 0 4
Condition33%2/6
not $self->{"no-patchperl"} || $looks_like_we_are_installing_cperl and my $patchperl = maybe_patchperl($self->root)
!ll&&!rl&&r
004
$self->{'no-patchperl'} || $looks_like_we_are_installing_cperl
l!l&&r!l&&!r
004
MC/DC0%0/3
not $self->{"no-patchperl"} || $looks_like_we_are_installing_cperl and my $patchperl = maybe_patchperl($self->root)
$self->{'no-patchperl'} $looks_like_we_are_installing_cperl my $patchperl = maybe_patchperl($self->root)
Truth table25%1/4
not(A || B) and C
A= $self->{'no-patchperl'}B= $looks_like_we_are_installing_cperlC= my $patchperl = maybe_patchperl($self->root)
ABCresult
1XX0
01X0
0000
0011
1596 && (not $looks_like_we_are_installing_cperl)
1597 && (my $patchperl = maybe_patchperl($self->root))) {
1598 4 push @preconfigure_commands, 'chmod -R +w .', $patchperl;
1599 }
1600  
1601 4 ▶ my $configure_flags = $self->env("PERLBREW_CONFIGURE_FLAGS") || '-de';
Condition50%1/2
$self->env('PERLBREW_CONFIGURE_FLAGS') || '-de'
l!l
04
MC/DC0%0/1
$self->env('PERLBREW_CONFIGURE_FLAGS') || '-de'
$self->env('PERLBREW_CONFIGURE_FLAGS')
Truth table50%1/2
A
A= $self->env('PERLBREW_CONFIGURE_FLAGS')
Aresult
11
00
1602  
1603 my @configure_commands = (
1604 "sh Configure $configure_flags "
1605 . join( ' ',
1606 6 ( map { qq{'-D$_'} } @d_options ),
1607 0 ( map { qq{'-U$_'} } @u_options ),
1608 4 ▶ ( map { qq{'-A$_'} } @a_options ),
Branch: 1 branch
BranchTrueFalseTotal
defined $version && $version < $self->comparable_perl_version('5.8.9') ? : 0 4 4
Condition33%1/3
defined $version and $version < $self->comparable_perl_version("5.8.9")
!ll&&!rl&&r
040
MC/DC0%0/2
defined $version and $version < $self->comparable_perl_version("5.8.9")
defined $version $version < $self->comparable_perl_version("5.8.9")
Truth table33%1/3
A and B
A= defined $versionB= $version < $self->comparable_perl_version("5.8.9")
ABresult
0X0
100
111
1609 ),
1610 ( defined $version and $version < $self->comparable_perl_version('5.8.9') )
1611 ? ("$^X -i -nle 'print unless /command-line/' makefile x2p/makefile")
1612 : ()
1613 );
1614  
1615 4 ▶ my $make = $ENV{MAKE} || ( $^O eq "solaris" ? 'gmake' : 'make' );
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'solaris' ? : 0 4 4
Condition33%1/3
$ENV{'MAKE'} || ($^O eq 'solaris' ? 'gmake' : 'make')
l!l&&r!l&&!r
040
MC/DC0%0/2
$ENV{'MAKE'} || ($^O eq 'solaris' ? 'gmake' : 'make')
$ENV{'MAKE'} ($^O eq 'solaris' ? 'gmake' : 'make')
Truth table33%1/3
A || B
A= $ENV{'MAKE'}B= ($^O eq 'solaris' ? 'gmake' : 'make')
ABresult
1X1
011
000
1616 4 ▶ my @build_commands = ( $make . ' ' . ( $self->{j} ? "-j$self->{j}" : "" ) );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'j'} ? : 0 4 4
1617  
1618 # Test via "make test_harness" if available so we'll get
1619 # automatic parallel testing via $HARNESS_OPTIONS. The
1620 # "test_harness" target was added in 5.7.3, which was the last
1621 # development release before 5.8.0.
1622 4 ▶ my $use_harness = ( $dist_version =~ /^5\.(\d+)\.(\d+)/
Condition25%3/12
$dist_version =~ /^5\.(\d+)\.(\d+)/ && ($1 >= 8 || $1 == 7 && $2 == 3) || $dist_version eq 'blead'
l!l&&r!l&&!r
400
$dist_version =~ /^5\.(\d+)\.(\d+)/ and $1 >= 8 || $1 == 7 && $2 == 3
!ll&&!rl&&r
004
$1 >= 8 or $1 == 7 and $2 == 3
l!l&&r!l&&!r
400
$1 == 7 and $2 == 3
!ll&&!rl&&r
000
MC/DC0%0/5
$dist_version =~ /^5\.(\d+)\.(\d+)/ && ($1 >= 8 || $1 == 7 && $2 == 3) || $dist_version eq 'blead'
$dist_version =~ /^5\.(\d+)\.(\d+)/ $1 >= 8 $1 == 7 $2 == 3 $dist_version eq 'blead'
Truth table12%1/8
A and B or C and D || E
A= $dist_version =~ /^5\.(\d+)\.(\d+)/B= $1 >= 8C= $1 == 7D= $2 == 3E= $dist_version eq 'blead'
ABCDEresult
11XXX1
1011X1
0XXX11
100X11
101011
0XXX00
100X00
101000
1623 && ( $1 >= 8 || $1 == 7 && $2 == 3 ) )
1624 || $dist_version eq "blead";
1625 4 ▶ my $test_target = $use_harness ? "test_harness" : "test";
Branch: 1 branch
BranchTrueFalseTotal
$use_harness ? : 4 0 4
1626  
1627 local $ENV{TEST_JOBS} = $self->{j}
1628 4 ▶ if $test_target eq "test_harness" && ( $self->{j} || 1 ) > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $test_target eq "test_harness" and ($self->{"j"} || 1) > 1 0 4 4
Condition40%2/5
$test_target eq "test_harness" and ($self->{"j"} || 1) > 1
!ll&&!rl&&r
040
$self->{'j'} || 1
l!l
04
MC/DC0%0/2
$test_target eq "test_harness" and ($self->{"j"} || 1) > 1
$test_target eq "test_harness" $self->{'j'}
Truth table33%1/3
A and B
A= $test_target eq "test_harness"B= $self->{'j'}
ABresult
0X0
100
111
1629  
1630 4 ▶ my @install_commands = ( "${make} install" . ( $destdir ? " DESTDIR=$destdir" : q|| ) );
Branch: 1 branch
BranchTrueFalseTotal
$destdir ? : 1 3 4
1631 4 ▶ unshift @install_commands, "${make} $test_target" unless $self->{notest};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"notest"} 4 0 4
1632  
1633 # Whats happening here? we optionally join with && based on $self->{force}, but then subsequently join with && anyway?
1634 4 ▶ @install_commands = join " && ", @install_commands unless ( $self->{force} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"force"} 4 0 4
1635  
1636 4 my $cmd = join " && ", ( @preconfigure_commands, @configure_commands, @build_commands, @install_commands );
1637  
1638 4 $self->{log_file}->unlink;
1639  
1640 4 ▶ if ( $self->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'verbose'}) { } 0 4 4
1641 0 $cmd = "($cmd) 2>&1 | tee $self->{log_file}";
1642 0 ▶ print "$cmd\n" if $self->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} 0 0 0
1643 }
1644 else {
1645 4 $cmd = "($cmd) >> '$self->{log_file}' 2>&1 ";
1646 }
1647  
1648 4 delete $ENV{$_} for qw(PERL5LIB PERL5OPT AWKPATH NO_COLOR);
1649  
1650 4 ▶ if ( $self->do_system($cmd) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->do_system($cmd)) { } 3 1 4
1651 3 my $newperl = $self->root->perls($installation_name)->perl;
1652 3 ▶ unless ( -e $newperl ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $newperl) 2 1 3
1653 2 $self->run_command_symlink_executables($installation_name);
1654 }
1655  
1656 3 eval { $self->append_log('##### Brew Finished #####') };
1657  
1658 3 ▶ if ($sitecustomize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sitecustomize) 2 1 3
1659 2 my $capture = $self->do_capture("$newperl -V:sitelib");
1660 2 my ($sitelib) = $capture =~ m/sitelib='([^']*)';/;
1661 2 ▶ $sitelib = $destdir . $sitelib if $destdir;
Branch: 1 branch
BranchTrueFalseTotal
if $destdir 1 1 2
1662 2 $sitelib = App::Perlbrew::Path->new($sitelib);
1663 2 $sitelib->mkpath;
1664 2 my $target = $sitelib->child("sitecustomize.pl");
1665 2 ▶ open my $dst, ">", $target
Branch: 1 branch
BranchTrueFalseTotal
open my $dst, ">", $target or die "Could not open '${target}' for writing: $!\n" 2 0 2
1666 or die "Could not open '$target' for writing: $!\n";
1667 2 ▶ open my $src, "<", $sitecustomize
Branch: 1 branch
BranchTrueFalseTotal
open my $src, "<", $sitecustomize or die "Could not open '${sitecustomize}' for reading: $!\n" 2 0 2
1668 or die "Could not open '$sitecustomize' for reading: $!\n";
1669 2 print {$dst} do { local $/; <$src> };
1670 }
1671  
1672 3 my $version_file = $self->root->perls($installation_name)->version_file;
1673  
1674 3 ▶ if ( -e $version_file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $version_file) 0 3 3
1675 0 ▶ $version_file->unlink()
Branch: 1 branch
BranchTrueFalseTotal
$version_file->unlink or die "Could not unlink $version_file file: $!\n" 0 0 0
1676 or die "Could not unlink $version_file file: $!\n";
1677 }
1678  
1679 3 print "$installation_name is successfully installed.\n";
1680 }
1681 else {
1682 1 eval { $self->append_log('##### Brew Failed #####') };
1683 1 die $self->INSTALLATION_FAILURE_MESSAGE;
1684 }
1685 3 return;
1686 }
1687  
1688 0 ▶sub do_install_skaji_relocatable_perl {
Subroutine do_install_skaji_relocatable_perl: not called CC=5 SCAR=34.0
Pod undocumented
1689 0 my ($self, $detail) = @_;
1690  
1691 0 ▶ my $installation_name = $self->{as} || ("skaji-relocatable-perl-" . $detail->{version});
Condition0%0/2
$self->{'as'} || 'skaji-relocatable-perl-' . $detail->{'version'}
l!l
00
MC/DC0%0/1
$self->{'as'} || 'skaji-relocatable-perl-' . $detail->{'version'}
$self->{'as'}
Truth table0%0/2
A
A= $self->{'as'}
Aresult
11
00
1692 0 my $installation_path = $self->root->perls->child($installation_name);
1693  
1694 0 ▶ die "ERROR: Installation target \"${installation_name}\" already exists\n"
Branch: 1 branch
BranchTrueFalseTotal
if $installation_path->exists 0 0 0
1695 if $installation_path->exists;
1696  
1697 my $path = $self->root->dists
1698 ->child("skaji-relocatable-perl")
1699 ->child($detail->{version})
1700 ->mkpath()
1701 0 ->child($detail->{original_filename});
1702  
1703 0 ▶ if (-f $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $path) { } 0 0 0
1704 0 print "Re-using the downloaded $path\n";
1705 } else {
1706 0 my $url = $detail->{url};
1707 0 print "Downloading $url as $path\n";
1708 0 my $error = http_download( $detail->{url}, $path );
1709 0 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
1710 0 die "Failed to download from $url\nError: $error";
1711 }
1712 }
1713  
1714 0 my $extracted_path = $self->do_extract_skaji_relocatable_perl_tarball($detail, $path);
1715  
1716 0 move $extracted_path, $installation_path;
1717  
1718 0 print "$installation_name is installed at $installation_path.\n";
1719  
1720 0 print "$installation_name is successfully installed.\n";
1721 }
1722  
1723 0 ▶sub do_extract_skaji_relocatable_perl_tarball {
Subroutine do_extract_skaji_relocatable_perl_tarball: not called CC=3 SCAR=24.8
Pod undocumented
1724 0 my ($self, $detail, $tarball_path) = @_;
1725  
1726 my $workdir = $self->builddir
1727 ->child("skaji-relocatable-perl")
1728 0 ->child($detail->{version});
1729  
1730 0 ▶ $workdir->rmpath()
Branch: 1 branch
BranchTrueFalseTotal
if $workdir->exists 0 0 0
1731 if $workdir->exists();
1732  
1733 0 $workdir->mkpath();
1734  
1735 0 my $tarx = "tar xzf";
1736 0 my $extract_command = "cd $workdir; $tarx $tarball_path";
1737  
1738 0 ▶ system($extract_command) == 0
Branch: 1 branch
BranchTrueFalseTotal
system($extract_command) == 0 or die "Failed to extract $tarball_path" 0 0 0
1739 or die "Failed to extract $tarball_path";
1740  
1741 0 my ($extracted_path) = $workdir->children;
1742  
1743 0 return $extracted_path;
1744 }
1745  
1746 8 ▶sub do_install_program_from_url {
Subroutine do_install_program_from_url: called CC=14 SCAR=30.6
Pod undocumented
1747 8 my ( $self, $url, $program_name, $body_filter ) = @_;
1748  
1749 8 my $out = $self->root->bin($program_name);
1750  
1751 8 ▶ if ( -f $out && !$self->{force} && !$self->{yes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $out and not $self->{"force"} and not $self->{"yes"}) 0 8 8
Condition33%2/6
-f $out and not $self->{"force"} and not $self->{"yes"}
!ll&&!rl&&r
800
-f $out and not $self->{"force"}
!ll&&!rl&&r
800
MC/DC0%0/3
-f $out and not $self->{"force"} and not $self->{"yes"}
-f $out not $self->{"force"} not $self->{"yes"}
Truth table25%1/4
A and not(B) and not(C)
A= -f $outB= not $self->{"force"}C= not $self->{"yes"}
ABCresult
0XX0
10X0
1100
1111
1752 0 my $ans = prompt( "\n$out already exists, are you sure to override ? [y/N]", "N" );
1753  
1754 0 ▶ if ( $ans !~ /^Y/i ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ans =~ /^Y/i) 0 0 0
1755 0 ▶ print "\n$program_name installation skipped.\n\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
1756 0 return;
1757 }
1758 }
1759  
1760 8 ▶ my $body = http_get($url)
Branch: 1 branch
BranchTrueFalseTotal
my $body = http_get($url) or die "\nERROR: Failed to retrieve $program_name executable.\n\n" 6 2 8
1761 or die "\nERROR: Failed to retrieve $program_name executable.\n\n";
1762  
1763 6 ▶ unless ( $body =~ m{\A#!/}s ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body =~ m[\A#!/]s) 3 3 6
1764 3 ▶ my $x = App::Perlbrew::Path->new( $self->env('TMPDIR') || "/tmp", "${program_name}.downloaded.$$" );
Condition50%1/2
$self->env('TMPDIR') || '/tmp'
l!l
03
MC/DC0%0/1
$self->env('TMPDIR') || '/tmp'
$self->env('TMPDIR')
Truth table50%1/2
A
A= $self->env('TMPDIR')
Aresult
11
00
1765 3 my $message =
1766 "\nERROR: The downloaded $program_name program seem to be invalid. Please check if the following URL can be reached correctly\n\n\t$url\n\n...and try again latter.";
1767  
1768 3 ▶ unless ( -f $x ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $x) 3 0 3
1769 3 open my $OUT, ">", $x;
1770 3 print $OUT $body;
1771 3 close($OUT);
1772 3 $message .= "\n\nThe previously downloaded file is saved at $x for manual inspection.\n\n";
1773 }
1774  
1775 3 die $message;
1776 }
1777  
1778 3 ▶ if ( $body_filter && ref($body_filter) eq "CODE" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($body_filter and ref $body_filter eq "CODE") 1 2 3
Condition66%2/3
$body_filter and ref $body_filter eq "CODE"
!ll&&!rl&&r
201
MC/DC50%1/2
$body_filter and ref $body_filter eq "CODE"
$body_filter ref $body_filter eq "CODE"
Truth table66%2/3
A and B
A= $body_filterB= ref $body_filter eq "CODE"
ABresult
0X0
100
111
1779 1 $body = $body_filter->($body);
1780 }
1781  
1782 3 $self->root->bin->mkpath;
1783 3 ▶ open my $OUT, '>', $out or die "cannot open file($out): $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $OUT, ">", $out or die "cannot open file($out): $!" 3 0 3
1784 3 print $OUT $body;
1785 3 close $OUT;
1786 3 chmod 0755, $out;
1787 3 ▶ print "\n$program_name is installed to\n\n $out\n\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 3 3
1788 }
1789  
1790 0 ▶sub do_exit_with_error_code {
Subroutine do_exit_with_error_code: not called CC=1 SCAR=6.9
Pod undocumented
1791 0 my ( $self, $code ) = @_;
1792 0 exit($code);
1793 }
1794  
1795 4 ▶sub do_system_with_exit_code {
Subroutine do_system_with_exit_code: called CC=1 SCAR=0.0
Pod undocumented
1796 4 my ( $self, @cmd ) = @_;
1797 4 return system(@cmd);
1798 }
1799  
1800 4 ▶sub do_system {
Subroutine do_system: called CC=1 SCAR=0.0
Pod undocumented
1801 4 my ( $self, @cmd ) = @_;
1802 4 return !$self->do_system_with_exit_code(@cmd);
1803 }
1804  
1805 4 ▶sub do_capture {
Subroutine do_capture: called CC=1 SCAR=0.0
Pod undocumented
1806 4 my ( $self, @cmd ) = @_;
1807 return Capture::Tiny::capture(
1808 4 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1809 4 $self->do_system(@cmd);
1810 }
1811 4 );
1812 }
1813  
1814 2 ▶sub do_capture_current_perl {
Subroutine do_capture_current_perl: called CC=1 SCAR=0.0
Pod undocumented
1815 2 my ( $self, @cmd ) = @_;
1816 2 return $self->do_capture(
1817 $self->installed_perl_executable( $self->current_perl ),
1818 @cmd,
1819 );
1820 }
1821  
1822 478 ▶sub format_perl_version {
Subroutine format_perl_version: called CC=2 SCAR=6.9
Pod undocumented
1823 478 my $self = shift;
1824 478 my $version = shift;
1825 478 ▶ return sprintf "%d.%d.%d", substr( $version, 0, 1 ), substr( $version, 2, 3 ), substr( $version, 5 ) || 0;
Condition100%2/2
substr($version, 5) || 0
l!l
4771
MC/DC100%1/1
substr($version, 5) || 0
substr($version, 5)
Truth table100%2/2
A
A= substr($version, 5)
Aresult
11
00
1826 }
1827  
1828 178 ▶sub installed_perls {
Subroutine installed_perls: called CC=11 SCAR=25.1
Pod undocumented
1829 178 my $self = shift;
1830  
1831 178 my @result;
1832 178 my $root = $self->root;
1833  
1834 178 for my $installation ( $root->perls->list ) {
1835 474 my $name = $installation->name;
1836 474 my $executable = $installation->perl;
1837 474 ▶ next unless -f $executable;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $executable 0 474 474
1838  
1839 474 my $version_file = $installation->version_file;
1840 474 my $ctime = localtime( ( stat $executable )[10] ); # localtime in scalar context!
1841  
1842 474 my $orig_version;
1843 474 ▶ if ( -e $version_file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $version_file) { } 439 35 474
1844 439 open my $fh, '<', $version_file;
1845 439 local $/;
1846 439 $orig_version = <$fh>;
1847 439 chomp $orig_version;
1848 }
1849 else {
1850 35 $orig_version = `$executable -e 'print \$]'`;
1851 35 ▶ if ( defined $orig_version and length $orig_version ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $orig_version and length $orig_version) 35 0 35
Condition33%1/3
defined $orig_version and length $orig_version
!ll&&!rl&&r
0035
MC/DC0%0/2
defined $orig_version and length $orig_version
defined $orig_version length $orig_version
Truth table33%1/3
A and B
A= defined $orig_versionB= length $orig_version
ABresult
0X0
100
111
1852 35 ▶ if ( open my $fh, '>', $version_file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, ">", $version_file) 35 0 35
1853 35 print {$fh} $orig_version;
1854 }
1855 }
1856 }
1857  
1858 474 ▶ push @result,
Condition100%3/3
$self->current_perl eq $name && !$self->current_lib
!ll&&!rl&&r
429342
MC/DC100%2/2
$self->current_perl eq $name && !$self->current_lib
$self->current_perl eq $name !$self->current_lib
Truth table100%3/3
A && not(B)
A= $self->current_perl eq $nameB= !$self->current_lib
ABresult
0X0
100
111
1859 {
1860 name => $name,
1861 orig_version => $orig_version,
1862 version => $self->format_perl_version($orig_version),
1863 is_current => ( $self->current_perl eq $name ) && !( $self->current_lib ),
1864 libs => [$self->local_libs($name)],
1865 executable => $executable,
1866 dir => $installation,
1867 comparable_version => $self->comparable_perl_version($orig_version),
1868 ctime => $ctime,
1869 };
1870 }
1871  
1872 return sort {
1873 178 (
1874 $self->{reverse}
1875 ? ( $a->{comparable_version} <=> $b->{comparable_version} or $b->{name} cmp $a->{name} )
1876 : ( $b->{comparable_version} <=> $a->{comparable_version} or $a->{name} cmp $b->{name} )
1877 416 ▶ )
Branch: 1 branch
BranchTrueFalseTotal
$self->{'reverse'} ? : 0 416 416
Condition33%2/6
$App::perlbrew::a->{"comparable_version"} <=> $App::perlbrew::b->{"comparable_version"} or $App::perlbrew::b->{"name"} cmp $App::perlbrew::a->{"name"}
l!l&&r!l&&!r
000
$App::perlbrew::b->{"comparable_version"} <=> $App::perlbrew::a->{"comparable_version"} or $App::perlbrew::a->{"name"} cmp $App::perlbrew::b->{"name"}
l!l&&r!l&&!r
403130
MC/DC0%0/2
$App::perlbrew::a->{"comparable_version"} <=> $App::perlbrew::b->{"comparable_version"} or $App::perlbrew::b->{"name"} cmp $App::perlbrew::a->{"name"}
$App::perlbrew::a->{"comparable_version"} <=> $App::perlbrew::b->{"comparable_version"} $App::perlbrew::b->{"name"} cmp $App::perlbrew::a->{"name"}
MC/DC0%0/2
$App::perlbrew::b->{"comparable_version"} <=> $App::perlbrew::a->{"comparable_version"} or $App::perlbrew::a->{"name"} cmp $App::perlbrew::b->{"name"}
$App::perlbrew::b->{"comparable_version"} <=> $App::perlbrew::a->{"comparable_version"} $App::perlbrew::a->{"name"} cmp $App::perlbrew::b->{"name"}
Truth table0%0/3
A or B
A= $App::perlbrew::a->{"comparable_version"} <=> $App::perlbrew::b->{"comparable_version"}B= $App::perlbrew::b->{"name"} cmp $App::perlbrew::a->{"name"}
ABresult
1X1
011
000
Truth table66%2/3
A or B
A= $App::perlbrew::b->{"comparable_version"} <=> $App::perlbrew::a->{"comparable_version"}B= $App::perlbrew::a->{"name"} cmp $App::perlbrew::b->{"name"}
ABresult
1X1
011
000
1878 } @result;
1879 }
1880  
1881 8 ▶sub compose_locallib {
Subroutine compose_locallib: called CC=1 SCAR=0.0
Pod undocumented
1882 8 my ( $self, $perl_name, $lib_name ) = @_;
1883 8 return join '@', $perl_name, $lib_name;
1884 }
1885  
1886 124 ▶sub decompose_locallib {
Subroutine decompose_locallib: called CC=1 SCAR=0.0
Pod undocumented
1887 124 my ( $self, $name ) = @_;
1888 124 return split '@', $name;
1889 }
1890  
1891 9 ▶sub enforce_localib {
Subroutine enforce_localib: called CC=2 SCAR=6.9
Pod undocumented
1892 9 my ( $self, $name ) = @_;
1893 9 ▶ $name =~ s/^/@/ unless $name =~ m/@/;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /@/ 5 4 9
1894 9 return $name;
1895 }
1896  
1897 476 ▶sub local_libs {
Subroutine local_libs: called CC=2 SCAR=6.9
Pod undocumented
1898 476 my ( $self, $perl_name ) = @_;
1899  
1900 476 my $current = $self->current_env;
1901 my @libs = map {
1902 476 my $name = $_->basename;
1903 39 my ( $p, $l ) = $self->decompose_locallib($name);
1904 +{
1905 39 name => $name,
1906 is_current => $name eq $current,
1907 perl_name => $p,
1908 lib_name => $l,
1909 dir => $_,
1910 }
1911 } $self->home->child("libs")->children;
1912 476 ▶ if ($perl_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perl_name) 476 0 476
1913 476 @libs = grep { $perl_name eq $_->{perl_name} } @libs;
1914 }
1915 476 return @libs;
1916 }
1917  
1918 139 ▶sub is_installed {
Subroutine is_installed: called CC=1 SCAR=0.0
Pod undocumented
1919 139 my ( $self, $name ) = @_;
1920  
1921 139 return grep { $name eq $_->{name} } $self->installed_perls;
1922 }
1923  
1924 0 ▶sub assert_known_installation {
Subroutine assert_known_installation: not called CC=2 SCAR=17.9
Pod undocumented
1925 0 my ( $self, $name ) = @_;
1926 0 ▶ return 1 if $self->is_installed($name);
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_installed($name) 0 0 0
1927 0 die "ERROR: The installation \"$name\" is unknown\n\n";
1928 }
1929  
1930 # Return a hash of PERLBREW_* variables
1931 38 ▶sub perlbrew_env {
Subroutine perlbrew_env: called CC=18 SCAR=29.5
Pod undocumented
1932 38 my ( $self, $name ) = @_;
1933 38 my ( $perl_name, $lib_name );
1934  
1935 38 ▶ if ($name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) 37 1 38
1936 37 ( $perl_name, $lib_name ) = $self->resolve_installation_name($name);
1937  
1938 37 ▶ unless ($perl_name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($perl_name) 0 37 37
1939 0 die "\nERROR: The installation \"$name\" is unknown.\n\n";
1940 }
1941  
1942 37 ▶ unless ( !$lib_name || grep { $_->{lib_name} eq $lib_name } $self->local_libs($perl_name) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not $lib_name or grep {$_->{"lib_name"} eq $lib_name;} $self->local_libs($perl_name)) 0 37 37
Condition66%2/3
not $lib_name or grep {$_->{"lib_name"} eq $lib_name;} $self->local_libs($perl_name)
l!l&&r!l&&!r
3520
MC/DC0%0/2
not $lib_name or grep {$_->{"lib_name"} eq $lib_name;} $self->local_libs($perl_name)
not $lib_name grep {$_->{"lib_name"} eq $lib_name;} $self->local_libs($perl_name)
Truth table66%2/3
not(A) or B
A= not $lib_nameB= grep {$_->{"lib_name"} eq $lib_name;} $self->local_libs($perl_name)
ABresult
1X1
011
000
1943 0 die "\nERROR: The lib name \"$lib_name\" is unknown.\n\n";
1944 }
1945 }
1946  
1947 38 my %env = (
1948 PERLBREW_VERSION => $VERSION,
1949 PERLBREW_PATH => $self->root->bin,
1950 PERLBREW_MANPATH => "",
1951 PERLBREW_ROOT => $self->root
1952 );
1953  
1954 38 require local::lib;
1955 38 my $pb_home = $self->home;
1956 38 ▶ my $current_local_lib_root = $self->env("PERL_LOCAL_LIB_ROOT") || "";
Condition50%1/2
$self->env('PERL_LOCAL_LIB_ROOT') || ''
l!l
038
MC/DC0%0/1
$self->env('PERL_LOCAL_LIB_ROOT') || ''
$self->env('PERL_LOCAL_LIB_ROOT')
Truth table50%1/2
A
A= $self->env('PERL_LOCAL_LIB_ROOT')
Aresult
11
00
1957 38 my $current_local_lib_context = local::lib->new;
1958 0 my @perlbrew_local_lib_root = uniq( grep { /\Q${pb_home}\E/ } split( /:/, $current_local_lib_root ) );
1959 38 ▶ if ( $current_local_lib_root =~ /^\Q${pb_home}\E/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_local_lib_root =~ /^\Q$pb_home\E/) 0 38 38
1960 0 $current_local_lib_context = $current_local_lib_context->activate($_) for @perlbrew_local_lib_root;
1961 }
1962  
1963 38 ▶ if ($perl_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perl_name) { } 37 1 38
1964 37 my $installation = $self->root->perls($perl_name);
1965 37 ▶ if ( -d $installation->child("bin") ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $installation->child("bin")) 37 0 37
1966 37 $env{PERLBREW_PERL} = $perl_name;
1967 37 $env{PERLBREW_PATH} .= ":" . $installation->child("bin");
1968 37 $env{PERLBREW_MANPATH} = $installation->child("man");
1969 }
1970  
1971 37 ▶ if ($lib_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lib_name) { } 2 35 37
1972 2 $current_local_lib_context = $current_local_lib_context->deactivate($_) for @perlbrew_local_lib_root;
1973  
1974 2 my $base = $self->home->child( "libs", "${perl_name}\@${lib_name}" );
1975  
1976 2 ▶ if ( -d $base ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $base) 2 0 2
1977 2 $current_local_lib_context = $current_local_lib_context->activate($base);
1978  
1979 2 ▶ if ( $self->env('PERLBREW_LIB_PREFIX') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->env("PERLBREW_LIB_PREFIX")) 1 1 2
1980 unshift
1981 1 @{ $current_local_lib_context->libs },
1982 $self->env('PERLBREW_LIB_PREFIX');
1983 }
1984  
1985 2 $env{PERLBREW_PATH} = $base->child("bin") . ":" . $env{PERLBREW_PATH};
1986 2 $env{PERLBREW_MANPATH} = $base->child("man") . ":" . $env{PERLBREW_MANPATH};
1987 2 $env{PERLBREW_LIB} = $lib_name;
1988 }
1989 }
1990 else {
1991 35 $current_local_lib_context = $current_local_lib_context->deactivate($_) for @perlbrew_local_lib_root;
1992 35 $env{PERLBREW_LIB} = undef;
1993 }
1994  
1995 37 my %ll_env = $current_local_lib_context->build_environment_vars;
1996 37 delete $ll_env{PATH};
1997 37 for my $key ( keys %ll_env ) {
1998 78 $env{$key} = $ll_env{$key};
1999 }
2000 }
2001 else {
2002 1 $current_local_lib_context = $current_local_lib_context->deactivate($_) for @perlbrew_local_lib_root;
2003  
2004 1 my %ll_env = $current_local_lib_context->build_environment_vars;
2005 1 delete $ll_env{PATH};
2006 1 for my $key ( keys %ll_env ) {
2007 2 $env{$key} = $ll_env{$key};
2008 }
2009 1 $env{PERLBREW_LIB} = undef;
2010 1 $env{PERLBREW_PERL} = undef;
2011 }
2012  
2013 38 return %env;
2014 }
2015  
2016 5 ▶sub run_command_list {
Subroutine run_command_list: called CC=11 SCAR=24.4
Pod undocumented
2017 5 my $self = shift;
2018 5 my $is_verbose = $self->{verbose};
2019  
2020 5 ▶ if ( $self->{'no-decoration'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'no-decoration'}) { } 2 3 5
2021 2 for my $i ( $self->installed_perls ) {
2022 8 print $i->{name} . "\n";
2023 8 for my $lib ( @{ $i->{libs} } ) {
2024 2 print $lib->{name} . "\n";
2025 }
2026 }
2027 }
2028 else {
2029 3 for my $i ( $self->installed_perls ) {
2030 printf "%-2s%-20s %-20s %s\n", $i->{is_current} ? '*' : '', $i->{name},
2031 (
2032 $is_verbose
2033 12 ▶ ? ( index( $i->{name}, $i->{version} ) < 0 )
Branch: 4 branches
BranchTrueFalseTotal
$i->{'is_current'} ? : 1 11 12
$is_verbose ? : 0 12 12
(index($i->{'name'}, $i->{'version'}) == -1) ? : 0 0 0
$is_verbose ? : 0 12 12
2034 ? "($i->{version})"
2035 : ''
2036 : ''
2037 ),
2038 ( $is_verbose ? "(installed on $i->{ctime})" : '' );
2039  
2040 12 for my $lib ( @{ $i->{libs} } ) {
2041 4 ▶ print $lib->{is_current} ? "* " : " ", $lib->{name}, "\n";
Branch: 1 branch
BranchTrueFalseTotal
$lib->{'is_current'} ? : 2 2 4
2042 }
2043 }
2044 }
2045  
2046 5 return 0;
2047 }
2048  
2049 0 ▶sub launch_sub_shell {
Subroutine launch_sub_shell: not called CC=7 SCAR=38.1
Pod undocumented
2050 0 my ( $self, $name ) = @_;
2051 0 my $shell = $self->env('SHELL');
2052  
2053 0 my $shell_opt = "";
2054  
2055 0 ▶ if ( $shell =~ /\/zsh\d?$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($shell =~ m[/zsh\d?$]) 0 0 0
2056 0 $shell_opt = "-d -f";
2057  
2058 0 ▶ if ( $^O eq 'darwin' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "darwin") 0 0 0
2059 0 my $root_dir = $self->root;
2060 0 print <<"WARNINGONMAC";
2061 --------------------------------------------------------------------------------
2062 WARNING: zsh perlbrew sub-shell is not working on Mac OSX Lion.
2063  
2064 It is known that on MacOS Lion, zsh always resets the value of PATH on launching
2065 a sub-shell. Effectively nullify the changes required by perlbrew sub-shell. You
2066 may `echo \$PATH` to examine it and if you see perlbrew related paths are in the
2067 end, instead of in the beginning, you are unfortunate.
2068  
2069 You are advised to include the following line to your ~/.zshenv as a better
2070 way to work with perlbrew:
2071  
2072 source $root_dir/etc/bashrc
2073  
2074 --------------------------------------------------------------------------------
2075 WARNINGONMAC
2076  
2077 }
2078 }
2079  
2080 0 my %env = ( $self->perlbrew_env($name), PERLBREW_SKIP_INIT => 1 );
2081  
2082 0 ▶ unless ( $ENV{PERLBREW_VERSION} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"PERLBREW_VERSION"}) 0 0 0
2083 0 my $root = $self->root;
2084  
2085 # The user does not source bashrc/csh in their shell initialization.
2086 0 $env{PATH} = $env{PERLBREW_PATH} . ":" . join ":", grep { !/$root\/bin/ } split ":", $ENV{PATH};
2087 $env{MANPATH} = $env{PERLBREW_MANPATH} . ":" . join ":",
2088 0 ▶ grep { !/$root\/man/ } ( defined( $ENV{MANPATH} ) ? split( ":", $ENV{MANPATH} ) : () );
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{'MANPATH'} ? : 0 0 0
2089 }
2090  
2091 0 my $command = "env ";
2092 0 ▶ while ( my ( $k, $v ) = each(%env) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %env) 0 0 0
2093 70 ▶ no warnings "uninitialized";
Subroutine BEGIN: called CC=1 SCAR=0.0
2094 0 $command .= "$k=\"$v\" ";
2095 }
2096 0 $command .= " $shell $shell_opt";
2097  
2098 0 ▶ my $pretty_name = defined($name) ? $name : "the default perl";
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 0 0
2099 0 print "\nA sub-shell is launched with $pretty_name as the activated perl. Run 'exit' to finish it.\n\n";
2100 0 exec($command);
2101 }
2102  
2103 0 ▶sub run_command_use {
Subroutine run_command_use: not called CC=3 SCAR=24.8
Pod undocumented
2104 0 my $self = shift;
2105 0 my $perl = shift;
2106  
2107 0 ▶ if ( !$perl ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($perl) 0 0 0
2108 0 my $current = $self->current_env;
2109 0 ▶ if ($current) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current) { } 0 0 0
2110 0 print "Currently using $current\n";
2111 }
2112 else {
2113 0 print "No version in use; defaulting to system\n";
2114 }
2115 0 return;
2116 }
2117  
2118 0 $self->launch_sub_shell($perl);
2119  
2120 }
2121  
2122 0 ▶sub run_command_switch {
Subroutine run_command_switch: not called CC=3 SCAR=24.8
Pod undocumented
2123 0 my ( $self, $dist, $alias ) = @_;
2124  
2125 0 ▶ unless ($dist) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist) 0 0 0
2126 0 my $current = $self->current_env;
2127 0 ▶ printf "Currently switched %s\n", ( $current ? "to $current" : 'off' );
Branch: 1 branch
BranchTrueFalseTotal
$current ? : 0 0 0
2128 0 return;
2129 }
2130  
2131 0 $self->switch_to( $dist, $alias );
2132 }
2133  
2134 0 ▶sub switch_to {
Subroutine switch_to: not called CC=6 SCAR=37.4
Pod undocumented
2135 0 my ( $self, $dist, $alias ) = @_;
2136  
2137 0 ▶ die "Cannot use for alias something that starts with 'perl-'\n"
Branch: 1 branch
BranchTrueFalseTotal
if $alias and $alias =~ /^perl-/ 0 0 0
Condition0%0/3
$alias and $alias =~ /^perl-/
!ll&&!rl&&r
000
MC/DC0%0/2
$alias and $alias =~ /^perl-/
$alias $alias =~ /^perl-/
Truth table0%0/3
A and B
A= $aliasB= $alias =~ /^perl-/
ABresult
0X0
100
111
2138 if $alias && $alias =~ /^perl-/;
2139  
2140 0 ▶ die "${dist} is not installed\n" unless -d $self->root->perls($dist);
Branch: 1 branch
BranchTrueFalseTotal
unless -d $self->root->perls($dist) 0 0 0
2141  
2142 0 ▶ if ( $self->env("PERLBREW_SHELLRC_VERSION") && $self->current_shell_is_bashish ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->env('PERLBREW_SHELLRC_VERSION') and $self->current_shell_is_bashish) { } 0 0 0
Condition0%0/3
$self->env("PERLBREW_SHELLRC_VERSION") and $self->current_shell_is_bashish
!ll&&!rl&&r
000
MC/DC0%0/2
$self->env("PERLBREW_SHELLRC_VERSION") and $self->current_shell_is_bashish
$self->env("PERLBREW_SHELLRC_VERSION") $self->current_shell_is_bashish
Truth table0%0/3
A and B
A= $self->env("PERLBREW_SHELLRC_VERSION")B= $self->current_shell_is_bashish
ABresult
0X0
100
111
2143 0 local $ENV{PERLBREW_PERL} = $dist;
2144 0 my $HOME = $self->env('HOME');
2145 0 my $pb_home = $self->home;
2146  
2147 0 $pb_home->mkpath;
2148 0 system( "$0 env $dist > " . $pb_home->child("init") );
2149  
2150 0 print "Switched to $dist.\n\n";
2151 }
2152 else {
2153 0 $self->launch_sub_shell($dist);
2154 }
2155 }
2156  
2157 0 ▶sub run_command_off {
Subroutine run_command_off: not called CC=1 SCAR=6.9
Pod undocumented
2158 0 my $self = shift;
2159 0 $self->launch_sub_shell;
2160 }
2161  
2162 0 ▶sub run_command_switch_off {
Subroutine run_command_switch_off: not called CC=1 SCAR=6.9
Pod undocumented
2163 0 my $self = shift;
2164 0 my $pb_home = $self->home;
2165  
2166 0 $pb_home->mkpath;
2167 0 system( "env PERLBREW_PERL= $0 env > " . $pb_home->child("init") );
2168  
2169 0 print "\nperlbrew is switched off. Please exit this shell and start a new one to make it effective.\n";
2170 0 print
2171 0 "To immediately make it effective, run this line in this terminal:\n\n exec @{[ $self->env('SHELL') ]}\n\n";
2172 }
2173  
2174 7 ▶sub shell_env {
Subroutine shell_env: called CC=9 SCAR=22.0
Pod undocumented
2175 7 my ( $self, $env ) = @_;
2176 7 my %env = %$env;
2177  
2178 7 my @statements;
2179 7 for my $k ( sort keys %env ) {
2180 46 my $v = $env{$k};
2181 46 ▶ if ( defined($v) && $v ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v and $v ne '') { } 39 7 46
Condition100%3/3
defined $v and $v ne ""
!ll&&!rl&&r
3439
MC/DC100%2/2
defined $v and $v ne ""
defined $v $v ne ""
Truth table100%3/3
A and B
A= defined $vB= $v ne ""
ABresult
0X0
100
111
2182 39 $v =~ s/(\\")/\\$1/g;
2183 39 push @statements, ["set", $k, $v];
2184 }
2185 else {
2186 7 push @statements, ["unset", $k];
2187 }
2188 }
2189  
2190 7 my $statements = "";
2191  
2192 7 ▶ if ( $self->env('SHELL') =~ /(ba|k|z|\/)sh\d?$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->env('SHELL') =~ m[(ba|k|z|/)sh\d?$]) { } 3 4 7
2193 3 for (@statements) {
2194 28 my ( $o, $k, $v ) = @$_;
2195 28 ▶ if ( $o eq 'unset' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o eq 'unset') { } 3 25 28
2196 3 $statements .= "unset $k\n";
2197 }
2198 else {
2199 25 $v =~ s/(\\")/\\$1/g;
2200 25 $statements .= "export $k=\"$v\"\n";
2201 }
2202 }
2203 }
2204 else {
2205 4 for (@statements) {
2206 18 my ( $o, $k, $v ) = @$_;
2207 18 ▶ if ( $o eq 'unset' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o eq 'unset') { } 4 14 18
2208 4 $statements .= "unsetenv $k\n";
2209 }
2210 else {
2211 14 $statements .= "setenv $k \"$v\"\n";
2212 }
2213 }
2214 }
2215  
2216 7 return $statements;
2217 }
2218  
2219 3 ▶sub run_command_env {
Subroutine run_command_env: called CC=1 SCAR=0.0
Pod undocumented
2220 3 my ( $self, $name ) = @_;
2221  
2222 3 print $self->shell_env({ $self->perlbrew_env($name) });
2223 }
2224  
2225 2 ▶sub run_command_symlink_executables {
Subroutine run_command_symlink_executables: called CC=7 SCAR=32.1
Pod undocumented
2226 2 my ( $self, @perls ) = @_;
2227 2 my $root = $self->root;
2228  
2229 2 ▶ unless (@perls) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@perls) 0 2 2
2230 0 ▶ @perls = map { $_->name } grep { -d $_ && !-l $_ } $root->perls->list;
Condition0%0/3
-d $_ && !(-l $_)
!ll&&!rl&&r
000
MC/DC0%0/2
-d $_ && !(-l $_)
-d $_ !(-l $_)
Truth table0%0/3
A && not(B)
A= -d $_B= !(-l $_)
ABresult
0X0
100
111
2231 }
2232  
2233 2 for my $perl (@perls) {
2234 2 for my $executable ( $root->perls($perl)->bin->children ) {
2235 0 my ( $name, $version ) = $executable =~ m/bin\/(.+?)(5\.\d.*)?$/;
2236 0 ▶ next unless $version;
Branch: 1 branch
BranchTrueFalseTotal
unless $version 0 0 0
2237  
2238 0 $executable->symlink( $root->perls($perl)->bin($name) );
2239 0 ▶ $executable->symlink( $root->perls($perl)->perl ) if $name eq "cperl";
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "cperl" 0 0 0
2240 }
2241 }
2242 }
2243  
2244 2 ▶sub run_command_install_patchperl {
Subroutine run_command_install_patchperl: called CC=1 SCAR=0.0
Pod undocumented
2245 2 my ($self) = @_;
2246 $self->do_install_program_from_url(
2247 'https://raw.githubusercontent.com/gugod/patchperl-packing/6094dd0c9eb3ed5cfab195a7f40f5791cf65ebd2/patchperl',
2248 'patchperl',
2249 1 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
2250 1 my ($body) = @_;
2251 1 $body =~ s/\A#!.+?\n/ $self->system_perl_shebang . "\n" /se;
2252 1 return $body;
2253 }
2254 2 );
2255 }
2256  
2257 3 ▶sub run_command_install_cpanm {
Subroutine run_command_install_cpanm: called CC=1 SCAR=0.0
Pod undocumented
2258 3 my ($self) = @_;
2259 3 $self->do_install_program_from_url(
2260 'https://raw.githubusercontent.com/miyagawa/cpanminus/99cef089c7fc3188a19822f594515dbd5295b855/cpanm',
2261 'cpanm'
2262 )
2263 }
2264  
2265 3 ▶sub run_command_install_cpm {
Subroutine run_command_install_cpm: called CC=1 SCAR=0.0
Pod undocumented
2266 3 my ($self) = @_;
2267 3 $self->do_install_program_from_url(
2268 'https://raw.githubusercontent.com/skaji/cpm/bcd4a1072bea4b21f8424eca574b81f627ccd18b/cpm',
2269 'cpm'
2270 );
2271 }
2272  
2273 0 ▶sub run_command_self_upgrade {
Subroutine run_command_self_upgrade: not called CC=7 SCAR=40.3
Pod undocumented
2274 0 my ($self) = @_;
2275  
2276 0 require FindBin;
2277 0 ▶ unless ( -w $FindBin::Bin ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-w $FindBin::Bin) 0 0 0
2278 0 die "Your perlbrew installation appears to be system-wide. Please upgrade through your package manager.\n";
2279 }
2280  
2281 0 ▶ my $TMPDIR = $ENV{TMPDIR} || "/tmp";
Condition0%0/2
$ENV{'TMPDIR'} || '/tmp'
l!l
00
MC/DC0%0/1
$ENV{'TMPDIR'} || '/tmp'
$ENV{'TMPDIR'}
Truth table0%0/2
A
A= $ENV{'TMPDIR'}
Aresult
11
00
2282 0 my $TMP_PERLBREW = App::Perlbrew::Path->new( $TMPDIR, "perlbrew" );
2283  
2284 0 http_download( 'https://raw.githubusercontent.com/gugod/App-perlbrew/master/perlbrew', $TMP_PERLBREW );
2285  
2286 0 chmod 0755, $TMP_PERLBREW;
2287 0 my $new_version = qx($TMP_PERLBREW version);
2288 0 chomp $new_version;
2289 0 ▶ if ( $new_version =~ /App::perlbrew\/(\d+\.\d+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_version =~ m[App::perlbrew/(\d+\.\d+)$]) { } 0 0 0
2290 0 $new_version = $1;
2291 }
2292 else {
2293 0 $TMP_PERLBREW->unlink;
2294 0 die "Unable to detect version of new perlbrew!\n";
2295 }
2296  
2297 0 ▶ if ( $new_version <= $VERSION ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_version <= $App::perlbrew::VERSION) 0 0 0
2298 0 ▶ print "Your perlbrew is up-to-date (version $VERSION).\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
2299 0 $TMP_PERLBREW->unlink;
2300 0 return;
2301 }
2302  
2303 0 ▶ print "Upgrading from $VERSION to $new_version\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
2304  
2305 0 system $TMP_PERLBREW, "self-install";
2306 0 $TMP_PERLBREW->unlink;
2307 }
2308  
2309 0 ▶sub run_command_uninstall {
Subroutine run_command_uninstall: not called CC=10 SCAR=47.0
Pod undocumented
2310 0 my ( $self, $target ) = @_;
2311  
2312 0 ▶ unless ($target) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target) 0 0 0
2313 0 $self->run_command_help("uninstall");
2314 0 exit(-1);
2315 }
2316  
2317 0 my @installed = $self->installed_perls(@_);
2318  
2319 0 my ($to_delete) = grep { $_->{name} eq $target } @installed;
2320  
2321 0 ▶ die "'$target' is not installed\n" unless $to_delete;
Branch: 1 branch
BranchTrueFalseTotal
unless $to_delete 0 0 0
2322  
2323 0 my @dir_to_delete;
2324 0 for ( @{ $to_delete->{libs} } ) {
2325 0 push @dir_to_delete, $_->{dir};
2326 }
2327 0 push @dir_to_delete, $to_delete->{dir};
2328  
2329 0 ▶ my $ans = ( $self->{yes} ) ? "Y" : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'yes'} ? : 0 0 0
2330 0 ▶ if ( !defined($ans) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ans) 0 0 0
2331 0 $ans = prompt(
2332 "\nThe following perl+lib installation(s) will be deleted:\n\n\t"
2333 . join( "\n\t", @dir_to_delete )
2334 . "\n\n... are you sure ? [y/N]",
2335 "N"
2336 );
2337 }
2338  
2339 0 ▶ if ( $ans =~ /^Y/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ans =~ /^Y/i) { } 0 0 0
2340 0 for (@dir_to_delete) {
2341 0 ▶ print "Deleting: $_\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
2342 0 App::Perlbrew::Path->new($_)->rmpath;
2343 0 ▶ print "Deleted: $_\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
2344 }
2345 }
2346 else {
2347 0 print "\nOK. Not deleting anything.\n\n";
2348 0 return;
2349 }
2350 }
2351  
2352 17 ▶sub run_command_exec {
Subroutine run_command_exec: called CC=25 SCAR=32.3
Pod undocumented
2353 17 my $self = shift;
2354 17 my %opts;
2355  
2356 17 local (@ARGV) = @{ $self->{original_argv} };
2357  
2358 17 Getopt::Long::Configure( 'require_order', 'nopass_through' );
2359 17 my @command_options = ( 'with=s', 'halt-on-error', 'min=s', 'max=s' );
2360  
2361 17 $self->parse_cmdline( \%opts, @command_options );
2362 17 shift @ARGV; # "exec"
2363 17 $self->parse_cmdline( \%opts, @command_options );
2364  
2365 17 my @exec_with;
2366 17 ▶ if ( $opts{with} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'with'}) { } 14 3 17
2367 14 my %installed = map { $_->{name} => $_ } map { ( $_, @{ $_->{libs} } ) } $self->installed_perls;
2368  
2369 14 ▶ my $d = ( $opts{with} =~ m/ / ) ? qr( +) : qr(,+);
Branch: 1 branch
BranchTrueFalseTotal
$opts{'with'} =~ / / ? : 6 8 14
2370 21 my @with = grep { $_ } map {
2371 21 my ( $p, $l ) = $self->resolve_installation_name($_);
2372 21 ▶ $p .= "\@$l" if $l;
Branch: 1 branch
BranchTrueFalseTotal
if $l 0 21 21
2373 21 $p;
2374 14 } split $d, $opts{with};
2375  
2376 14 @exec_with = map { $installed{$_} } @with;
2377 }
2378 else {
2379 @exec_with = grep {
2380 12 not -l $self->root->perls( $_->{name} ); # Skip Aliases
2381 3 } map { ( $_, @{ $_->{libs} } ) } $self->installed_perls;
2382 }
2383  
2384 17 ▶ if ( $opts{min} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"min"}) 1 16 17
2385  
2386 # TODO use comparable version.
2387 # For now, it doesn't produce consistent results for 5.026001 and 5.26.1
2388 1 @exec_with = grep { $_->{orig_version} >= $opts{min} } @exec_with;
2389 }
2390  
2391 17 ▶ if ( $opts{max} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"max"}) 1 16 17
2392 1 @exec_with = grep { $_->{orig_version} <= $opts{max} } @exec_with;
2393 }
2394  
2395 17 ▶ if ( 0 == @exec_with ) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 == @exec_with) 0 17 17
2396 0 ▶ print "No perl installation found.\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
2397 }
2398  
2399 17 my $no_header = 0;
2400 17 ▶ if ( 1 == @exec_with ) {
Branch: 1 branch
BranchTrueFalseTotal
if (1 == @exec_with) 9 8 17
2401 9 $no_header = 1;
2402 }
2403  
2404 17 my $overall_success = 1;
2405 17 for my $i (@exec_with) {
2406 28 my %env = $self->perlbrew_env( $i->{name} );
2407 28 ▶ next if !$env{PERLBREW_PERL};
Branch: 1 branch
BranchTrueFalseTotal
unless $env{"PERLBREW_PERL"} 0 28 28
2408  
2409 28 local %ENV = %ENV;
2410 28 ▶ $ENV{$_} = defined $env{$_} ? $env{$_} : '' for keys %env;
Branch: 1 branch
BranchTrueFalseTotal
defined $env{$_} ? : 196 28 224
2411 28 $ENV{PATH} = join( ':', $env{PERLBREW_PATH}, $ENV{PATH} );
2412 28 ▶ $ENV{MANPATH} = join( ':', $env{PERLBREW_MANPATH}, $ENV{MANPATH} || "" );
Condition50%1/2
$ENV{'MANPATH'} || ''
l!l
028
MC/DC0%0/1
$ENV{'MANPATH'} || ''
$ENV{'MANPATH'}
Truth table50%1/2
A
A= $ENV{'MANPATH'}
Aresult
11
00
2413 28 ▶ $ENV{PERL5LIB} = $env{PERL5LIB} || "";
Condition50%1/2
$env{'PERL5LIB'} || ''
l!l
280
MC/DC0%0/1
$env{'PERL5LIB'} || ''
$env{'PERL5LIB'}
Truth table50%1/2
A
A= $env{'PERL5LIB'}
Aresult
11
00
2414  
2415 28 ▶ print "$i->{name}\n==========\n" unless $no_header || $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $no_header or $self->{"quiet"} 19 9 28
Condition66%2/3
$no_header or $self->{"quiet"}
l!l&&r!l&&!r
9019
MC/DC50%1/2
$no_header or $self->{"quiet"}
$no_header $self->{"quiet"}
Truth table66%2/3
A or B
A= $no_headerB= $self->{"quiet"}
ABresult
1X1
011
000
2416  
2417 28 ▶ if ( my $err = $self->do_system_with_exit_code(@ARGV) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $err = $self->do_system_with_exit_code(@ARGV)) 8 20 28
2418 8 my $exit_code = $err >> 8;
2419  
2420 # return 255 for case when process was terminated with signal, in that case real exit code is useless and weird
2421 8 ▶ $exit_code = 255 if $exit_code > 255;
Branch: 1 branch
BranchTrueFalseTotal
if $exit_code > 255 1 7 8
2422 8 $overall_success = 0;
2423  
2424 8 ▶ unless ( $self->{quiet} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"quiet"}) 7 1 8
2425 7 print "Command terminated with non-zero status.\n";
2426  
2427 print STDERR "Command ["
2428 7 ▶ . join( ' ', map { /\s/ ? "'$_'" : $_ } @ARGV )
Branch: 1 branch
BranchTrueFalseTotal
/\s/ ? : 7 14 21
2429 . # trying reverse shell escapes - quote arguments containing spaces
2430 "] terminated with exit code $exit_code (\$? = $err) under the following perl environment:\n";
2431 7 print STDERR $self->format_info_output;
2432 }
2433  
2434 8 ▶ $self->do_exit_with_error_code($exit_code) if ( $opts{'halt-on-error'} );
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"halt-on-error"} 3 5 8
2435 }
2436 25 ▶ print "\n" unless $self->{quiet} || $no_header;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} or $no_header 18 7 25
Condition100%3/3
$self->{"quiet"} or $no_header
l!l&&r!l&&!r
1618
MC/DC100%2/2
$self->{"quiet"} or $no_header
$self->{"quiet"} $no_header
Truth table100%3/3
A or B
A= $self->{"quiet"}B= $no_header
ABresult
1X1
011
000
2437 }
2438 14 ▶ $self->do_exit_with_error_code(1) unless $overall_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $overall_success 5 9 14
2439 }
2440  
2441 0 ▶sub run_command_clean {
Subroutine run_command_clean: not called CC=3 SCAR=24.8
Pod undocumented
2442 0 my ($self) = @_;
2443 0 my $root = $self->root;
2444 0 my @build_dirs = $root->build->children;
2445  
2446 0 for my $dir (@build_dirs) {
2447 0 print "Removing $dir\n";
2448 0 App::Perlbrew::Path->new($dir)->rmpath;
2449 }
2450  
2451 0 my @tarballs = $root->dists->children;
2452 0 for my $file (@tarballs) {
2453 0 print "Removing $file\n";
2454 0 $file->unlink;
2455 }
2456  
2457 0 print "\nDone\n";
2458 }
2459  
2460 1 ▶sub run_command_alias {
Subroutine run_command_alias: called CC=17 SCAR=48.5
Pod undocumented
2461 1 my ( $self, $cmd, $name, $alias ) = @_;
2462  
2463 1 ▶ unless ($cmd) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cmd) 0 1 1
2464 0 $self->run_command_help("alias");
2465 0 exit(-1);
2466 }
2467  
2468 1 ▶ my $path_name = $self->root->perls($name) if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 1 1
2469 1 ▶ my $path_alias = $self->root->perls($alias) if $alias;
Branch: 1 branch
BranchTrueFalseTotal
if $alias 0 1 1
2470  
2471 1 ▶ if ( $alias && -e $path_alias && !-l $path_alias ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alias and -e $path_alias and not -l $path_alias) 0 1 1
Condition33%2/6
$alias and -e $path_alias and not -l $path_alias
!ll&&!rl&&r
100
$alias and -e $path_alias
!ll&&!rl&&r
100
MC/DC0%0/3
$alias and -e $path_alias and not -l $path_alias
$alias -e $path_alias not -l $path_alias
Truth table25%1/4
A and B and not(C)
A= $aliasB= -e $path_aliasC= not -l $path_alias
ABCresult
0XX0
10X0
1100
1111
2472 0 die "\nABORT: The installation name `$alias` is not an alias, cannot override.\n\n";
2473 }
2474  
2475 1 ▶ if ( $cmd eq 'create' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($cmd eq 'create') { } 0 1 1
elsif ($cmd eq 'delete') { } 0 1 1
elsif ($cmd eq 'rename') { } 0 1 1
elsif ($cmd eq 'help') { } 0 1 1
2476 0 $self->assert_known_installation($name);
2477  
2478 0 ▶ if ( $self->is_installed($alias) && !$self->{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_installed($alias) and not $self->{"force"}) 0 0 0
Condition0%0/3
$self->is_installed($alias) and not $self->{"force"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->is_installed($alias) and not $self->{"force"}
$self->is_installed($alias) not $self->{"force"}
Truth table0%0/3
A and not(B)
A= $self->is_installed($alias)B= not $self->{"force"}
ABresult
0X0
100
111
2479 0 die "\nABORT: The installation `${alias}` already exists. Cannot override.\n\n";
2480 }
2481  
2482 0 $path_alias->unlink;
2483 0 $path_name->symlink($path_alias);
2484 }
2485 elsif ( $cmd eq 'delete' ) {
2486 0 $self->assert_known_installation($name);
2487  
2488 0 ▶ unless ( -l $path_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-l $path_name) 0 0 0
2489 0 die "\nABORT: The installation name `$name` is not an alias, cannot remove.\n\n";
2490 }
2491  
2492 0 $path_name->unlink;
2493 }
2494 elsif ( $cmd eq 'rename' ) {
2495 0 $self->assert_known_installation($name);
2496  
2497 0 ▶ unless ( -l $path_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-l $path_name) 0 0 0
2498 0 die "\nABORT: The installation name `$name` is not an alias, cannot rename.\n\n";
2499 }
2500  
2501 0 ▶ if ( -l $path_alias && !$self->{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-l $path_alias and not $self->{"force"}) 0 0 0
Condition0%0/3
-l $path_alias and not $self->{"force"}
!ll&&!rl&&r
000
MC/DC0%0/2
-l $path_alias and not $self->{"force"}
-l $path_alias not $self->{"force"}
Truth table0%0/3
A and not(B)
A= -l $path_aliasB= not $self->{"force"}
ABresult
0X0
100
111
2502 0 die "\nABORT: The alias `$alias` already exists, cannot rename to it.\n\n";
2503 }
2504  
2505 0 rename( $path_name, $path_alias );
2506 }
2507 elsif ( $cmd eq 'help' ) {
2508 0 $self->run_command_help("alias");
2509 }
2510 else {
2511 1 die "\nERROR: Unrecognized action: `${cmd}`.\n\n";
2512 }
2513 }
2514  
2515 0 ▶sub run_command_display_bashrc {
Subroutine run_command_display_bashrc: not called CC=1 SCAR=6.9
Pod undocumented
2516 0 print BASHRC_CONTENT();
2517 }
2518  
2519 0 ▶sub run_command_display_cshrc {
Subroutine run_command_display_cshrc: not called CC=1 SCAR=6.9
Pod undocumented
2520 0 print CSHRC_CONTENT();
2521 }
2522  
2523 0 ▶sub run_command_display_installation_failure_message {
Subroutine run_command_display_installation_failure_message: not called CC=1 SCAR=6.9
Pod undocumented
2524 0 my ($self) = @_;
2525 }
2526  
2527 12 ▶sub run_command_lib {
Subroutine run_command_lib: called CC=3 SCAR=11.4
Pod undocumented
2528 12 my ( $self, $subcommand, @args ) = @_;
2529  
2530 12 ▶ unless ($subcommand) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($subcommand) 0 12 12
2531 0 $self->run_command_help("lib");
2532 0 exit(-1);
2533 }
2534  
2535 12 my $sub = "run_command_lib_$subcommand";
2536 12 ▶ if ( $self->can($sub) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($sub)) { } 11 1 12
2537 11 $self->$sub(@args);
2538 }
2539 else {
2540 1 print "Unknown command: $subcommand\n";
2541 }
2542 }
2543  
2544 8 ▶sub run_command_lib_create {
Subroutine run_command_lib_create: called CC=5 SCAR=16.2
Pod undocumented
2545 8 my ( $self, $name ) = @_;
2546  
2547 8 ▶ die "ERROR: No lib name\n", $self->run_command_help( "lib", undef, 'return_text' ) unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 1 7 8
2548  
2549 7 $name = $self->enforce_localib($name);
2550  
2551 7 my ( $perl_name, $lib_name ) = $self->resolve_installation_name($name);
2552  
2553 7 ▶ if ( !$perl_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($perl_name) 1 6 7
2554 1 my ( $perl_name, $lib_name ) = $self->decompose_locallib($name);
2555 1 die "ERROR: '$perl_name' is not installed yet, '$name' cannot be created.\n";
2556 }
2557  
2558 6 my $fullname = $self->compose_locallib( $perl_name, $lib_name );
2559 6 my $dir = $self->home->child( "libs", $fullname );
2560  
2561 6 ▶ if ( -d $dir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $dir) 0 6 6
2562 0 die "$fullname is already there.\n";
2563 }
2564  
2565 6 $dir->mkpath;
2566  
2567 6 ▶ print "lib '$fullname' is created.\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 6 0 6
2568  
2569 6 return;
2570 }
2571  
2572 3 ▶sub run_command_lib_delete {
Subroutine run_command_lib_delete: called CC=5 SCAR=16.2
Pod undocumented
2573 3 my ( $self, $name ) = @_;
2574  
2575 3 ▶ die "ERROR: No lib to delete\n", $self->run_command_help( "lib", undef, 'return_text' ) unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 1 2 3
2576  
2577 2 $name = $self->enforce_localib($name);
2578  
2579 2 my ( $perl_name, $lib_name ) = $self->resolve_installation_name($name);
2580  
2581 2 my $fullname = $self->compose_locallib( $perl_name, $lib_name );
2582  
2583 2 my $current = $self->current_env;
2584  
2585 2 my $dir = $self->home->child( "libs", $fullname );
2586  
2587 2 ▶ if ( -d $dir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $dir) { } 1 1 2
2588  
2589 1 ▶ if ( $fullname eq $current ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fullname eq $current) 0 1 1
2590 0 die "$fullname is currently being used in the current shell, it cannot be deleted.\n";
2591 }
2592  
2593 1 $dir->rmpath;
2594  
2595 print "lib '$fullname' is deleted.\n"
2596 1 ▶ unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 1 0 1
2597 }
2598 else {
2599 1 die "ERROR: '$fullname' does not exist.\n";
2600 }
2601  
2602 1 return;
2603 }
2604  
2605 0 ▶sub run_command_lib_list {
Subroutine run_command_lib_list: not called CC=6 SCAR=37.4
Pod undocumented
2606 0 my ($self) = @_;
2607 0 my $dir = $self->home->child("libs");
2608 0 ▶ return unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 0 0
2609  
2610 0 ▶ opendir my $dh, $dir or die "open $dir failed: $!";
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $dir or die "open $dir failed: $!" 0 0 0
2611 0 ▶ my @libs = grep { !/^\./ && /\@/ } readdir($dh);
Condition0%0/3
!/^\./ && /\@/
!ll&&!rl&&r
000
MC/DC0%0/2
!/^\./ && /\@/
!/^\./ /\@/
Truth table0%0/3
not(A) && B
A= !/^\./B= /\@/
ABresult
0X0
100
111
2612  
2613 0 my $current = $self->current_env;
2614 0 for (@libs) {
2615 0 ▶ print $current eq $_ ? "* " : " ";
Branch: 1 branch
BranchTrueFalseTotal
$current eq $_ ? : 0 0 0
2616 0 print "$_\n";
2617 }
2618 }
2619  
2620 0 ▶sub run_command_upgrade_perl {
Subroutine run_command_upgrade_perl: not called CC=10 SCAR=47.0
Pod undocumented
2621 0 my ($self) = @_;
2622  
2623 0 my $PERL_VERSION_RE = qr/(\d+)\.(\d+)\.(\d+)/;
2624  
2625 0 my ($current) = grep { $_->{is_current} } $self->installed_perls;
2626  
2627 0 ▶ unless ( defined $current ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $current) 0 0 0
2628 0 print "no perlbrew environment is currently in use\n";
2629 0 exit(1);
2630 }
2631  
2632 0 my ( $major, $minor, $release );
2633  
2634 0 ▶ if ( $current->{version} =~ /^$PERL_VERSION_RE$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current->{'version'} =~ /^$PERL_VERSION_RE$/) { } 0 0 0
2635 0 ( $major, $minor, $release ) = ( $1, $2, $3 );
2636 }
2637 else {
2638 0 print "unable to parse version '$current->{version}'\n";
2639 0 exit(1);
2640 }
2641  
2642 0 my @available = grep { /^perl-$major\.$minor/ } $self->available_perls;
2643  
2644 0 my $latest_available_perl = $release;
2645  
2646 0 foreach my $perl (@available) {
2647 0 ▶ if ( $perl =~ /^perl-$PERL_VERSION_RE$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perl =~ /^perl-$PERL_VERSION_RE$/) 0 0 0
2648 0 my $this_release = $3;
2649 0 ▶ if ( $this_release > $latest_available_perl ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this_release > $latest_available_perl) 0 0 0
2650 0 $latest_available_perl = $this_release;
2651 }
2652 }
2653 }
2654  
2655 0 ▶ if ( $latest_available_perl == $release ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($latest_available_perl == $release) 0 0 0
2656 0 print "This perlbrew environment ($current->{name}) is already up-to-date.\n";
2657 0 exit(0);
2658 }
2659  
2660 0 my $dist_version = "$major.$minor.$latest_available_perl";
2661 0 my $dist = "perl-$dist_version";
2662  
2663 0 ▶ print "Upgrading $current->{name} to $dist_version\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
2664 0 local $self->{as} = $current->{name};
2665 0 local $self->{dist_name} = $dist;
2666  
2667 0 my @d_options = map { '-D' . $flavor{$_}->{d_option} } keys %flavor;
2668 0 my %sub_config = map { $_ => $Config{$_} } grep { /^config_arg\d/ } keys %Config;
2669 0 for my $value ( values %sub_config ) {
2670 0 my $value_wo_D = $value;
2671 0 $value_wo_D =~ s/^-D//;
2672 0 ▶ push @{ $self->{D} }, $value_wo_D if grep { /$value/ } @d_options;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/$value/;} @d_options 0 0 0
2673 }
2674  
2675 0 $self->do_install_release( $dist, $dist_version );
2676 }
2677  
2678 1 ▶sub list_modules {
Subroutine list_modules: called CC=6 SCAR=24.5
Pod undocumented
2679 1 my ( $self, $env ) = @_;
2680  
2681 1 ▶ $env ||= $self->current_env;
Condition33%1/3
$env ||= $self->current_env
l!l&&r!l&&!r
010
MC/DC0%0/2
$env ||= $self->current_env
$env $self->current_env
Truth table33%1/3
A ||= B
A= $envB= $self->current_env
ABresult
1X1
011
000
2682 my ( $stdout, $stderr, $success ) = Capture::Tiny::capture(
2683 1 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
2684 1 __PACKAGE__->new( "--quiet", "exec", "--with", $env, 'perl', '-MExtUtils::Installed', '-le',
2685 'BEGIN{@INC=grep {$_ ne q!.!} @INC}; print for ExtUtils::Installed->new->modules;',
2686 )->run;
2687 }
2688 1 );
2689  
2690 1 ▶ unless ($success) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($success) 0 1 1
2691 0 ▶ unless ( $self->{quiet} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"quiet"}) 0 0 0
2692 0 print STDERR "Failed to retrive the list of installed modules.\n";
2693 0 ▶ if ( $self->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verbose"}) 0 0 0
2694 0 print STDERR "STDOUT\n======\n$stdout\nSTDERR\n======\n$stderr\n";
2695 }
2696 }
2697 0 return [];
2698 }
2699  
2700 1 my %rename = (
2701 "ack" => "App::Ack",
2702 "libwww::perl" => "LWP",
2703 "libintl-perl" => "Locale::Messages",
2704 "Role::Identifiable" => "Role::Identifiable::HasTags",
2705 "TAP::Harness::Multiple" => "TAP::Harness::ReportByDescription",
2706 );
2707  
2708 1 ▶ return [map { $rename{$_} || $_ } grep { $_ ne "Perl" } split( /\n/, $stdout )];
Condition33%1/3
$rename{$_} || $_
l!l&&r!l&&!r
010
MC/DC0%0/2
$rename{$_} || $_
$rename{$_} $_
Truth table33%1/3
A || B
A= $rename{$_}B= $_
ABresult
1X1
011
000
2709 }
2710  
2711 0 ▶sub run_command_list_modules {
Subroutine run_command_list_modules: not called CC=2 SCAR=17.9
Pod undocumented
2712 0 my ($self) = @_;
2713 0 my ( $modules, $error ) = $self->list_modules();
2714 0 print "$_\n" for @$modules;
2715 }
2716  
2717 85 ▶sub resolve_installation_name {
Subroutine resolve_installation_name: called CC=7 SCAR=19.5
Pod undocumented
2718 85 my ( $self, $name ) = @_;
2719 85 ▶ die "App::perlbrew->resolve_installation_name requires one argument." unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 1 84 85
2720  
2721 84 my ( $perl_name, $lib_name ) = $self->decompose_locallib($name);
2722 84 ▶ $perl_name = $name unless $lib_name;
Branch: 1 branch
BranchTrueFalseTotal
unless $lib_name 71 13 84
2723 84 ▶ $perl_name ||= $self->current_perl;
Condition66%2/3
$perl_name ||= $self->current_perl
l!l&&r!l&&!r
7770
MC/DC0%0/2
$perl_name ||= $self->current_perl
$perl_name $self->current_perl
Truth table66%2/3
A ||= B
A= $perl_nameB= $self->current_perl
ABresult
1X1
011
000
2724  
2725 84 ▶ if ( !$self->is_installed($perl_name) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_installed($perl_name)) 6 78 84
2726 6 ▶ if ( $self->is_installed("perl-${perl_name}") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_installed("perl-$perl_name")) { } 3 3 6
2727 3 $perl_name = "perl-${perl_name}";
2728 }
2729 else {
2730 3 return undef;
2731 }
2732 }
2733  
2734 81 ▶ return wantarray ? ( $perl_name, $lib_name ) : $perl_name;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 67 14 81
2735 }
2736  
2737 # Implementation of the 'clone-modules' command.
2738 #
2739 # This method accepts a destination and source installation
2740 # of Perl to clone modules from and into.
2741 # For instance calling
2742 # $app->run_command_clone_modules($perl_a, $perl_b);
2743 # installs all modules that have been installed on Perl A
2744 # to the instance of Perl B.
2745 # The source instance is optional, that is if the method
2746 # is invoked with a single argument, the currently
2747 # running instance is used as source. Therefore the
2748 # two following calls are the same:
2749 #
2750 # $app->run_command_clone_modules( $self->current_perl, $perl_b );
2751 # $app->run_command_clone_modules( $perl_b );
2752 #
2753 # Of course, both Perl installation must exist on this
2754 # perlbrew enviroment.
2755 #
2756 # The method extracts the modules installed on the source Perl
2757 # instance and put them on a temporary file, such file is then
2758 # passed to another instance of the application to
2759 # execute cpanm on it. The final result is the installation
2760 # of source modules into the destination instance.
2761 4 ▶sub run_command_clone_modules {
Subroutine run_command_clone_modules: called CC=12 SCAR=30.5
Pod undocumented
2762 4 my $self = shift;
2763  
2764 # default to use the currently installation
2765 4 my ( $dst_perl, $src_perl );
2766  
2767 # the first argument is the destination, the second
2768 # optional argument is the source version, default
2769 # to use the current installation
2770 4 ▶ $dst_perl = pop || $self->current_env;
Condition33%1/3
pop() || $self->current_env
l!l&&r!l&&!r
400
MC/DC0%0/2
pop() || $self->current_env
pop() $self->current_env
Truth table33%1/3
A || B
A= pop()B= $self->current_env
ABresult
1X1
011
000
2771 4 ▶ $src_perl = pop || $self->current_env;
Condition66%2/3
pop() || $self->current_env
l!l&&r!l&&!r
220
MC/DC0%0/2
pop() || $self->current_env
pop() $self->current_env
Truth table66%2/3
A || B
A= pop()B= $self->current_env
ABresult
1X1
011
000
2772  
2773 # check source and destination do exist
2774 4 ▶ undef $src_perl if ( !$self->resolve_installation_name($src_perl) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->resolve_installation_name($src_perl) 0 4 4
2775 4 ▶ undef $dst_perl if ( !$self->resolve_installation_name($dst_perl) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->resolve_installation_name($dst_perl) 0 4 4
2776  
2777 4 ▶ if ( !$src_perl
Branch: 1 branch
BranchTrueFalseTotal
if (not $src_perl && $dst_perl or $src_perl eq $dst_perl) 0 4 4
Condition33%2/6
not $src_perl && $dst_perl or $src_perl eq $dst_perl
l!l&&r!l&&!r
004
$src_perl && $dst_perl
!ll&&!rl&&r
004
MC/DC0%0/3
not $src_perl && $dst_perl or $src_perl eq $dst_perl
$src_perl $dst_perl $src_perl eq $dst_perl
Truth table25%1/4
not(A && B) or C
A= $src_perlB= $dst_perlC= $src_perl eq $dst_perl
ABCresult
0XX1
10X1
1111
1100
2778 || !$dst_perl
2779 || $src_perl eq $dst_perl )
2780 {
2781 # cannot understand from where to where or
2782 # the user did specify the same versions
2783 0 $self->run_command_help('clone-modules');
2784 0 exit(-1);
2785 }
2786  
2787 4 my @modules_to_install = @{ $self->list_modules($src_perl) };
2788  
2789 4 ▶ unless (@modules_to_install) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@modules_to_install) 0 4 4
2790 0 ▶ print "\nNo modules installed on $src_perl !\n" unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 0 0 0
2791 0 return;
2792 }
2793  
2794 print "\nInstalling $#modules_to_install modules from $src_perl to $dst_perl ...\n"
2795 4 ▶ unless $self->{quiet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"quiet"} 4 0 4
2796  
2797 # create a new application to 'exec' the 'cpanm'
2798 # with the specified module list
2799  
2800 4 my @args = ( qw(--quiet exec --with), $dst_perl, 'cpanm' );
2801 4 ▶ push @args, '--notest' if $self->{notest};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"notest"} 2 2 4
2802 4 push @args, @modules_to_install;
2803  
2804 4 __PACKAGE__->new(@args)->run;
2805 }
2806  
2807 4 ▶sub format_info_output {
Subroutine format_info_output: called CC=6 SCAR=17.9
Pod undocumented
2808 4 my ( $self, $module ) = @_;
2809  
2810 4 my $out = '';
2811  
2812 4 $out .= "Current perl:\n";
2813 4 ▶ if ( $self->current_perl ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->current_perl) { } 3 1 4
2814 3 $out .= " Name: " . $self->current_env . "\n";
2815 3 $out .= " Path: " . $self->installed_perl_executable( $self->current_perl ) . "\n";
2816 3 $out .= " Config: " . $self->configure_args( $self->current_perl ) . "\n";
2817 $out .= join(
2818 '',
2819 " Compiled at: ",
2820 (
2821 3 ▶ map { / Compiled at (.+)\n/ ? $1 : () }
Branch: 1 branch
BranchTrueFalseTotal
/ Compiled at (.+)\n/ ? : 3 321 324
2822 3 `@{[ $self->installed_perl_executable($self->current_perl) ]} -V`
2823 ),
2824 "\n"
2825 );
2826 }
2827 else {
2828 1 $out .= "Using system perl." . "\n";
2829 1 $out .= "Shebang: " . $self->system_perl_shebang . "\n";
2830 }
2831  
2832 4 $out .= "\nperlbrew:\n";
2833 4 $out .= " version: " . $self->VERSION . "\n";
2834 4 $out .= " ENV:\n";
2835 4 for ( map { "PERLBREW_$_" } qw(ROOT HOME PATH MANPATH) ) {
2836 16 ▶ $out .= " $_: " . ( $self->env($_) || "" ) . "\n";
Condition50%1/2
$self->env($_) || ''
l!l
160
MC/DC0%0/1
$self->env($_) || ''
$self->env($_)
Truth table50%1/2
A
A= $self->env($_)
Aresult
11
00
2837 }
2838  
2839 4 ▶ if ($module) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module) 2 2 4
2840 2 my $code =
2841 qq{eval "require $module" and do { (my \$f = "$module") =~ s<::></>g; \$f .= ".pm"; print "$module\n Location: \$INC{\$f}\n Version: " . ($module->VERSION ? $module->VERSION : "no VERSION specified" ) } or do { print "$module could not be found, is it installed?" } };
2842 2 $out .=
2843 "\nModule: " . $self->do_capture_current_perl( '-le', $code );
2844 }
2845  
2846 4 $out;
2847 }
2848  
2849 4 ▶sub run_command_info {
Subroutine run_command_info: called CC=1 SCAR=0.0
Pod undocumented
2850 4 my ($self) = shift;
2851 4 print $self->format_info_output(@_);
2852 }
2853  
2854 6 ▶sub run_command_make_shim {
Subroutine run_command_make_shim: called CC=7 SCAR=19.6
Pod undocumented
2855 6 my ($self, $program) = @_;
2856  
2857 6 ▶ unless ($program) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($program) 1 5 6
2858 1 $self->run_command_help("make-shim");
2859 1 return;
2860 }
2861  
2862 5 ▶ my $output = $self->{output} || $program;
Condition66%2/3
$self->{'output'} || $program
l!l&&r!l&&!r
230
MC/DC0%0/2
$self->{'output'} || $program
$self->{'output'} $program
Truth table66%2/3
A || B
A= $self->{'output'}B= $program
ABresult
1X1
011
000
2863  
2864 5 ▶ if (-f $output) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $output) 2 3 5
2865 2 die "ERROR: $program already exists under current directory.\n";
2866 }
2867  
2868 3 ▶ my $current_env = $self->current_env
Branch: 1 branch
BranchTrueFalseTotal
my $current_env = $self->current_env or die "ERROR: perlbrew is not activated. make-shim requires an perlbrew environment to be activated.\nRead the usage by running: perlbrew help make-shim\n" 2 1 3
2869 or die "ERROR: perlbrew is not activated. make-shim requires an perlbrew environment to be activated.\nRead the usage by running: perlbrew help make-shim\n";
2870  
2871 2 my %env = $self->perlbrew_env( $current_env );
2872  
2873 2 my $shebang = '#!' . $self->env('SHELL');
2874 2 my $preemble = $self->shell_env(\%env);
2875 2 my $path = $self->shell_env({ PATH => $env{"PERLBREW_PATH"} . ":" . $self->env("PATH") });
2876 2 my $shim = join(
2877 "\n",
2878 $shebang,
2879 $preemble,
2880 $path,
2881 'exec ' . $program . ' "$@"',
2882 "\n"
2883 );
2884  
2885 2 ▶ open my $fh, ">", "$output" or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", "$output" or die $! 2 0 2
2886 2 print $fh $shim;
2887 2 close $fh;
2888 2 chmod 0755, $output;
2889  
2890 2 ▶ if ( $self->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verbose"}) 0 2 2
2891 0 print "The shim $output is made.\n";
2892 }
2893 }
2894  
2895 0 ▶sub run_command_make_pp {
Subroutine run_command_make_pp: not called CC=9 SCAR=45.0
Pod undocumented
2896 0 my ($self, $program) = @_;
2897  
2898 0 ▶ my $current_env = $self->current_env
Branch: 1 branch
BranchTrueFalseTotal
my $current_env = $self->current_env or die "ERROR: perlbrew is not activated. make-pp requires an perlbrew environment to be activated.\nRead the usage by running: perlbrew help make-pp\n" 0 0 0
2899 or die "ERROR: perlbrew is not activated. make-pp requires an perlbrew environment to be activated.\nRead the usage by running: perlbrew help make-pp\n";
2900 0 ▶ my $path_pp = $self->whereis_in_env("pp", $current_env)
Branch: 1 branch
BranchTrueFalseTotal
my $path_pp = $self->whereis_in_env("pp", $current_env) or die "ERROR: pp cannot be found in $current_env" 0 0 0
2901 or die "ERROR: pp cannot be found in $current_env";
2902  
2903 0 my $input = $self->{input};
2904 0 my $output = $self->{output};
2905  
2906 0 ▶ unless ($input && $output) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($input and $output) 0 0 0
Condition0%0/3
$input and $output
!ll&&!rl&&r
000
MC/DC0%0/2
$input and $output
$input $output
Truth table0%0/3
A and B
A= $inputB= $output
ABresult
0X0
100
111
2907 0 $self->run_command_help("make-pp");
2908 0 return;
2909 }
2910  
2911 0 ▶ unless (-f $input) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $input) 0 0 0
2912 0 die "ERROR: The specified input $input do not exists\n";
2913 }
2914  
2915 0 ▶ if (-f $output) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $output) 0 0 0
2916 0 die "ERROR: $output already exists.\n";
2917 }
2918  
2919 0 my $sitelib = $self->do_capture_current_perl(
2920 '-MConfig',
2921 '-e',
2922 'print $Config{sitelibexp}',
2923 );
2924  
2925 0 my $privlib = $self->do_capture_current_perl(
2926 '-MConfig',
2927 '-e',
2928 'print $Config{privlibexp}',
2929 );
2930  
2931 0 my $locallib;
2932 0 ▶ if ($self->current_lib) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->current_lib) 0 0 0
2933 0 require local::lib;
2934 0 my ($current_lib) = grep { $_->{is_current} } $self->local_libs();
2935 0 my @llpaths = sort { length($a) <=> length($b) }
2936 0 local::lib->lib_paths_for( $current_lib->{dir} );
2937 0 $locallib = $llpaths[0];
2938 }
2939  
2940 0 my $perlversion = $self->do_capture_current_perl(
2941 '-MConfig',
2942 '-e',
2943 'print $Config{version}',
2944 );
2945  
2946 0 ▶ my @cmd = (
Branch: 1 branch
BranchTrueFalseTotal
$locallib ? : 0 0 0
2947 $path_pp,
2948 "-B", # core modules
2949 "-a", "$privlib;$perlversion",
2950 "-a", "$sitelib;$perlversion",
2951 ($locallib ? ("-a", "$locallib;$perlversion") : ()),
2952 "-z", "9",
2953 "-o", $output,
2954 $input,
2955 );
2956  
2957 0 $self->do_system(@cmd);
2958 }
2959  
2960 0 ▶sub whereis_in_env {
Subroutine whereis_in_env: not called CC=1 SCAR=6.9
Pod undocumented
2961 0 my ($self, $program, $env) = @_;
2962 0 my %env = $self->perlbrew_env( $env );
2963 0 my @paths = split /:/, $env{PERLBREW_PATH};
2964  
2965 0 my ($path) = grep { -x $_ } map { App::Perlbrew::Path->new($_, $program) } @paths;
2966  
2967 0 return $path;
2968 }
2969  
2970  
2971 11 ▶sub BASHRC_CONTENT() {
Subroutine BASHRC_CONTENT: called CC=2 SCAR=6.9
Pod undocumented
2972 return
2973 "export PERLBREW_SHELLRC_VERSION=$VERSION\n"
2974 11 ▶ . ( exists $ENV{PERLBREW_ROOT} ? "export PERLBREW_ROOT=$PERLBREW_ROOT\n" : "" ) . "\n"
Branch: 1 branch
BranchTrueFalseTotal
exists $ENV{'PERLBREW_ROOT'} ? : 9 2 11
2975 . <<'RC';
2976  
2977 __perlbrew_reinit() {
2978 if [[ ! -d "$PERLBREW_HOME" ]]; then
2979 mkdir -p "$PERLBREW_HOME"
2980 fi
2981  
2982 [ -f "$PERLBREW_HOME/init" ] && rm -f "$PERLBREW_HOME/init"
2983 echo '# DO NOT EDIT THIS FILE' > "$PERLBREW_HOME/init"
2984 command perlbrew env $1 | \grep PERLBREW_ >> "$PERLBREW_HOME/init"
2985 . "$PERLBREW_HOME/init"
2986 __perlbrew_set_path
2987 }
2988  
2989 __perlbrew_purify () {
2990 local path patharray outsep
2991 IFS=: read -r${BASH_VERSION+a}${ZSH_VERSION+A} patharray <<< "$1"
2992 for path in "${patharray[@]}" ; do
2993 case "$path" in
2994 (*"$PERLBREW_HOME"*) ;;
2995 (*"$PERLBREW_ROOT"*) ;;
2996 (*) printf '%s' "${outsep:-}$path" ; outsep=: ;;
2997 esac
2998 done
2999 }
3000  
3001 __perlbrew_set_path () {
3002 export MANPATH=${PERLBREW_MANPATH:-}${PERLBREW_MANPATH:+:}$(__perlbrew_purify "$(manpath 2>/dev/null)")
3003 export PATH=${PERLBREW_PATH:-$PERLBREW_ROOT/bin}:$(__perlbrew_purify "$PATH")
3004 if [[ -o hashall ]] ; then
3005 hash -r
3006 fi
3007 }
3008  
3009 __perlbrew_set_env() {
3010 local code
3011 code="$($perlbrew_command env $@)" || return $?
3012 eval "$code"
3013 }
3014  
3015 __perlbrew_activate() {
3016 [[ -n $(alias perl 2>/dev/null) ]] && unalias perl 2>/dev/null
3017  
3018 if [[ -n "${PERLBREW_PERL:-}" ]]; then
3019 __perlbrew_set_env "${PERLBREW_PERL:-}${PERLBREW_LIB:+@}${PERLBREW_LIB:-}"
3020 fi
3021  
3022 __perlbrew_set_path
3023 }
3024  
3025 __perlbrew_deactivate() {
3026 __perlbrew_set_env
3027 unset PERLBREW_PERL
3028 unset PERLBREW_LIB
3029 __perlbrew_set_path
3030 }
3031  
3032 perlbrew () {
3033 local exit_status
3034 local short_option
3035 export SHELL
3036  
3037 if [[ $1 == -* ]]; then
3038 short_option=$1
3039 shift
3040 else
3041 short_option=""
3042 fi
3043  
3044 case $1 in
3045 (use)
3046 if [[ -z "$2" ]] ; then
3047 echo -n "Currently using ${PERLBREW_PERL:-system perl}"
3048 [ -n "${PERLBREW_LIB:-}" ] && echo -n "@${PERLBREW_LIB:-}"
3049 echo
3050 else
3051 __perlbrew_set_env "$2" && { __perlbrew_set_path ; true ; }
3052 exit_status="$?"
3053 fi
3054 ;;
3055  
3056 (switch)
3057 if [[ -z "$2" ]] ; then
3058 command perlbrew switch
3059 else
3060 perlbrew use "$2" && { __perlbrew_reinit "$2" ; true ; }
3061 exit_status=$?
3062 fi
3063 ;;
3064  
3065 (off)
3066 local save_opt
3067 local force_opt
3068 exit_status=0
3069  
3070 shift
3071 while [[ $# != '0' ]] && [[ "$exit_status" == '0' ]]; do
3072 case "$1" in
3073 -s) save_opt=1 ;;
3074 -f) force_opt=1 ;;
3075 -sf|-fs)
3076 save_opt=1
3077 force_opt=1
3078 ;;
3079 *)
3080 echo "invalid option: $1."
3081 exit_status=1
3082 ;;
3083 esac
3084 shift
3085 done
3086  
3087 if [[ "$exit_status" == '0' ]]; then
3088 if [[ "$save_opt" == '1' ]]; then
3089 if [[ -n "$PERLBREW_PERL_LAST" ]]; then
3090 if [[ "$force_opt" != '1' ]]; then
3091 echo "PERLBREW_PERL_LAST already set to '$PERLBREW_PERL_LAST'. Add '-f' option to override."
3092 exit_status=1;
3093 fi
3094 fi
3095 if [[ "$exit_status" == '0' ]]; then
3096 echo "$PERLBREW_PERL is saved to PERLBREW_PERL_LAST."
3097 export PERLBREW_PERL_LAST="${PERLBREW_PERL}${PERLBREW_LIB:+@$PERLBREW_LIB}"
3098 fi
3099 fi
3100 fi
3101  
3102 if [[ "$exit_status" == '0' ]]; then
3103 __perlbrew_deactivate
3104 fi
3105 echo "perlbrew is turned off."
3106 ;;
3107  
3108 (on)
3109 if [[ -z "$PERLBREW_PERL_LAST" ]] ; then
3110 echo "Sorry, PERLBREW_PERL_LAST is not set, cannot turn on last perlbrew installation you were using."
3111 exit_status=1
3112 else
3113 __perlbrew_set_env "$PERLBREW_PERL_LAST" && { __perlbrew_set_path
3114 echo "perlbrew $PERLBREW_PERL_LAST is restored."
3115 unset PERLBREW_PERL_LAST
3116 true ; }
3117 exit_status="$?"
3118 fi
3119 ;;
3120  
3121 (switch-off)
3122 __perlbrew_deactivate
3123 __perlbrew_reinit
3124 echo "perlbrew is switched off."
3125 ;;
3126  
3127 (*)
3128 command perlbrew ${short_option:+"$short_option"} "$@"
3129 exit_status=$?
3130 ;;
3131 esac
3132 hash -r
3133 return ${exit_status:-0}
3134 }
3135  
3136 [[ -z "${PERLBREW_ROOT:-}" ]] && export PERLBREW_ROOT="$HOME/perl5/perlbrew"
3137 [[ -z "${PERLBREW_HOME:-}" ]] && export PERLBREW_HOME="$HOME/.perlbrew"
3138  
3139 if [[ ! -n "${PERLBREW_SKIP_INIT:-}" ]]; then
3140 if [[ -f "${PERLBREW_HOME:-}/init" ]]; then
3141 . "$PERLBREW_HOME/init"
3142 fi
3143 fi
3144  
3145 if [[ -f "${PERLBREW_ROOT:-}/bin/perlbrew" ]]; then
3146 perlbrew_command="${PERLBREW_ROOT:-}/bin/perlbrew"
3147 else
3148 perlbrew_command="perlbrew"
3149 fi
3150  
3151 __perlbrew_activate
3152  
3153 RC
3154  
3155 }
3156  
3157 6 ▶sub BASH_COMPLETION_CONTENT() {
Subroutine BASH_COMPLETION_CONTENT: called CC=1 SCAR=0.0
Pod undocumented
3158 6 return <<'COMPLETION';
3159 if [[ -n ${ZSH_VERSION-} ]]; then
3160 autoload -U +X bashcompinit && bashcompinit
3161 fi
3162  
3163 export PERLBREW="command perlbrew"
3164 _perlbrew_compgen()
3165 {
3166 COMPREPLY=( $($PERLBREW compgen $COMP_CWORD ${COMP_WORDS[*]}) )
3167 }
3168 complete -F _perlbrew_compgen perlbrew
3169 COMPLETION
3170 }
3171  
3172 6 ▶sub PERLBREW_FISH_CONTENT {
Subroutine PERLBREW_FISH_CONTENT: called CC=1 SCAR=0.0
Pod undocumented
3173 6 return "set -x PERLBREW_SHELLRC_VERSION $VERSION\n" . <<'END';
3174  
3175 function __perlbrew_reinit
3176 if not test -d "$PERLBREW_HOME"
3177 mkdir -p "$PERLBREW_HOME"
3178 end
3179  
3180 echo '# DO NOT EDIT THIS FILE' > "$PERLBREW_HOME/init"
3181 command perlbrew env $argv[1] | \grep PERLBREW_ >> "$PERLBREW_HOME/init"
3182 __source_init
3183 __perlbrew_set_path
3184 end
3185  
3186 function __perlbrew_set_path
3187 set -l MANPATH_WITHOUT_PERLBREW (perl -e 'print join ":", grep { index($_, $ENV{PERLBREW_HOME}) < 0 } grep { index($_, $ENV{PERLBREW_ROOT}) < 0 } split/:/,qx(manpath 2> /dev/null);')
3188  
3189 if test -n "$PERLBREW_MANPATH"
3190 set -l PERLBREW_MANPATH $PERLBREW_MANPATH":"
3191 set -x MANPATH {$PERLBREW_MANPATH}{$MANPATH_WITHOUT_PERLBREW}
3192 else
3193 set -x MANPATH $MANPATH_WITHOUT_PERLBREW
3194 end
3195  
3196 set -l PATH_WITHOUT_PERLBREW (eval $perlbrew_command display-pristine-path | perl -pe'y/:/ /')
3197  
3198 # silencing stderr in case there's a non-existent path in $PATH (see GH#446)
3199 if test -n "$PERLBREW_PATH"
3200 set -x PERLBREW_PATH (echo $PERLBREW_PATH | perl -pe 'y/:/ /' )
3201 eval set -x PATH $PERLBREW_PATH $PATH_WITHOUT_PERLBREW 2> /dev/null
3202 else
3203 eval set -x PATH $PERLBREW_ROOT/bin $PATH_WITHOUT_PERLBREW 2> /dev/null
3204 end
3205 end
3206  
3207 function __perlbrew_set_env
3208 set -l code (eval $perlbrew_command env $argv | perl -pe 's/^(export|setenv)/set -xg/; s/=/ /; s/^unset(env)* (.*)/if test -n "\$$2"; set -eg $2; end/; s/$/;/; y/:/ /')
3209  
3210 if test -z "$code"
3211 return 0;
3212 else
3213 eval $code
3214 end
3215 end
3216  
3217 function __perlbrew_activate
3218 functions -e perl
3219  
3220 if test -n "$PERLBREW_PERL"
3221 if test -z "$PERLBREW_LIB"
3222 __perlbrew_set_env $PERLBREW_PERL
3223 else
3224 __perlbrew_set_env $PERLBREW_PERL@$PERLBREW_LIB
3225 end
3226 end
3227  
3228 __perlbrew_set_path
3229 end
3230  
3231 function __perlbrew_deactivate
3232 __perlbrew_set_env
3233 set -x PERLBREW_PERL
3234 set -x PERLBREW_LIB
3235 set -x PERLBREW_PATH
3236 __perlbrew_set_path
3237 end
3238  
3239 function perlbrew
3240  
3241 test -z "$argv"
3242 and echo " Usage: perlbrew <command> [options] [arguments]"
3243 and echo " or: perlbrew help"
3244 and return 1
3245  
3246 switch $argv[1]
3247 case use
3248 if test ( count $argv ) -eq 1
3249 if test -z "$PERLBREW_PERL"
3250 echo "Currently using system perl"
3251 else
3252 echo "Currently using $PERLBREW_PERL"
3253 end
3254 else
3255 __perlbrew_set_env $argv[2]
3256 if test "$status" -eq 0
3257 __perlbrew_set_path
3258 end
3259 end
3260  
3261 case switch
3262 if test ( count $argv ) -eq 1
3263 command perlbrew switch
3264 else
3265 perlbrew use $argv[2]
3266 if test "$status" -eq 0
3267 __perlbrew_reinit $argv[2]
3268 end
3269 end
3270  
3271 case off
3272 set -l save_opt
3273 set -l force_opt
3274 set -l exit_status 0
3275  
3276 set -e argv[1]
3277 while test (count $argv) -gt 0; and test "$exit_status" = 0
3278 switch $argv[1]
3279 case -s
3280 set save_opt 1
3281 case -f
3282 set force_opt 1
3283 case -sf -fs
3284 set save_opt 1
3285 set force_opt 1
3286 case '*'
3287 echo "invalid option: $argv[1]"
3288 set exit_status 1
3289 end
3290 set -e argv[1]
3291 end
3292  
3293 if test "$exit_status" = 0
3294 if test "$save_opt" = 1
3295 if set -q PERLBREW_PERL_LAST; and test -n "$PERLBREW_PERL_LAST"
3296 if test "$force_opt" != 1
3297 echo "PERLBREW_PERL_LAST already set to '$PERLBREW_PERL_LAST'. Add '-f' option to override."
3298 return 1
3299 end
3300 end
3301 if test "$exit_status" = 0
3302 set -gx PERLBREW_PERL_LAST $PERLBREW_PERL
3303 end
3304 end
3305 end
3306  
3307 if test "$exit_status" = 0
3308 __perlbrew_deactivate
3309 end
3310 echo "perlbrew is turned off."
3311  
3312 case on
3313 if test -z "$PERLBREW_PERL_LAST
3314 echo "Sorry, PERLBREW_PERL_LAST is not set, cannot turn on last perlbrew installation you were using."
3315 false
3316 else
3317 __perlbrew_set_env "$PERLBREW_PERL_LAST"
3318 if test "$status" -eq 0
3319 __perlbrew_set_path
3320 echo "perlbrew $PERLBREW_PERL_LAST is restored."
3321 set -e PERLBREW_PERL_LAST
3322 end
3323 fi
3324 ;;
3325  
3326  
3327 case switch-off
3328 __perlbrew_deactivate
3329 __perlbrew_reinit
3330 echo "perlbrew is switched off."
3331  
3332 case '*'
3333 command perlbrew $argv
3334 end
3335 end
3336  
3337 function __source_init
3338 perl -pe 's/^(export|setenv)/set -xg/; s/^unset(env)* (.*)/if test -n "\$$2"; set -eg $2; end/; s/=/ /; s/$/;/;' "$PERLBREW_HOME/init" | source
3339 end
3340  
3341 if test -z "$PERLBREW_ROOT"
3342 set -x PERLBREW_ROOT "$HOME/perl5/perlbrew"
3343 end
3344  
3345 if test -z "$PERLBREW_HOME"
3346 set -x PERLBREW_HOME "$HOME/.perlbrew"
3347 end
3348  
3349 if test -z "$PERLBREW_SKIP_INIT" -a -f "$PERLBREW_HOME/init"
3350 __source_init
3351 end
3352  
3353 set perlbrew_bin_path "$PERLBREW_ROOT/bin"
3354  
3355 if test -f "$perlbrew_bin_path/perlbrew"
3356 set perlbrew_command "$perlbrew_bin_path/perlbrew"
3357 else
3358 set perlbrew_command perlbrew
3359 end
3360  
3361 set -e perlbrew_bin_path
3362  
3363 __perlbrew_activate
3364  
3365 ## autocomplete stuff #############################################
3366  
3367 function __fish_perlbrew_needs_command
3368 set cmd (commandline -opc)
3369 if test (count $cmd) -eq 1 -a $cmd[1] = 'perlbrew'
3370 return 0
3371 end
3372 return 1
3373 end
3374  
3375 function __fish_perlbrew_using_command
3376 set cmd (commandline -opc)
3377 if test (count $cmd) -gt 1
3378 if [ $argv[1] = $cmd[2] ]
3379 return 0
3380 end
3381 end
3382 end
3383  
3384 for com in (perlbrew help | perl -ne'print lc if s/^COMMAND:\s+//')
3385 complete -f -c perlbrew -n '__fish_perlbrew_needs_command' -a $com
3386 end
3387  
3388 for com in switch use;
3389 complete -f -c perlbrew -n "__fish_perlbrew_using_command $com" \
3390 -a '(perlbrew list | perl -pe\'s/\*?\s*(\S+).*/$1/\')'
3391 end
3392  
3393 END
3394 }
3395  
3396 6 ▶sub CSH_WRAPPER_CONTENT {
Subroutine CSH_WRAPPER_CONTENT: called CC=1 SCAR=0.0
Pod undocumented
3397 6 return <<'WRAPPER';
3398 set perlbrew_exit_status=0
3399  
3400 if ( "$1" =~ -* ) then
3401 set perlbrew_short_option="$1"
3402 shift
3403 else
3404 set perlbrew_short_option=""
3405 endif
3406  
3407 switch ( "$1" )
3408 case use:
3409 if ( $%2 == 0 ) then
3410 if ( $?PERLBREW_PERL == 0 ) then
3411 echo "Currently using system perl"
3412 else
3413 if ( $%PERLBREW_PERL == 0 ) then
3414 echo "Currently using system perl"
3415 else
3416 echo "Currently using $PERLBREW_PERL"
3417 endif
3418 endif
3419 else
3420 set perlbrew_line_count=0
3421 foreach perlbrew_line ( "`\perlbrew env $2:q`" )
3422 eval "$perlbrew_line"
3423 @ perlbrew_line_count++
3424 end
3425 if ( $perlbrew_line_count == 0 ) then
3426 set perlbrew_exit_status=1
3427 else
3428 source "$PERLBREW_ROOT/etc/csh_set_path"
3429 endif
3430 endif
3431 breaksw
3432  
3433 case switch:
3434 if ( $%2 == 0 ) then
3435 \perlbrew switch
3436 else
3437 perlbrew use "$2" && source "$PERLBREW_ROOT/etc/csh_reinit" "$2"
3438 endif
3439 breaksw
3440  
3441 case off:
3442 set save_opt = 0
3443 set force_opt = 0
3444 set exit_status = 0
3445  
3446 shift argv
3447 while ( $#argv > 0 && $exit_status == 0 )
3448 switch ( "$argv[1]" )
3449 case "-s":
3450 set save_opt = 1
3451 breaksw
3452  
3453 case "-f":
3454 set force_opt = 1
3455 breaksw
3456  
3457 case "-sf":
3458 case "-fs":
3459 set save_opt = 1
3460 set force_opt = 1
3461 breaksw
3462  
3463 default:
3464 echo "invalid option: $argv[1]"
3465 set exit_status = 1
3466 breaksw
3467 endsw
3468 shift argv
3469 end
3470  
3471 if ( $exit_status == 0 ) then
3472 if ( $save_opt == 1 ) then
3473 if ( $?PERLBREW_PERL_LAST ) then
3474 if ( $force_opt != 1 ) then
3475 echo "PERLBREW_PERL_LAST already set to '$PERLBREW_PERL_LAST'. Add '-f' option to override."
3476 set exit_status = 1
3477 endif
3478 endif
3479 if ( $exit_status == 0 ) then
3480 setenv PERLBREW_PERL_LAST "$PERLBREW_PERL"
3481 endif
3482 endif
3483 endif
3484  
3485 if ( $exit_status == 0 ) then
3486 unsetenv PERLBREW_PERL
3487 foreach perlbrew_line ( "`\perlbrew env`" )
3488 eval "$perlbrew_line"
3489 end
3490 source "$PERLBREW_ROOT/etc/csh_set_path"
3491 echo "perlbrew is turned off."
3492  
3493 breaksw
3494  
3495 case on:
3496 set perlbrew_exit_status=0
3497 if (! $?PERLBREW_PERL_LAST)
3498 echo "Sorry, PERLBREW_PERL_LAST is not set, cannot turn on last perlbrew installation you were using."
3499 set perlbrew_exit_status=1
3500 else
3501 set perlbrew_line_count=0
3502 foreach perlbrew_line ( "`\perlbrew env $PERLBREW_PERL_LAST:q`" )
3503 eval "$perlbrew_line"
3504 @ perlbrew_line_count++
3505 end
3506 if ( $perlbrew_line_count == 0 ) then
3507 set perlbrew_exit_status=1
3508 else
3509 source "$PERLBREW_ROOT/etc/csh_set_path"
3510 set perlbrew_exit_status="$?"
3511 echo "perlbrew $PERLBREW_PERL_LAST is restored."
3512 unsetenv PERLBREW_PERL_LAST
3513 endif
3514 endif
3515  
3516 breaksw
3517  
3518 case switch-off:
3519 unsetenv PERLBREW_PERL
3520 source "$PERLBREW_ROOT/etc/csh_reinit" ''
3521 echo "perlbrew is switched off."
3522 breaksw
3523  
3524 default:
3525 \perlbrew $perlbrew_short_option:q $argv:q
3526 set perlbrew_exit_status=$?
3527 breaksw
3528 endsw
3529 rehash
3530 exit $perlbrew_exit_status
3531 WRAPPER
3532 }
3533  
3534 6 ▶sub CSH_REINIT_CONTENT {
Subroutine CSH_REINIT_CONTENT: called CC=1 SCAR=0.0
Pod undocumented
3535 6 return <<'REINIT';
3536 if ( ! -d "$PERLBREW_HOME" ) then
3537 mkdir -p "$PERLBREW_HOME"
3538 endif
3539  
3540 echo '# DO NOT EDIT THIS FILE' >! "$PERLBREW_HOME/init"
3541 \perlbrew env $1 >> "$PERLBREW_HOME/init"
3542 source "$PERLBREW_HOME/init"
3543 source "$PERLBREW_ROOT/etc/csh_set_path"
3544 REINIT
3545 }
3546  
3547 6 ▶sub CSH_SET_PATH_CONTENT {
Subroutine CSH_SET_PATH_CONTENT: called CC=1 SCAR=0.0
Pod undocumented
3548 6 return <<'SETPATH';
3549 unalias perl
3550  
3551 if ( $?PERLBREW_PATH == 0 ) then
3552 setenv PERLBREW_PATH "$PERLBREW_ROOT/bin"
3553 endif
3554  
3555 setenv PATH_WITHOUT_PERLBREW `perl -e 'print join ":", grep { index($_, $ENV{PERLBREW_ROOT}) } split/:/,$ENV{PATH};'`
3556 setenv PATH "${PERLBREW_PATH}:${PATH_WITHOUT_PERLBREW}"
3557  
3558 setenv MANPATH_WITHOUT_PERLBREW `perl -e 'print join ":", grep { index($_, $ENV{PERLBREW_ROOT}) } split/:/,qx(manpath 2> /dev/null);'`
3559 if ( $?PERLBREW_MANPATH == 1 ) then
3560 setenv MANPATH "${PERLBREW_MANPATH}:${MANPATH_WITHOUT_PERLBREW}"
3561 else
3562 setenv MANPATH "${MANPATH_WITHOUT_PERLBREW}"
3563 endif
3564 SETPATH
3565 }
3566  
3567 6 ▶sub CSHRC_CONTENT {
Subroutine CSHRC_CONTENT: called CC=1 SCAR=0.0
Pod undocumented
3568 6 return "setenv PERLBREW_SHELLRC_VERSION $VERSION\n\n" . <<'CSHRC';
3569  
3570 if ( $?PERLBREW_HOME == 0 ) then
3571 setenv PERLBREW_HOME "$HOME/.perlbrew"
3572 endif
3573  
3574 if ( $?PERLBREW_ROOT == 0 ) then
3575 setenv PERLBREW_ROOT "$HOME/perl5/perlbrew"
3576 endif
3577  
3578 if ( $?PERLBREW_SKIP_INIT == 0 ) then
3579 if ( -f "$PERLBREW_HOME/init" ) then
3580 source "$PERLBREW_HOME/init"
3581 endif
3582 endif
3583  
3584 if ( $?PERLBREW_PATH == 0 ) then
3585 setenv PERLBREW_PATH "$PERLBREW_ROOT/bin"
3586 endif
3587  
3588 source "$PERLBREW_ROOT/etc/csh_set_path"
3589 alias perlbrew 'source "$PERLBREW_ROOT/etc/csh_wrapper"'
3590 CSHRC
3591  
3592 }
3593  
3594 4 ▶sub append_log {
Subroutine append_log: called CC=2 SCAR=7.0
Pod undocumented
3595 4 my ( $self, $message ) = @_;
3596 4 my $log_handler;
3597 open( $log_handler, '>>', $self->{log_file} )
3598 4 ▶ or die "Cannot open log file for appending: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $log_handler, ">>", $self->{"log_file"} or die "Cannot open log file for appending: $!" 4 0 4
3599 4 print $log_handler "$message\n";
3600 4 close($log_handler);
3601 }
3602  
3603 1 ▶sub INSTALLATION_FAILURE_MESSAGE {
Subroutine INSTALLATION_FAILURE_MESSAGE: called CC=1 SCAR=0.0
Pod undocumented
3604 1 my ($self) = @_;
3605 1 return <<FAIL;
3606 Installation process failed. To spot any issues, check
3607  
3608 $self->{log_file}
3609  
3610 If some perl tests failed and you still want to install this distribution anyway,
3611 do:
3612  
3613 (cd $self->{dist_extracted_dir}; make install)
3614  
3615 You might also want to try upgrading patchperl before trying again:
3616  
3617 perlbrew install-patchperl
3618  
3619 Generally, if you need to install a perl distribution known to have minor test
3620 failures, do one of these commands to avoid seeing this message:
3621  
3622 perlbrew --notest install $self->{dist_name}
3623 perlbrew --force install $self->{dist_name}
3624  
3625 FAIL
3626  
3627 }
3628  
3629 70 1;
3630  
3631 __END__
↑ Summary lib/App/Perlbrew/HTTP.pm »