line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Carmel::Runner; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
307
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
7
|
|
|
|
|
|
|
|
8
|
0
|
|
|
|
|
|
require Carmel::Setup; |
9
|
0
|
|
|
|
|
|
Carmel::Setup->load; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
12
|
|
|
|
|
|
|
|
13
|
0
|
0
|
|
|
|
|
if (Carmel::Setup->has_local) { |
14
|
0
|
|
|
|
|
|
$self->{local} = Carmel::Setup->environment->{base} . '/local'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
$self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Note: can't capture carmel exec perl -MModule because it's loaded earlier than PERL5OPT |
21
|
|
|
|
|
|
|
sub env { |
22
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $environment = Carmel::Setup->environment; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
if ($self->{local}) { |
27
|
|
|
|
|
|
|
return ( |
28
|
|
|
|
|
|
|
_join(':', PATH => ["$self->{local}/bin"]), |
29
|
|
|
|
|
|
|
_join(' ', PERL5OPT => ["-MCarmel::Setup"]), |
30
|
|
|
|
|
|
|
PERL_CARMEL_PATH => $environment->{base}, |
31
|
0
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
return ( |
34
|
|
|
|
|
|
|
_join(':', PATH => $environment->{path}), |
35
|
|
|
|
|
|
|
_join(' ', PERL5OPT => ["-MCarmel::Setup"]), |
36
|
|
|
|
|
|
|
PERL_CARMEL_PATH => $environment->{base}, |
37
|
0
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub execute { |
42
|
0
|
|
|
0
|
0
|
|
my($self, @cmd) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
0
|
|
|
|
shift @cmd if $cmd[0] && $cmd[0] eq '--'; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
%ENV = (%ENV, $self->env); |
47
|
0
|
|
|
|
|
|
exec @cmd; |
48
|
0
|
|
|
|
|
|
exit 127; # command not found |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub run { |
52
|
0
|
|
|
0
|
0
|
|
my($self, @cmd) = @_; |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
0
|
|
|
|
shift @cmd if $cmd[0] && $cmd[0] eq '--'; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
local %ENV = (%ENV, $self->env); |
57
|
0
|
|
|
|
|
|
system @cmd; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _join { |
61
|
0
|
|
|
0
|
|
|
my($sep, $env, $list) = @_; |
62
|
0
|
0
|
|
|
|
|
return unless $list; |
63
|
0
|
0
|
|
|
|
|
push @$list, $ENV{$env} if $ENV{$env}; |
64
|
0
|
|
|
|
|
|
return ($env => join($sep, @$list)); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |