| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CPAN::Packager; |
|
2
|
1
|
|
|
1
|
|
34
|
use 5.00800; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
2372
|
|
|
3
|
1
|
|
|
1
|
|
983
|
use Mouse; |
|
|
1
|
|
|
|
|
101698
|
|
|
|
1
|
|
|
|
|
7
|
|
|
4
|
1
|
|
|
1
|
|
432
|
use List::MoreUtils qw/uniq/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
116
|
|
|
5
|
1
|
|
|
1
|
|
745
|
use CPAN::Packager::DependencyAnalyzer; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
41
|
|
|
6
|
1
|
|
|
1
|
|
760
|
use CPAN::Packager::BuilderFactory; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
32
|
|
|
7
|
1
|
|
|
1
|
|
599
|
use CPAN::Packager::DownloaderFactory; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
29
|
|
|
8
|
1
|
|
|
1
|
|
571
|
use CPAN::Packager::Config::Merger; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
34
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use CPAN::Packager::Config::Loader; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
10
|
1
|
|
|
1
|
|
708
|
use CPAN::Packager::Util; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
35
|
|
|
11
|
1
|
|
|
1
|
|
7
|
use Log::Log4perl qw(:easy); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
12
|
1
|
|
|
1
|
|
627
|
use Try::Tiny; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1680
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.33'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'builder' => ( |
|
17
|
|
|
|
|
|
|
is => 'rw', |
|
18
|
|
|
|
|
|
|
required => 1, |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'downloader' => ( |
|
22
|
|
|
|
|
|
|
is => 'rw', |
|
23
|
|
|
|
|
|
|
default => 'CPAN', |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'dry_run' => ( |
|
27
|
|
|
|
|
|
|
is => 'rw', |
|
28
|
|
|
|
|
|
|
isa => 'Bool', |
|
29
|
|
|
|
|
|
|
default => 0, |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'conf' => ( is => 'rw', ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'dependency_config_merger' => ( |
|
35
|
|
|
|
|
|
|
is => 'rw', |
|
36
|
|
|
|
|
|
|
default => sub { |
|
37
|
|
|
|
|
|
|
CPAN::Packager::Config::Merger->new; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has 'is_debug' => ( |
|
42
|
|
|
|
|
|
|
is => 'rw', |
|
43
|
|
|
|
|
|
|
lazy => 1, |
|
44
|
|
|
|
|
|
|
default => sub { get_logger('')->level() == $DEBUG } |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'config_loader' => ( |
|
48
|
|
|
|
|
|
|
is => 'rw', |
|
49
|
|
|
|
|
|
|
default => sub { |
|
50
|
|
|
|
|
|
|
CPAN::Packager::Config::Loader->new; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'dependency_analyzer' => ( is => 'rw', ); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has 'always_build' => ( |
|
57
|
|
|
|
|
|
|
is => 'rw', |
|
58
|
|
|
|
|
|
|
isa => 'Int', |
|
59
|
|
|
|
|
|
|
default => 0, |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has 'verbose' => ( |
|
63
|
|
|
|
|
|
|
is => 'rw', |
|
64
|
|
|
|
|
|
|
isa => 'Int', |
|
65
|
|
|
|
|
|
|
default => 0, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub BUILD { |
|
69
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
70
|
0
|
|
|
|
|
|
$self->_setup_dependencies(); |
|
71
|
0
|
|
|
|
|
|
$self->_setup_logger(); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _setup_dependencies { |
|
75
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
76
|
0
|
|
|
|
|
|
$self->_build_dependency_analyzer; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _setup_logger { |
|
80
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
81
|
0
|
0
|
|
|
|
|
my $level = $self->verbose ? $DEBUG : $INFO; |
|
82
|
0
|
|
|
|
|
|
my $layout = '%p: %m{chomp}%n'; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if ( $ENV{CPAN_PACKAGER_DEBUG} ) { |
|
85
|
0
|
|
|
|
|
|
$level = $DEBUG; |
|
86
|
0
|
|
|
|
|
|
$layout = '%p %d{HH:mm:ss} [%c:%L]: %m{chomp}%n'; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Log::Log4perl->easy_init( |
|
90
|
0
|
|
|
|
|
|
{ level => $level, |
|
91
|
|
|
|
|
|
|
layout => $layout |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _build_dependency_analyzer { |
|
97
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
98
|
0
|
|
|
|
|
|
my $dependency_analyzer |
|
99
|
|
|
|
|
|
|
= CPAN::Packager::DependencyAnalyzer->new( downloader => |
|
100
|
|
|
|
|
|
|
CPAN::Packager::DownloaderFactory->create( $self->downloader ) ); |
|
101
|
0
|
|
|
|
|
|
$self->dependency_analyzer($dependency_analyzer); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
our $config; |
|
105
|
|
|
|
|
|
|
sub make { |
|
106
|
0
|
|
|
0
|
0
|
|
my ( $self, $module, $built_modules ) = @_; |
|
107
|
0
|
0
|
|
|
|
|
die 'module must be passed' unless $module; |
|
108
|
0
|
|
|
|
|
|
INFO("### Building packages for $module ..."); |
|
109
|
0
|
0
|
|
|
|
|
$config = $self->config_loader->load( $self->conf ) unless $config; |
|
110
|
0
|
0
|
|
|
|
|
if($built_modules) { |
|
111
|
0
|
|
|
|
|
|
$config = $self->merge_config( $built_modules, $config ); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
0
|
|
|
|
|
|
$config->{global}->{verbose} = $self->verbose; |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
INFO("### Analyzing dependencies for $module ..."); |
|
116
|
0
|
|
|
|
|
|
my ( $modules, $resolved_module_name ) |
|
117
|
|
|
|
|
|
|
= $self->analyze_module_dependencies( $module, $config ); |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$modules->{$resolved_module_name}->{force_build} |
|
120
|
|
|
|
|
|
|
= 1; # always build target module. |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
$config = $self->merge_config( $modules, $config ) |
|
123
|
|
|
|
|
|
|
if $self->conf; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
$self->_dump_modules( "config modules", $config->{modules} ); |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $sorted_modules = [ |
|
128
|
|
|
|
|
|
|
uniq reverse @{ |
|
129
|
0
|
|
|
|
|
|
CPAN::Packager::Util::topological_sort( $resolved_module_name, |
|
130
|
|
|
|
|
|
|
$config->{modules} ) |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
]; |
|
133
|
0
|
|
|
|
|
|
$self->_dump_modules( "sorted modules", $sorted_modules ); |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
0
|
|
|
|
|
unless ( $self->dry_run ) { |
|
136
|
|
|
|
|
|
|
try { |
|
137
|
0
|
|
|
0
|
|
|
$built_modules = $self->build_modules( $sorted_modules, $config ); |
|
138
|
0
|
|
|
|
|
|
INFO("### Built packages for $module :-)"); |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
catch { |
|
142
|
0
|
|
|
0
|
|
|
$self->_dump_modules( "Sorted modules", $sorted_modules ); |
|
143
|
0
|
|
|
|
|
|
LOGDIE( "### Built packages for $module faied :-(. Cause: " . $_); |
|
144
|
0
|
|
|
|
|
|
}; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
$self->check_confliction; |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
$built_modules; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub check_confliction { |
|
153
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
154
|
0
|
|
|
|
|
|
$self->dependency_analyzer->confliction_checker->check_conflict(); |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub _dump_modules { |
|
158
|
0
|
|
|
0
|
|
|
my ( $self, $dump_type, $modules ) = @_; |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
return unless $self->is_debug; |
|
161
|
0
|
0
|
|
|
|
|
return unless $ENV{CPAN_PACKAGER_ENABLE_DUMP}; |
|
162
|
0
|
|
|
|
|
|
require Data::Dumper; |
|
163
|
0
|
|
|
|
|
|
DEBUG("$dump_type: "); |
|
164
|
0
|
|
|
|
|
|
DEBUG( Data::Dumper::Dumper $modules ); |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub merge_config { |
|
168
|
0
|
|
|
0
|
0
|
|
my ( $self, $modules, $config ) = @_; |
|
169
|
0
|
|
|
|
|
|
$self->dependency_config_merger->merge_module_config( $modules, $config ); |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub build_modules { |
|
173
|
0
|
|
|
0
|
0
|
|
my ( $self, $modules, $config ) = @_; |
|
174
|
0
|
|
|
|
|
|
my $builder_name = $self->builder; |
|
175
|
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
my $builder |
|
177
|
|
|
|
|
|
|
= CPAN::Packager::BuilderFactory->create( $builder_name, $config ); |
|
178
|
0
|
|
|
|
|
|
$builder->print_installed_packages; |
|
179
|
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
for my $module ( @{$modules} ) { |
|
|
0
|
|
|
|
|
|
|
|
181
|
0
|
0
|
0
|
|
|
|
next if $module->{skip_build} && $module->{skip_build} == 1; |
|
182
|
0
|
0
|
|
|
|
|
next unless $module->{module}; |
|
183
|
0
|
0
|
|
|
|
|
next if $module->{build_status}; |
|
184
|
|
|
|
|
|
|
next |
|
185
|
0
|
0
|
0
|
|
|
|
if $builder->is_installed( $module->{module} ) |
|
|
|
|
0
|
|
|
|
|
|
186
|
|
|
|
|
|
|
&& !$self->always_build |
|
187
|
|
|
|
|
|
|
&& !$module->{force_build}; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# FIXME: RPM is not consider force_build setting. |
|
190
|
0
|
0
|
|
|
|
|
if ( $self->always_build ) { |
|
191
|
0
|
|
|
|
|
|
$module->{force_build} = 1; # afffect force_build flag. |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
|
my $package = $builder->build($module); |
|
195
|
|
|
|
|
|
|
|
|
196
|
0
|
0
|
|
|
|
|
if ($package) { |
|
197
|
0
|
|
|
|
|
|
$module->{build_status} = 'success'; |
|
198
|
0
|
|
|
|
|
|
INFO("$module->{module} created ($package)"); |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
else { |
|
201
|
0
|
|
|
|
|
|
$module->{build_status} = 'failed'; |
|
202
|
0
|
|
|
|
|
|
die("$module->{module} failed"); |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
my $built_modules = {}; |
|
207
|
0
|
|
|
|
|
|
foreach my $module (@{$modules}) { |
|
|
0
|
|
|
|
|
|
|
|
208
|
0
|
0
|
|
|
|
|
if(exists $module->{module}) { |
|
|
|
0
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
$built_modules->{$module->{module}} = $module; |
|
210
|
|
|
|
|
|
|
} elsif (exists $module->{original_module}) { |
|
211
|
0
|
|
|
|
|
|
$built_modules->{$module->{original_module}} = $module; |
|
212
|
|
|
|
|
|
|
} else { |
|
213
|
0
|
|
|
|
|
|
$built_modules->{$module} = $module; |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
return $built_modules; |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub analyze_module_dependencies { |
|
221
|
0
|
|
|
0
|
0
|
|
my ( $self, $module, $config ) = @_; |
|
222
|
0
|
|
|
|
|
|
INFO("Analyzing dependencies for $module ..."); |
|
223
|
0
|
|
|
|
|
|
my $analyzer = $self->dependency_analyzer; |
|
224
|
0
|
|
|
|
|
|
my $resolved_module = $analyzer->analyze_dependencies( $module, $config ); |
|
225
|
0
|
|
|
|
|
|
return ( $analyzer->modules, $resolved_module ); |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
1
|
|
|
1
|
|
9
|
no Mouse; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
229
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
230
|
|
|
|
|
|
|
1; |
|
231
|
|
|
|
|
|
|
__END__ |