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