Skip to content

Commit 51ac268

Browse files
committed
generate.pl: patch cpanm to set --no-lwp by default
Let cpanm avoid having to use LWP when it is available, since it will require LWP::Protocol::https now that cpanm is patched to use HTTPS by default. Also re-run perltidy.
1 parent 8a259ae commit 51ac268

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

generate.pl

100755100644
+22-13
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ sub die_with_sample {
6464
chomp $docker_slim_run_install;
6565

6666
my $docker_slim_run_purge = <<'EOF';
67-
savedPackages="ca-certificates make netbase zlib1g-dev libssl-dev" \
67+
savedPackages="ca-certificates curl make netbase zlib1g-dev libssl-dev" \
6868
&& apt-mark auto '.*' > /dev/null \
6969
&& apt-mark manual $savedPackages \
7070
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
@@ -87,21 +87,27 @@ sub die_with_sample {
8787

8888
my %install_modules = (
8989
cpanm => {
90-
name => "App-cpanminus-1.7047",
91-
url => "https://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7047.tar.gz",
90+
name => "App-cpanminus-1.7047",
91+
url => "https://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7047.tar.gz",
92+
9293
# sha256 taken from http://www.cpan.org/authors/id/M/MI/MIYAGAWA/CHECKSUMS
9394
sha256 => "963e63c6e1a8725ff2f624e9086396ae150db51dd0a337c3781d09a994af05a5",
94-
patch => q[perl -pi -E 's{http://(www\.cpan\.org|backpan\.perl\.org|cpan\.metacpan\.org|fastapi\.metacpan\.org|cpanmetadb\.plackperl\.org)}{https://$1}g' bin/cpanm],
95+
96+
patch_https =>
97+
q[perl -pi -E 's{http://(www\.cpan\.org|backpan\.perl\.org|cpan\.metacpan\.org|fastapi\.metacpan\.org|cpanmetadb\.plackperl\.org)}{https://$1}g' bin/cpanm],
98+
patch_nolwp => q[perl -pi -E 's{try_lwp=>1}{try_lwp=>0}g' bin/cpanm],
9599
},
96100
iosocketssl => {
97-
name => "IO-Socket-SSL-2.085",
98-
url => "https://www.cpan.org/authors/id/S/SU/SULLR/IO-Socket-SSL-2.085.tar.gz",
101+
name => "IO-Socket-SSL-2.085",
102+
url => "https://www.cpan.org/authors/id/S/SU/SULLR/IO-Socket-SSL-2.085.tar.gz",
103+
99104
# sha256 taken from http://www.cpan.org/authors/id/S/SU/SULLR/CHECKSUMS
100105
sha256 => "95b2f7c0628a7e246a159665fbf0620d0d7835e3a940f22d3fdd47c3aa799c2e",
101106
},
102107
netssleay => {
103-
name => "Net-SSLeay-1.94",
104-
url => "https://www.cpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.94.tar.gz",
108+
name => "Net-SSLeay-1.94",
109+
url => "https://www.cpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.94.tar.gz",
110+
105111
# sha256 taken from http://www.cpan.org/authors/id/C/CH/CHRISN/CHECKSUMS
106112
sha256 => "9d7be8a56d1bedda05c425306cc504ba134307e0c09bda4a788c98744ebcd95d",
107113
},
@@ -133,8 +139,8 @@ sub die_with_sample {
133139

134140
my $patch;
135141
my $tarball = CPAN::Perl::Releases::MetaCPAN::perl_tarballs($release->{version})->{'tar.gz'};
136-
my ($file) = File::Basename::fileparse($tarball);
137-
my $url = "https://cpan.metacpan.org/authors/id/$tarball";
142+
my ($file) = File::Basename::fileparse($tarball);
143+
my $url = "https://cpan.metacpan.org/authors/id/$tarball";
138144
if (-f "downloads/$file" && `sha256sum downloads/$file` =~ /^\Q$release->{sha256}\E\s+\Qdownloads\/$file\E/) {
139145
print "Skipping download of $file, already current\n";
140146
}
@@ -169,9 +175,9 @@ sub die_with_sample {
169175
my $module = $install_modules{$name};
170176
$release->{"${name}_dist_$_"} = $module->{$_} for keys %$module;
171177
}
172-
$release->{"cpm_dist_$_"} = $cpm{$_} for keys %cpm;
178+
$release->{"cpm_dist_$_"} = $cpm{$_} for keys %cpm;
173179

174-
$release->{extra_flags} ||= '';
180+
$release->{extra_flags} ||= '';
175181

176182
$release->{image} = $build =~ /main/ ? 'buildpack-deps' : 'debian';
177183

@@ -214,8 +220,10 @@ sub die_with_sample {
214220
$output =~ s/\{\{test\}\}/TEST_JOBS=\$(nproc) make test_harness/;
215221
}
216222
elsif ($release->{run_tests} eq "no") {
223+
217224
# https://metacpan.org/pod/Devel::PatchPerl#CAVEAT
218225
$output =~ s/\{\{test\}\}/LD_LIBRARY_PATH=. .\/perl -Ilib -de0/;
226+
219227
# https://metacpan.org/pod/distribution/perl/INSTALL#Building-a-shared-Perl-library
220228
}
221229
else {
@@ -327,7 +335,8 @@ =head1 DESCRIPTION
327335
&& curl -fLO {{cpanm_dist_url}} \
328336
&& echo '{{cpanm_dist_sha256}} *{{cpanm_dist_name}}.tar.gz' | sha256sum --strict --check - \
329337
&& tar -xzf {{cpanm_dist_name}}.tar.gz && cd {{cpanm_dist_name}} \
330-
&& {{cpanm_dist_patch}} \
338+
&& {{cpanm_dist_patch_https}} \
339+
&& {{cpanm_dist_patch_nolwp}} \
331340
&& perl bin/cpanm . && cd /root \
332341
&& curl -fLO '{{netssleay_dist_url}}' \
333342
&& echo '{{netssleay_dist_sha256}} *{{netssleay_dist_name}}.tar.gz' | sha256sum --strict --check - \

0 commit comments

Comments
 (0)