line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Probe::CommandLine; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
6160
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
89
|
|
4
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
72
|
|
5
|
3
|
|
|
3
|
|
51
|
use 5.008004; |
|
3
|
|
|
|
|
10
|
|
6
|
3
|
|
|
3
|
|
372
|
use Alien::Build::Plugin; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
27
|
|
7
|
3
|
|
|
3
|
|
18
|
use Carp (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
68
|
|
8
|
3
|
|
|
3
|
|
18
|
use Capture::Tiny qw( capture ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
210
|
|
9
|
3
|
|
|
3
|
|
18
|
use File::Which (); |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
1428
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Probe for tools or commands already available |
12
|
|
|
|
|
|
|
our $VERSION = '2.47'; # 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
|
66
|
my($self, $meta) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $check = sub { |
40
|
13
|
|
|
13
|
|
28
|
my($build) = @_; |
41
|
|
|
|
|
|
|
|
42
|
13
|
100
|
|
|
|
40
|
unless(File::Which::which($self->command)) |
43
|
|
|
|
|
|
|
{ |
44
|
2
|
|
|
|
|
24
|
die 'Command not found ' . $self->command; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
11
|
100
|
100
|
|
|
138
|
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
|
|
|
|
|
8681
|
system( $self->command, @{ $self->args } ); |
|
10
|
|
|
|
|
25
|
|
51
|
10
|
|
|
|
|
241
|
}; |
52
|
10
|
50
|
|
|
|
7594
|
die 'Command did not return a true value' if $ret; |
53
|
10
|
100
|
100
|
|
|
33
|
die 'Command output did not match' if defined $self->match && $out !~ $self->match; |
54
|
9
|
100
|
100
|
|
|
23
|
die 'Command standard error did not match' if defined $self->match_stderr && $err !~ $self->match_stderr; |
55
|
8
|
100
|
|
|
|
17
|
if(defined $self->version) |
56
|
|
|
|
|
|
|
{ |
57
|
2
|
100
|
|
|
|
6
|
if($out =~ $self->version) |
58
|
|
|
|
|
|
|
{ |
59
|
1
|
|
|
|
|
4
|
$build->runtime_prop->{version} = $1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
8
|
100
|
|
|
|
23
|
if(defined $self->version_stderr) |
63
|
|
|
|
|
|
|
{ |
64
|
2
|
100
|
|
|
|
7
|
if($err =~ $self->version_stderr) |
65
|
|
|
|
|
|
|
{ |
66
|
1
|
|
|
|
|
9
|
$build->hook_prop->{version} = $1; |
67
|
1
|
|
|
|
|
5
|
$build->runtime_prop->{version} = $1; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
9
|
|
|
|
|
23
|
$build->runtime_prop->{command} = $self->command; |
73
|
9
|
|
|
|
|
21
|
'system'; |
74
|
20
|
|
|
|
|
90
|
}; |
75
|
|
|
|
|
|
|
|
76
|
20
|
100
|
|
|
|
53
|
if($self->secondary) |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
$meta->around_hook( |
79
|
|
|
|
|
|
|
probe => sub { |
80
|
4
|
|
|
4
|
|
11
|
my $orig = shift; |
81
|
4
|
|
|
|
|
6
|
my $build = shift; |
82
|
4
|
|
|
|
|
10
|
my $type = $orig->($build, @_); |
83
|
4
|
100
|
|
|
|
24
|
return $type unless $type eq 'system'; |
84
|
2
|
|
|
|
|
17
|
$check->($build); |
85
|
|
|
|
|
|
|
}, |
86
|
7
|
|
|
|
|
46
|
); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
else |
89
|
|
|
|
|
|
|
{ |
90
|
13
|
|
|
|
|
49
|
$meta->register_hook( |
91
|
|
|
|
|
|
|
probe => $check, |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |