line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
2170
|
use v5.14.0; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
160
|
|
2
|
4
|
|
|
4
|
|
47
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
180
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package OS::Package::Role::Build; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Provides build method for OS::Package object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.2.7'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
20
|
use OS::Package::Log; |
|
4
|
|
|
|
|
26
|
|
|
4
|
|
|
|
|
324
|
|
10
|
4
|
|
|
4
|
|
25
|
use File::Basename qw( basename dirname ); |
|
4
|
|
|
|
|
36
|
|
|
4
|
|
|
|
|
259
|
|
11
|
4
|
|
|
4
|
|
2781
|
use IPC::Cmd qw( can_run run ); |
|
4
|
|
|
|
|
176974
|
|
|
4
|
|
|
|
|
256
|
|
12
|
4
|
|
|
4
|
|
1879
|
use Env qw( $CC $HOME ); |
|
4
|
|
|
|
|
4014
|
|
|
4
|
|
|
|
|
24
|
|
13
|
4
|
|
|
4
|
|
3430
|
use File::Temp; |
|
4
|
|
|
|
|
33666
|
|
|
4
|
|
|
|
|
290
|
|
14
|
4
|
|
|
4
|
|
28
|
use Try::Tiny; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
158
|
|
15
|
4
|
|
|
4
|
|
17
|
use Role::Tiny; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
31
|
|
16
|
4
|
|
|
4
|
|
799
|
use Path::Tiny; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
185
|
|
17
|
4
|
|
|
4
|
|
11022
|
use Template; |
|
4
|
|
|
|
|
68782
|
|
|
4
|
|
|
|
|
1122
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub build { |
20
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $template = Path::Tiny->tempfile; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $temp_sh = sprintf '%s/install.sh', $self->artifact->workdir; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $vars = { |
27
|
|
|
|
|
|
|
FAKEROOT => $self->fakeroot, |
28
|
|
|
|
|
|
|
WORKDIR => $self->artifact->workdir, |
29
|
|
|
|
|
|
|
PREFIX => $self->prefix, |
30
|
|
|
|
|
|
|
DISTFILE => $self->artifact->distfile |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if ( defined $self->install ) { |
34
|
0
|
|
|
|
|
|
$template->spew( $self->install ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
0
|
|
|
|
|
|
return 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ( ! path($self->fakeroot)->exists ) { |
41
|
0
|
|
|
|
|
|
path($self->fakeroot)->mkpath; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $tt = Template->new( { INCLUDE_PATH => dirname($template) } ); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$tt->process( basename( $template->absolute ), $vars, $temp_sh ); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $command = [ can_run('bash'), '-e', $temp_sh ]; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$LOGGER->info( sprintf 'building: %s', $self->name ); |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if ( defined $self->artifact->archive ) { |
53
|
0
|
|
|
|
|
|
chdir path($self->artifact->archive->extract_path)->realpath; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) = |
57
|
|
|
|
|
|
|
run( command => $command ); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
foreach ( @{$full_buf} ) { |
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$LOGGER->debug($_); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
chdir $HOME; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
if ( !$success ) { |
66
|
0
|
|
|
|
|
|
$LOGGER->logcroak( sprintf "install script failed: %s\n", |
67
|
|
|
|
|
|
|
$error_message ); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return 2; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return 1; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |