Skip to content

Commit 4bd2166

Browse files
committed
generate.pl: download sources from MetaCPAN
Use MetaCPAN instead of cpan.org as Perl releases get indexed there faster. This also removes support for setting the release tarball suffix in config.yml, and now defaults to 'tar.gz' as that seems to be the only type supported by the MetaCPAN API.
1 parent 8967d86 commit 4bd2166

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

generate.pl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
use strict;
44
use warnings;
55
use YAML::XS;
6+
use CPAN::Perl::Releases::MetaCPAN;
67
use Devel::PatchPerl;
8+
use File::Basename;
79
use LWP::Simple;
810

911
sub die_with_sample {
@@ -115,9 +117,9 @@ sub die_with_sample {
115117
die "Bad version: $release->{version}" unless $release->{version} =~ /\A5\.\d+\.\d+\Z/;
116118

117119
my $patch;
118-
$release->{type} ||= 'bz2';
119-
my $file = "perl-$release->{version}.tar.$release->{type}";
120-
my $url = "https://www.cpan.org/src/5.0/$file";
120+
my $tarball = CPAN::Perl::Releases::MetaCPAN::perl_tarballs($release->{version})->{'tar.gz'};
121+
my ($file) = File::Basename::fileparse($tarball);
122+
my $url = "https://cpan.metacpan.org/authors/id/$tarball";
121123
if (-f "downloads/$file" && `sha256sum downloads/$file` =~ /^\Q$release->{sha256}\E\s+\Qdownloads\/$file\E/) {
122124
print "Skipping download of $file, already current\n";
123125
}
@@ -130,7 +132,7 @@ sub die_with_sample {
130132
qx{rm -fR $dir};
131133
mkdir $dir or die "Couldn't create $dir";
132134
qx{
133-
tar -C "downloads" -xf $dir.tar.$release->{type} &&\
135+
tar -C "downloads" -xf $dir.tar.gz &&\
134136
cd $dir &&\
135137
find . -exec chmod u+w {} + &&\
136138
git init &&\
@@ -255,7 +257,6 @@ =head1 DESCRIPTION
255257
This should be a list of tags for different Debian versions:
256258
257259
- version: 5.30.0
258-
type: xz
259260
debian_release:
260261
- bullseye
261262
- buster
@@ -292,10 +293,10 @@ =head1 DESCRIPTION
292293
WORKDIR /usr/src/perl
293294
294295
RUN {{docker_slim_run_install}} \
295-
&& curl -fL {{url}} -o perl-{{version}}.tar.{{type}} \
296-
&& echo '{{sha256}} *perl-{{version}}.tar.{{type}}' | sha256sum --strict --check - \
297-
&& tar --strip-components=1 -xaf perl-{{version}}.tar.{{type}} -C /usr/src/perl \
298-
&& rm perl-{{version}}.tar.{{type}} \
296+
&& curl -fL {{url}} -o perl-{{version}}.tar.gz \
297+
&& echo '{{sha256}} *perl-{{version}}.tar.gz' | sha256sum --strict --check - \
298+
&& tar --strip-components=1 -xaf perl-{{version}}.tar.gz -C /usr/src/perl \
299+
&& rm perl-{{version}}.tar.gz \
299300
&& cat *.patch | patch -p1 \
300301
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
301302
&& archBits="$(dpkg-architecture --query DEB_BUILD_ARCH_BITS)" \

0 commit comments

Comments
 (0)