3
3
use strict;
4
4
use warnings;
5
5
use YAML::XS;
6
+ use Devel::PatchPerl;
7
+ use LWP::Simple;
6
8
7
9
sub die_with_sample {
8
10
die <<EOF ;
@@ -42,8 +44,45 @@ sub die_with_sample {
42
44
die_with_sample unless defined $yaml -> {releases };
43
45
die_with_sample unless ref $yaml -> {releases } eq " ARRAY" ;
44
46
47
+ if (! -d " downloads" ) {
48
+ mkdir " downloads" or die " Couldn't create a downloads directory" ;
49
+ }
50
+
45
51
for my $release (@{$yaml -> {releases }}) {
46
52
do { die_with_sample unless $release -> {$_ }} for (qw( version pause sha1) );
53
+
54
+ die " Bad version: $release ->{version}" unless $release -> {version } =~ / \A 5\.\d +\.\d +\Z / ;
55
+
56
+ my $patch ;
57
+ my $file = " perl-$release ->{version}.tar.bz2" ;
58
+ my $url = " http://www.cpan.org/src/5.0/$file " ;
59
+ if (-f " downloads/$file " &&
60
+ ` sha1sum downloads/$file ` =~ / ^\Q $release ->{sha1}\E\s +\Q downloads\/ $file \E / ) {
61
+ print " Skipping download of $file , already current\n " ;
62
+ } else {
63
+ print " Downloading $url \n " ;
64
+ getstore($url , " downloads/$file " );
65
+ }
66
+ {
67
+ my $dir = " downloads/perl-$release ->{version}" ;
68
+ qx{ rm -fR $dir } ;
69
+ mkdir $dir or die " Couldn't create $dir " ;
70
+ qx{
71
+ tar -C "downloads" -jxf $dir .tar.bz2 &&\
72
+ cd $dir &&\
73
+ find . -exec chmod u+w {} + &&\
74
+ git init &&\
75
+ git add . &&\
76
+ git commit -m tmp
77
+ } ;
78
+ die " Couldn't create a temp git repo for $release ->{version}" if $? != 0;
79
+ Devel::PatchPerl-> patch_source($release -> {version }, $dir );
80
+ $patch = qx{
81
+ cd $dir && git commit -am tmp >/dev/null 2>/dev/null && git format-patch -1 --stdout
82
+ } ;
83
+ die " Couldn't create a Devel::PatchPerl patch for $release ->{version}" if $? != 0;
84
+ }
85
+
47
86
$release -> {pause } =~ s # (((.).).*)# $3 /$2 /$1 # ;
48
87
$release -> {extra_flags } = " " unless defined $release -> {extra_flags };
49
88
@@ -58,14 +97,10 @@ sub die_with_sample {
58
97
59
98
mkdir $dir unless -d $dir ;
60
99
61
- # glob switches behavior in scalar context, so force an intermediate
62
- # list context so we can get the count
63
- if (() = glob " $dir /*.patch" ) {
64
- $output =~ s # {{copy_patches}}# COPY *.patch /usr/src/perl/# ;
65
- $output =~ s # {{apply_patches}}# cat *.patch | patch -p1# ;
66
- } else {
67
- $output =~ s / {{copy_patches}}\n // mg ;
68
- $output =~ s / .*{{apply_patches}}.*\n // mg ;
100
+ # Set up the generated DevelPatchPerl.patch
101
+ {
102
+ open (my $fh , " >$dir /DevelPatchPerl.patch" );
103
+ print $fh $patch ;
69
104
}
70
105
71
106
if (defined $release -> {test_parallel } && $release -> {test_parallel } eq " no" ) {
@@ -152,14 +187,14 @@ =head1 DESCRIPTION
152
187
&& rm -fr /var/lib/apt/lists/*
153
188
154
189
RUN mkdir /usr/src/perl
155
- {{copy_patches}}
190
+ COPY DevelPatchPerl.patch /usr/src/perl/
156
191
WORKDIR /usr/src/perl
157
192
158
193
RUN curl -SL https://cpan.metacpan.org/authors/id/{{pause}}/perl-{{version}}.tar.bz2 -o perl-{{version}}.tar.bz2 \
159
194
&& echo '{{sha1}} *perl-{{version}}.tar.bz2' | sha1sum -c - \
160
195
&& tar --strip-components=1 -xjf perl-{{version}}.tar.bz2 -C /usr/src/perl \
161
196
&& rm perl-{{version}}.tar.bz2 \
162
- && {{apply_patches}} \
197
+ && cat DevelPatchPerl.patch | patch -p1
163
198
&& ./Configure {{args}} {{extra_flags}} -des \
164
199
&& make -j$(nproc) \
165
200
&& {{test}} \
0 commit comments