| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
72671
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
49
|
|
|
2
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
77
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::Deployment; |
|
5
|
|
|
|
|
|
|
$Footprintless::Deployment::VERSION = '1.28'; |
|
6
|
|
|
|
|
|
|
# ABSTRACT: A deployment manager |
|
7
|
|
|
|
|
|
|
# PODNAME: Footprintless::Deployment |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use parent qw(Footprintless::MixableBase); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
73
|
use Carp; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
99
|
|
|
12
|
2
|
|
|
|
|
80
|
use File::Path qw( |
|
13
|
|
|
|
|
|
|
make_path |
|
14
|
2
|
|
|
2
|
|
11
|
); |
|
|
2
|
|
|
|
|
3
|
|
|
15
|
2
|
|
|
|
|
128
|
use Footprintless::Mixins qw ( |
|
16
|
|
|
|
|
|
|
_clean |
|
17
|
|
|
|
|
|
|
_download |
|
18
|
|
|
|
|
|
|
_entity |
|
19
|
|
|
|
|
|
|
_extract_resource |
|
20
|
|
|
|
|
|
|
_resource |
|
21
|
|
|
|
|
|
|
_sub_entity |
|
22
|
2
|
|
|
2
|
|
786
|
); |
|
|
2
|
|
|
|
|
5
|
|
|
23
|
2
|
|
|
|
|
82
|
use Footprintless::Util qw( |
|
24
|
|
|
|
|
|
|
agent |
|
25
|
|
|
|
|
|
|
rebase |
|
26
|
|
|
|
|
|
|
temp_dir |
|
27
|
2
|
|
|
2
|
|
13
|
); |
|
|
2
|
|
|
|
|
2
|
|
|
28
|
2
|
|
|
2
|
|
11
|
use Log::Any; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
7
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub clean { |
|
33
|
2
|
|
|
2
|
1
|
6
|
my ( $self, @options ) = @_; |
|
34
|
2
|
|
|
|
|
8
|
$self->_clean(@options); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub deploy { |
|
38
|
7
|
|
|
7
|
1
|
58
|
my ( $self, %options ) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
7
|
100
|
|
|
|
31
|
if ( $options{to_dir} ) { |
|
41
|
1
|
|
|
|
|
7
|
$self->_ensure_clean_dirs( $options{to_dir} ); |
|
42
|
|
|
|
|
|
|
$self->_deploy_resources( $options{to_dir}, |
|
43
|
1
|
50
|
|
|
|
8
|
( $options{names} ? ( names => $options{names} ) : () ) ); |
|
44
|
1
|
50
|
|
|
|
9
|
&{ $options{extra} }( $options{to_dir} ) if ( $options{extra} ); |
|
|
0
|
|
|
|
|
0
|
|
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
else { |
|
47
|
|
|
|
|
|
|
$self->_local_template( |
|
48
|
|
|
|
|
|
|
sub { |
|
49
|
6
|
|
|
6
|
|
13
|
my ( $to_dir, $resource_dir ) = @_; |
|
50
|
6
|
|
|
|
|
20
|
$self->_ensure_clean_dirs($to_dir); |
|
51
|
|
|
|
|
|
|
$self->_deploy_resources( $resource_dir, |
|
52
|
6
|
50
|
|
|
|
38
|
( $options{names} ? ( names => $options{names} ) : () ) ); |
|
53
|
6
|
50
|
|
|
|
264
|
&{ $options{extra} }($to_dir) if ( $options{extra} ); |
|
|
0
|
|
|
|
|
0
|
|
|
54
|
|
|
|
|
|
|
}, |
|
55
|
|
|
|
|
|
|
rebase => $options{rebase} |
|
56
|
6
|
|
|
|
|
59
|
); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
7
|
|
|
|
|
66
|
$logger->debug("deploy complete"); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _deploy_resources { |
|
63
|
7
|
|
|
7
|
|
23
|
my ( $self, $to_dir, %options ) = @_; |
|
64
|
7
|
|
|
|
|
24
|
my $resources = $self->_sub_entity( 'resources', 1 ); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my @names = |
|
67
|
|
|
|
|
|
|
$options{names} |
|
68
|
7
|
50
|
|
|
|
26
|
? @{ $options{names} } |
|
|
0
|
|
|
|
|
0
|
|
|
69
|
|
|
|
|
|
|
: keys(%$resources); |
|
70
|
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
27
|
$logger->debugf( "deploy %s to %s", \@names, $to_dir ); |
|
72
|
7
|
|
|
|
|
77
|
foreach my $resource_name (@names) { |
|
73
|
13
|
|
|
|
|
25
|
my $resource = $resources->{$resource_name}; |
|
74
|
13
|
100
|
100
|
|
|
57
|
if ( ref($resource) eq 'HASH' && $resource->{extract_to} ) { |
|
75
|
1
|
|
|
|
|
7
|
my $extract_dir = File::Spec->catdir( $to_dir, $resource->{extract_to} ); |
|
76
|
1
|
|
|
|
|
10
|
$logger->tracef( 'extract [%s] to [%s]', $resource, $to_dir ); |
|
77
|
1
|
|
|
|
|
12
|
$self->_extract_resource( $resource, $extract_dir ); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
else { |
|
80
|
12
|
|
|
|
|
73
|
$logger->tracef( 'download [%s] to [%s]', $resource, $to_dir ); |
|
81
|
12
|
|
|
|
|
109
|
$self->_download( $resource, $to_dir ); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _ensure_clean_dirs { |
|
87
|
7
|
|
|
7
|
|
12
|
my ( $self, $base_dir ) = @_; |
|
88
|
7
|
|
|
|
|
21
|
foreach my $dir ( $self->_relative_clean_dirs ) { |
|
89
|
10
|
|
|
|
|
711
|
make_path( File::Spec->catdir( $base_dir, $dir ) ); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _local_template { |
|
94
|
6
|
|
|
6
|
|
55
|
my ( $self, $local_work, @options ) = @_; |
|
95
|
|
|
|
|
|
|
$self->Footprintless::Mixins::_local_template( |
|
96
|
|
|
|
|
|
|
sub { |
|
97
|
6
|
|
|
6
|
|
17
|
my ($to_dir) = @_; |
|
98
|
|
|
|
|
|
|
|
|
99
|
6
|
|
|
|
|
22
|
my $resource_dir = $self->_sub_entity('resource_dir'); |
|
100
|
6
|
100
|
|
|
|
21
|
$resource_dir = |
|
101
|
|
|
|
|
|
|
$resource_dir |
|
102
|
|
|
|
|
|
|
? File::Spec->catdir( $to_dir, $resource_dir ) |
|
103
|
|
|
|
|
|
|
: $to_dir; |
|
104
|
6
|
|
|
|
|
541
|
make_path($resource_dir); |
|
105
|
|
|
|
|
|
|
|
|
106
|
6
|
|
|
|
|
24
|
&$local_work( $to_dir, $resource_dir ); |
|
107
|
|
|
|
|
|
|
}, |
|
108
|
|
|
|
|
|
|
@options |
|
109
|
6
|
|
|
|
|
74
|
); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _relative_clean_dirs { |
|
113
|
7
|
|
|
7
|
|
10
|
my ($self) = @_; |
|
114
|
7
|
|
|
|
|
29
|
my $base = $self->_entity("$self->{coordinate}.to_dir"); |
|
115
|
|
|
|
|
|
|
return |
|
116
|
10
|
50
|
|
|
|
562
|
map { m'/$' ? ( File::Spec->abs2rel( $_, $base ) ) : () } |
|
117
|
7
|
|
|
|
|
12
|
@{ $self->_entity("$self->{coordinate}.clean") }; |
|
|
7
|
|
|
|
|
24
|
|
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |