Skip to content

Commit a5b1e61

Browse files
committed
Embed cpanm SHA256 checksum for verifying in image build
Install cpanm in the same fashion as Perl: via source dist with SHA256 checksum. Thanks @tianon for the idea!
1 parent a96dbd5 commit a5b1e61

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

generate.pl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ sub die_with_sample {
4545
"64bit,threaded" => "-Dusethreads -Duse64bitall $common",
4646
);
4747

48+
my %cpanm = (
49+
name => "App-cpanminus-1.7043",
50+
url => "http://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7043.tar.gz",
51+
sha256 => "68a06f7da80882a95bc02c92c7ee305846fb6ab648cf83678ea945e44ad65c65",
52+
);
53+
4854
die_with_sample unless defined $yaml->{releases};
4955
die_with_sample unless ref $yaml->{releases} eq "ARRAY";
5056

@@ -90,10 +96,12 @@ sub die_with_sample {
9096
$release->{url} = $url;
9197
$release->{extra_flags} = "" unless defined $release->{extra_flags};
9298
$release->{_tag} = $release->{buildpack_deps} || "stretch";
99+
$release->{"cpanm_dist_$_"} = $cpanm{$_} for keys %cpanm;
93100

94101
for my $config (keys %builds) {
95102
my $output = $template;
96-
$output =~ s/\{\{$_\}\}/$release->{$_}/mg for (qw(version extra_flags sha256 url _tag));
103+
$output =~ s/\{\{$_\}\}/$release->{$_}/mg
104+
for (qw(version pause extra_flags sha256 url _tag cpanm_dist_name cpanm_dist_url cpanm_dist_sha256));
97105
$output =~ s/\{\{args\}\}/$builds{$config}/mg;
98106

99107
my $dir = sprintf "%i.%03i.%03i-%s",
@@ -201,10 +209,10 @@ =head1 DESCRIPTION
201209
&& {{test}} \
202210
&& make install \
203211
&& cd /usr/src \
204-
&& curl -LO https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm \
205-
&& chmod +x cpanm \
206-
&& ./cpanm App::cpanminus \
207-
&& rm -fr ./cpanm /root/.cpanm /usr/src/perl /tmp/*
212+
&& curl -LO {{cpanm_dist_url}} \
213+
&& echo '{{cpanm_dist_sha256}} *{{cpanm_dist_name}}.tar.gz' | sha256sum -c - \
214+
&& tar -xzf {{cpanm_dist_name}}.tar.gz && cd {{cpanm_dist_name}} && perl bin/cpanm . && cd /root \
215+
&& rm -fr ./cpanm /root/.cpanm /usr/src/perl /usr/src/{{cpanm_dist_name}}* /tmp/*
208216
209217
WORKDIR /root
210218

0 commit comments

Comments
 (0)