A new perl installation tool

Shoichi Kaji
Dec 22, 2019 · 3 min read

Finally I created a new perl installation tool perl-install which is written in shell script.

Motivation

Why did I created a new perl installation tool?
Yes, we already have several perl installation tools. Among them, gugod’s perlbrew and tokuhirom’s perl-build are famous, I think. They are written in perl.

Unfortunately, these days, we cannot assume that there already exists system perl before installing perl. In fact, Apple announced that scripting language runtimes including perl wouldn’t be available by default in future versions of macOS.

So I think it would be nice if we have a perl installation tool that does not depend on perl. Thus I created perl-install, which is written in shell script.

Difficulties

If you try to write perl installation tools in shell script, then you’ll face some difficulties:

  • (1) Devel::PatchPerl is written in perl
    Old perls such as perl 5.8.1 cannot be installed into recent OS.
    Devel::PatchPerl provides the source patching functionality, and if we apply it on old perls, we can build old perls and install them into recent OS.
    But, again, Devel::PatchPerl is written in perl.
  • (2) How do we get perl tarball urls?
    Perl source code tarballs are primally located in each pumpkin’s CPAN directories. So we cannot easily expect perl tarball urls in advance. metacpan has an endpoint that returns perl tarball urls in JSON format.
    Unfortunately, JSON is not easy-to-use by shell script.

How does perl-install overcome these difficulties?

I thought that (1) was the reason why we were not able to create shell-script-based perl installation tool.
However, I found that the complexity of Devel::PatchPerl came from the code for perl 5.5 and 5.6. In fact, I successfully extracted plain patch files for 5.8.1+ from Devel::PatchPerl in https://github.com/skaji/patchperl-extracted. And perl-install internally uses the patchperl-extracted.

As for (2), I prepared a plain text file that contains perl tarball urls in
https://github.com/skaji/perl-releases. It will be automatically updated by GitHub Actions every 30 minutes so that we will not miss perl updates.

By the way, I think it would be nice if metacpan has an endpoint that returns perl tarball urls in plain text format. I created an issue to metacpan: https://github.com/metacpan/metacpan-api/issues/927.
If metacpan team accept the request, I will switch the source to metacpan.

Usage of perl-install

The usage of perl-install is very similar to perl-build:

❯ perl-install --help
Usage: perl-install [options] perl_version prefix
Options:
-A, -D, -U set perl configure options
-l, --list list stable perl versions, and exit
-L, --list-all list all perl versions, and exit
-j, --jobs set make --jobs option
-h, --help show this help
--version show perl-install's version
--noman do not generate man pages
--nopatch do not apply Devel::PatchPerl
--test run test
--work-dir set work directory
Examples:
$ perl-install -l
$ perl-install 5.30.1 ~/perl
$ perl-install 5.30.1 ~/perl-shrplib -Duseithreads -Duseshrplib

Moreover, like perl-build, perl-install can be used as a plenv plugin:

$ git clone https://github.com/skaji/perl-install $(plenv root)/plugins/perl-install# Now you have `plenv install` command powered by perl-install
$ plenv install 5.30.1

Shoichi Kaji

Written by

A Perl hacker

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade