Skip to content

Commit f8b2ff3

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 ccda32e commit f8b2ff3

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
@@ -46,6 +46,12 @@ sub die_with_sample {
4646
"64bit,threaded" => "-Dusethreads -Duse64bitall $common",
4747
);
4848

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

@@ -91,10 +97,12 @@ sub die_with_sample {
9197
$release->{pause} =~ s#(((.).).*)#$3/$2/$1#;
9298
$release->{extra_flags} = "" unless defined $release->{extra_flags};
9399
$release->{_tag} = $release->{buildpack_deps} || "stretch";
100+
$release->{"cpanm_dist_$_"} = $cpanm{$_} for keys %cpanm;
94101

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

100108
my $dir = sprintf "%i.%03i.%03i-%s",
@@ -208,10 +216,10 @@ =head1 DESCRIPTION
208216
&& {{test}} \
209217
&& make install \
210218
&& cd /usr/src \
211-
&& curl -LO https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm \
212-
&& chmod +x cpanm \
213-
&& ./cpanm App::cpanminus \
214-
&& rm -fr ./cpanm /root/.cpanm /usr/src/perl /tmp/*
219+
&& curl -LO {{cpanm_dist_url}} \
220+
&& echo '{{cpanm_dist_sha256}} *{{cpanm_dist_name}}.tar.gz' | sha256sum -c - \
221+
&& tar -xzf {{cpanm_dist_name}}.tar.gz && cd {{cpanm_dist_name}} && perl bin/cpanm . && cd /root \
222+
&& rm -fr ./cpanm /root/.cpanm /usr/src/perl /usr/src/{{cpanm_dist_name}}* /tmp/*
215223
216224
WORKDIR /root
217225

0 commit comments

Comments
 (0)