Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 99db547

Browse files
committedMar 28, 2019
Build a debugging version of Perl
Create a debugging version of Perl with gdb installed so one can take an exact copy of the image with all the symbol tables etc etc.
1 parent f1ee8c9 commit 99db547

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed
 

‎config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
builds:
33
- main
44
- slim
5+
- debug
56

67
options:
78
common: "-Duseshrplib -Dvendorprefix=/usr/local"

‎generate.pl

+35-6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ sub die_with_sample {
6969
EOF
7070
chomp $docker_slim_run_purge;
7171

72+
my $docker_rm_sources = <<'OEF';
73+
rm -fr ./cpanm /root/.cpanm /usr/src/perl /usr/src/{{cpanm_dist_name}}* /tmp/*
74+
OEF
75+
chomp $docker_rm_sources;
76+
77+
my $docker_rm_sources_install = <<'OEF';
78+
rm -fr ./cpanm /root/.cpanm /tmp/* /usr/src/{{cpanm_dist_name}}* \
79+
&& apt-get update \
80+
&& apt-get install --no-install-recommends -y gdb \
81+
&& rm -fr /var/cache/apt/* /var/lib/apt/lists/*
82+
OEF
83+
chomp $docker_rm_sources_install;
84+
85+
chomp $docker_rm_sources;
7286
my $config = do {
7387
open my $fh, '<', 'config.yml' or die "Couldn't open config";
7488
local $/;
@@ -144,20 +158,22 @@ sub die_with_sample {
144158

145159
$release->{extra_flags} ||= '';
146160
$release->{debian_release} ||= 'stretch';
161+
my $debug_flags = '';
147162

148-
if ($build =~ /main/) {
163+
if ($build =~ /(main|debug)/) {
149164
$release->{image} = 'buildpack-deps';
150165
$release->{tag} = $release->{debian_release};
166+
if ($build =~ /debug/) {
167+
# older versions may required -Doptimise=-g
168+
$debug_flags = " -Doptimise=-g -DEBUGGING=both";
169+
}
151170
}
152171
else {
153172
$release->{image} = 'debian';
154173
$release->{tag} = "@{[ $release->{debian_release} ]}-slim";
155174
}
156175

157176
my $output = $template;
158-
$output =~ s/\{\{$_\}\}/$release->{$_}/mg
159-
for (qw(version pause extra_flags sha256 type url image tag cpanm_dist_name cpanm_dist_url cpanm_dist_sha256));
160-
$output =~ s/\{\{args\}\}/$builds{$build}/mg;
161177

162178
if ($build =~ /slim/) {
163179
$output =~ s/\{\{docker_slim_run_install\}\}/$docker_slim_run_install/mg;
@@ -168,6 +184,19 @@ sub die_with_sample {
168184
$output =~ s/\{\{docker_slim_run_purge\}\}/true/mg;
169185
}
170186

187+
if ($build eq 'debug') {
188+
$output =~ s/\{\{docker_rm_sources\}\}/$docker_rm_sources_install/mg;
189+
}
190+
else {
191+
$output =~ s/\{\{docker_rm_sources\}\}/$docker_rm_sources/mg;
192+
}
193+
194+
$output =~ s/\{\{$_\}\}/$release->{$_}/mg
195+
for (qw(version pause extra_flags sha256 type url image tag cpanm_dist_name cpanm_dist_url cpanm_dist_sha256));
196+
$output =~ s/\{\{args\}\}/$builds{$build}/mg;
197+
198+
$output =~ s/ \{\{debug_flags\}\}/$debug_flags/mg;
199+
171200
my $dir = sprintf "%i.%03i.%03i-%s", ($release->{version} =~ /(\d+)\.(\d+)\.(\d+)/), $build;
172201

173202
mkdir $dir unless -d $dir;
@@ -277,7 +306,7 @@ =head1 DESCRIPTION
277306
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
278307
&& archBits="$(dpkg-architecture --query DEB_BUILD_ARCH_BITS)" \
279308
&& archFlag="$([ "$archBits" = '64' ] && echo '-Duse64bitall' || echo '-Duse64bitint')" \
280-
&& ./Configure -Darchname="$gnuArch" "$archFlag" {{args}} {{extra_flags}} -des \
309+
&& ./Configure -Darchname="$gnuArch" "$archFlag" {{args}} {{extra_flags}} {{debug_flags}} -des \
281310
&& make -j$(nproc) \
282311
&& {{test}} \
283312
&& make install \
@@ -286,7 +315,7 @@ =head1 DESCRIPTION
286315
&& echo '{{cpanm_dist_sha256}} *{{cpanm_dist_name}}.tar.gz' | sha256sum -c - \
287316
&& tar -xzf {{cpanm_dist_name}}.tar.gz && cd {{cpanm_dist_name}} && perl bin/cpanm . && cd /root \
288317
&& {{docker_slim_run_purge}} \
289-
&& rm -fr ./cpanm /root/.cpanm /usr/src/perl /usr/src/{{cpanm_dist_name}}* /tmp/*
318+
&& {{docker_rm_sources}}
290319
291320
WORKDIR /root
292321

0 commit comments

Comments
 (0)