Compiling Perl v5.8 on Debian Slim

tags: debian  slim 

I need a container for Perl v5.8, and I want it to be as small as I can make it. Starting with debian:bookworm-slim, I’d download the v5.8 source, modify it with patchperl, then compile it. But, there were problems.

First, some modules don’t compile. Notably, HTML::TagSet changed its minimal version to v5.10, although LWP, which aims for v5.8.1, depends on it. Then Test::Fatal updated its minimum version to v5.12, although URI, which LWP also needs. Neither of these changes were necessary.

Fixing the modules was easy enough by installing old versions before I start anything else:

cpanm PETDANCE/HTML-TagSet-3.20.tar.gz RJBS/Test-Fatal-0.017.tar.gz

The parent module had some trouble which I didn’t bother to figure out. v5.8 didn’t like something in the tests, so I installed it without running the tests:

cpanm –notest parent

Then I got weird errors trying to install IO::Socket::SSL. This one was really weird. The docker build died with a suspicious error:

#9 42.94 DIED. FAILED tests 1-15 #9 42.94 Failed 15/15 tests, 0.00% okay #9 42.94 t/alpn……………………….FAILED tests 1-5 #9 43.00 Failed 5/5 tests, 0.00% okay #9 43.00 t/auto_verify_hostname…………$!=No such file or directory, $@=IO::Socket::SSL: Bad protocol ‘tcp’, S$SSL_ERROR=IO::Socket::INET configuration failed at t/auto_verify_hostname.t line 34.

This one was a bit tricky, and the change between v5.8 and v5.10 does not show up in the perldelta. After trying lots of different things, I search for Bad protocol 'tcp'. That’s a result of the slim version of a base image that does not distribute /etc/protocols. That file defines the numeric constants for the internet protocols including TCP and UDP. If that file is not there, getprotobynam can’t resolve the names to their constants.

This wasn’t a problem in v5.10 because Socket defined those constants itself and didn’t need getprotobynam. I solved this by creating the file myself:

printf “tcp 6 TCP\nudp 17 UDP\n” » /etc/protocols

I could also get these by installing the data package that has the files:

apt-get install netbase