| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Probe::CommandLine; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
7316
|
use strict; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
101
|
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
|
3
|
|
|
|
|
13
|
|
|
|
3
|
|
|
|
|
88
|
|
|
5
|
3
|
|
|
3
|
|
51
|
use 5.008004; |
|
|
3
|
|
|
|
|
11
|
|
|
6
|
3
|
|
|
3
|
|
469
|
use Alien::Build::Plugin; |
|
|
3
|
|
|
|
|
15
|
|
|
|
3
|
|
|
|
|
34
|
|
|
7
|
3
|
|
|
3
|
|
18
|
use Carp (); |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
114
|
|
|
8
|
3
|
|
|
3
|
|
19
|
use Capture::Tiny qw( capture ); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
187
|
|
|
9
|
3
|
|
|
3
|
|
21
|
use File::Which (); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1719
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Probe for tools or commands already available |
|
12
|
|
|
|
|
|
|
our $VERSION = '2.46'; # VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has '+command' => sub { Carp::croak "@{[ __PACKAGE__ ]} requires command property" }; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'args' => []; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'secondary' => 0; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'match' => undef; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'match_stderr' => undef; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'version' => undef; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'version_stderr' => undef; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub init |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
20
|
|
|
20
|
1
|
82
|
my($self, $meta) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $check = sub { |
|
40
|
13
|
|
|
13
|
|
44
|
my($build) = @_; |
|
41
|
|
|
|
|
|
|
|
|
42
|
13
|
100
|
|
|
|
48
|
unless(File::Which::which($self->command)) |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
2
|
|
|
|
|
26
|
die 'Command not found ' . $self->command; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
11
|
100
|
100
|
|
|
150
|
if(defined $self->match || defined $self->match_stderr || defined $self->version || defined $self->version_stderr) |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
48
|
|
|
|
|
|
|
{ |
|
49
|
|
|
|
|
|
|
my($out,$err,$ret) = capture { |
|
50
|
10
|
|
|
|
|
10329
|
system( $self->command, @{ $self->args } ); |
|
|
10
|
|
|
|
|
31
|
|
|
51
|
10
|
|
|
|
|
283
|
}; |
|
52
|
10
|
50
|
|
|
|
9244
|
die 'Command did not return a true value' if $ret; |
|
53
|
10
|
100
|
100
|
|
|
39
|
die 'Command output did not match' if defined $self->match && $out !~ $self->match; |
|
54
|
9
|
100
|
100
|
|
|
28
|
die 'Command standard error did not match' if defined $self->match_stderr && $err !~ $self->match_stderr; |
|
55
|
8
|
100
|
|
|
|
62
|
if(defined $self->version) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
2
|
100
|
|
|
|
7
|
if($out =~ $self->version) |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
1
|
|
|
|
|
5
|
$build->runtime_prop->{version} = $1; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
8
|
100
|
|
|
|
21
|
if(defined $self->version_stderr) |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
2
|
100
|
|
|
|
6
|
if($err =~ $self->version_stderr) |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
1
|
|
|
|
|
10
|
$build->hook_prop->{version} = $1; |
|
67
|
1
|
|
|
|
|
3
|
$build->runtime_prop->{version} = $1; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
9
|
|
|
|
|
23
|
$build->runtime_prop->{command} = $self->command; |
|
73
|
9
|
|
|
|
|
26
|
'system'; |
|
74
|
20
|
|
|
|
|
104
|
}; |
|
75
|
|
|
|
|
|
|
|
|
76
|
20
|
100
|
|
|
|
64
|
if($self->secondary) |
|
77
|
|
|
|
|
|
|
{ |
|
78
|
|
|
|
|
|
|
$meta->around_hook( |
|
79
|
|
|
|
|
|
|
probe => sub { |
|
80
|
4
|
|
|
4
|
|
9
|
my $orig = shift; |
|
81
|
4
|
|
|
|
|
9
|
my $build = shift; |
|
82
|
4
|
|
|
|
|
13
|
my $type = $orig->($build, @_); |
|
83
|
4
|
100
|
|
|
|
29
|
return $type unless $type eq 'system'; |
|
84
|
2
|
|
|
|
|
20
|
$check->($build); |
|
85
|
|
|
|
|
|
|
}, |
|
86
|
7
|
|
|
|
|
43
|
); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
else |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
13
|
|
|
|
|
41
|
$meta->register_hook( |
|
91
|
|
|
|
|
|
|
probe => $check, |
|
92
|
|
|
|
|
|
|
); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |