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