line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Carmel::Builder; |
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
4
|
1
|
|
|
1
|
|
362
|
use Class::Tiny qw( snapshot cpanfile cpanfile_path repository_base collect_artifact ); |
|
1
|
|
|
|
|
1381
|
|
|
1
|
|
|
|
|
3
|
|
5
|
1
|
|
|
1
|
|
1093
|
use Path::Tiny; |
|
1
|
|
|
|
|
10808
|
|
|
1
|
|
|
|
|
58
|
|
6
|
1
|
|
|
1
|
|
411
|
use File::pushd; |
|
1
|
|
|
|
|
16399
|
|
|
1
|
|
|
|
|
51
|
|
7
|
1
|
|
|
1
|
|
324
|
use Carmel::Lock; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
654
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub tempdir { |
10
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
11
|
0
|
|
0
|
|
|
|
$self->{tempdir} ||= $self->build_tempdir; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub build_tempdir { |
15
|
0
|
|
|
0
|
0
|
|
my %opts = (); |
16
|
|
|
|
|
|
|
$opts{CLEANUP} = $ENV{PERL_FILE_TEMP_CLEANUP} |
17
|
0
|
0
|
|
|
|
|
if exists $ENV{PERL_FILE_TEMP_CLEANUP}; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
Path::Tiny->tempdir(%opts); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub install { |
23
|
0
|
|
|
0
|
0
|
|
my($self, @args) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my @cmd; |
26
|
0
|
0
|
|
|
|
|
if ($self->cpanfile) { |
27
|
0
|
|
|
|
|
|
my $path = Path::Tiny->tempfile; |
28
|
0
|
|
|
|
|
|
$self->cpanfile->save($path); |
29
|
0
|
|
|
|
|
|
@cmd = ("--cpanfile", $path, "--installdeps", "."); |
30
|
|
|
|
|
|
|
} else { |
31
|
0
|
|
|
|
|
|
@cmd = @args; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if ($self->snapshot) { |
35
|
0
|
|
|
|
|
|
my $path = Path::Tiny->tempfile; |
36
|
0
|
|
|
|
|
|
$self->snapshot->write_index($path); |
37
|
0
|
|
|
|
|
|
unshift @cmd, |
38
|
|
|
|
|
|
|
"--mirror-index", $path, |
39
|
|
|
|
|
|
|
"--cascade-search", |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
local $ENV{PERL_CPANM_HOME} = $self->tempdir; |
43
|
0
|
|
|
|
|
|
local $ENV{PERL_CPANM_OPT}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# FIXME: we could set the mirror option to $self->cpanfile in the caller |
46
|
0
|
0
|
|
|
|
|
my $cpanfile = $self->cpanfile_path |
47
|
|
|
|
|
|
|
or die "Can't locate 'cpanfile' to load module list.\n"; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# one mirror for now |
50
|
0
|
|
|
|
|
|
my $mirror = Module::CPANfile->load($cpanfile)->mirrors->[0]; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $lock = Carmel::Lock->new(path => $self->repository_base->child('run')); |
53
|
0
|
|
|
|
|
|
$lock->acquire; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# cleanup perl5 in case it was left from previous runs |
56
|
0
|
|
|
|
|
|
my $lib = $self->repository_base->child('perl5'); |
57
|
0
|
|
|
|
|
|
$lib->remove_tree({ safe => 0 }); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
require Menlo::CLI::Compat; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $cli = Menlo::CLI::Compat->new; |
62
|
0
|
0
|
|
|
|
|
$cli->parse_options( |
|
|
0
|
|
|
|
|
|
63
|
|
|
|
|
|
|
($Carmel::DEBUG ? () : "--quiet"), |
64
|
|
|
|
|
|
|
($mirror ? ("-M", $mirror) : ("--mirror", "https://cpan.metacpan.org/")), |
65
|
|
|
|
|
|
|
"--notest", |
66
|
|
|
|
|
|
|
"--save-dists", $self->repository_base->child('cache'), |
67
|
|
|
|
|
|
|
"-L", $lib, |
68
|
|
|
|
|
|
|
"--no-static-install", |
69
|
|
|
|
|
|
|
@cmd, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$cli->run; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my @artifacts; |
75
|
0
|
|
|
|
|
|
for my $ent ($self->tempdir->child("latest-build")->children) { |
76
|
0
|
0
|
0
|
|
|
|
next unless $ent->is_dir && $ent->child("blib/meta/install.json")->exists; |
77
|
0
|
|
|
|
|
|
push @artifacts, $self->collect_artifact->($ent); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$lib->remove_tree({ safe => 0 }); |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return @artifacts; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub search_module { |
86
|
0
|
|
|
0
|
0
|
|
my($self, $module, $version) = @_; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
local $ENV{PERL_CPANM_HOME} = $self->tempdir; |
89
|
0
|
|
|
|
|
|
local $ENV{PERL_CPANM_OPT}; |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
my $cpanfile = $self->cpanfile_path |
92
|
|
|
|
|
|
|
or die "Can't locate 'cpanfile' to load module list.\n"; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# one mirror for now |
95
|
0
|
|
|
|
|
|
my $mirror = Module::CPANfile->load($cpanfile)->mirrors->[0]; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
require Menlo::CLI::Compat; |
98
|
0
|
|
|
|
|
|
require Carton::Dist; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my $cli = Menlo::CLI::Compat->new; |
101
|
0
|
0
|
|
|
|
|
$cli->parse_options( |
|
|
0
|
|
|
|
|
|
102
|
|
|
|
|
|
|
($Carmel::DEBUG ? () : "--quiet"), |
103
|
|
|
|
|
|
|
($mirror ? ("-M", $mirror) : ()), |
104
|
|
|
|
|
|
|
"--info", |
105
|
|
|
|
|
|
|
"--save-dists", $self->repository_base->child('cache'), |
106
|
|
|
|
|
|
|
".", |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# This needs to be done to setup http backends for mirror #52 |
110
|
0
|
|
|
|
|
|
$cli->setup_home; |
111
|
0
|
|
|
|
|
|
$cli->init_tools; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $dist = $cli->search_module($module, $version); |
114
|
0
|
0
|
|
|
|
|
if ($dist) { |
115
|
|
|
|
|
|
|
return Carton::Dist->new( |
116
|
|
|
|
|
|
|
name => $dist->{distvname}, |
117
|
|
|
|
|
|
|
pathname => $dist->{pathname}, |
118
|
|
|
|
|
|
|
provides => { |
119
|
|
|
|
|
|
|
$dist->{module} => { |
120
|
|
|
|
|
|
|
version => $dist->{module_version}, |
121
|
|
|
|
|
|
|
}, |
122
|
|
|
|
|
|
|
}, |
123
|
|
|
|
|
|
|
version => $dist->{version}, |
124
|
0
|
|
|
|
|
|
); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub rollout { |
131
|
0
|
|
|
0
|
0
|
|
my($self, $install_base, $artifacts) = @_; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
require ExtUtils::Install; |
134
|
0
|
|
|
|
|
|
require ExtUtils::InstallPaths; |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
for my $artifact (@$artifacts) { |
137
|
0
|
|
|
|
|
|
my $dir = pushd $artifact->path; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my $paths = ExtUtils::InstallPaths->new(install_base => $install_base); |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
printf "Installing %s to %s\n", $artifact->distname, $install_base; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# ExtUtils::Install writes to STDOUT |
144
|
0
|
|
|
|
|
|
open my $fh, ">", \my $output; |
145
|
0
|
0
|
|
|
|
|
my $old; $old = select $fh unless $Carmel::DEBUG; |
|
0
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my %result; |
148
|
0
|
|
|
|
|
|
ExtUtils::Install::install([ |
149
|
|
|
|
|
|
|
from_to => $paths->install_map, |
150
|
|
|
|
|
|
|
verbose => 0, |
151
|
|
|
|
|
|
|
dry_run => 0, |
152
|
|
|
|
|
|
|
uninstall_shadows => 0, |
153
|
|
|
|
|
|
|
skip => undef, |
154
|
|
|
|
|
|
|
always_copy => 1, |
155
|
|
|
|
|
|
|
result => \%result, |
156
|
|
|
|
|
|
|
]); |
157
|
|
|
|
|
|
|
|
158
|
0
|
0
|
|
|
|
|
select $old unless $Carmel::DEBUG; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |