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