| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tapper::Base; |
|
2
|
|
|
|
|
|
|
# git description: v4.1.4-43-g3d8dee0 |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Tapper - Common functions for all Tapper classes |
|
6
|
|
|
|
|
|
|
$Tapper::Base::VERSION = '5.0.0'; |
|
7
|
2
|
|
|
2
|
|
457095
|
use Moose; |
|
|
2
|
|
|
|
|
380178
|
|
|
|
2
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
12487
|
use common::sense; |
|
|
2
|
|
|
|
|
17
|
|
|
|
2
|
|
|
|
|
9
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
125
|
use 5.010; |
|
|
2
|
|
|
|
|
10
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'MooseX::Log::Log4perl'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub makedir |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
0
|
|
|
0
|
1
|
0
|
my ($self, $dir) = @_; |
|
19
|
0
|
0
|
|
|
|
0
|
return 0 if -d $dir; |
|
20
|
0
|
0
|
0
|
|
|
0
|
if (-e $dir and not -d $dir) { |
|
21
|
0
|
|
|
|
|
0
|
unlink $dir; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
0
|
0
|
|
|
|
0
|
system("mkdir","-p",$dir) == 0 or return "Can't create $dir:$!"; |
|
24
|
0
|
|
|
|
|
0
|
return 0; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub log_and_exec |
|
30
|
|
|
|
|
|
|
{ |
|
31
|
1
|
|
|
1
|
1
|
3501
|
my ($self, @cmd) = @_; |
|
32
|
1
|
|
|
|
|
3
|
my $cmd = join " ",@cmd; |
|
33
|
1
|
|
|
|
|
6
|
$self->log->debug( $cmd ); |
|
34
|
1
|
|
|
|
|
2865
|
my $output=`$cmd 2>&1`; |
|
35
|
1
|
|
|
|
|
10
|
my $retval=$?; |
|
36
|
1
|
50
|
|
|
|
8
|
if (not defined($output)) { |
|
37
|
0
|
|
|
|
|
0
|
$output = "Executing $cmd failed"; |
|
38
|
0
|
|
|
|
|
0
|
$retval = 1; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
1
|
50
|
|
|
|
8
|
chomp $output if $output; |
|
41
|
1
|
50
|
|
|
|
10
|
if ($retval) { |
|
42
|
0
|
0
|
|
|
|
0
|
return ($retval >> 8, $output) if wantarray; |
|
43
|
0
|
|
|
|
|
0
|
return $output; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
1
|
50
|
|
|
|
5
|
return (0, $output) if wantarray; |
|
46
|
1
|
|
|
|
|
20
|
return 0; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; # End of Tapper::Base |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Tapper::Base - Tapper - Common functions for all Tapper classes |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
package Tapper::Some::Class; |
|
64
|
|
|
|
|
|
|
use Moose; |
|
65
|
|
|
|
|
|
|
extends 'Tapper::Base'; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 makedir |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Checks whether a given directory exists and creates it if not. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
@param string - directory to create |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
@return success - 0 |
|
76
|
|
|
|
|
|
|
@return error - error string |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 log_and_exec |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Execute a given command. Make sure the command is logged if requested and none |
|
81
|
|
|
|
|
|
|
of its output pollutes the console. In scalar context the function returns 0 |
|
82
|
|
|
|
|
|
|
for success and the output of the command on error. In array context the |
|
83
|
|
|
|
|
|
|
function always return a list containing the return value of the command and |
|
84
|
|
|
|
|
|
|
the output of the command. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
@param string - command |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
@return success - 0 |
|
89
|
|
|
|
|
|
|
@return error - error string |
|
90
|
|
|
|
|
|
|
@returnlist success - (0, output) |
|
91
|
|
|
|
|
|
|
@returnlist error - (return value of command, output) |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHORS |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Tapper Team <tapper-ops@amazon.com> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Advanced Micro Devices, Inc.. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software, licensed under: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |