A .deb
package is an easy solution for distributing Perl modules to
Debian-based systems. Unlike manual installation using Module::Build
, it does
not require re-installation whenever the perl minor version changes. Unlike
project-specific cpanm
or carton
setups, the module is available
system-wide and can easily be used in random Perl scripts which are not bound
to a project repository.
The Debian package dh-make-perl
(also known as cpan2deb
) does a good job
here. In many cases, creating a personal package for a Perl module is as easy
as cpan2deb Acme::Octarine
. Delegating the build process to Docker may be
useful if you do not have a Debian build host available and would rather avoid
having the build process depend on the (probably not well-defined) state of
your dev machine.
For CPAN modules, all you need is a Debian container with dh-make-perl. Using
this container, run cpan2deb and extract the resulting .deb. You can find a
Dockerfile and some scripts for this task in my
docker-dh-make-perl
repository. The Dockerfile is used to create a dh-make-perl image (so you don't
need to install dh-make-perl in a fresh Debian image whenever you build a
module). scripts/makedeb-docker-helper
builds the package inside the
container and copies it to the out/
directory, and scripts/makedeb-docker
orchestrates the process.
Note: A package generated this way is suitable for personal use. It is not fit for inclusion in the Debian package repository. As all Debian packages must have an author, you need to set the DEBEMAIL and DEBFULLNAME environment variables to appropriate values. Feel free to extend the Dockerfile and scripts as you see fit – the repository is meant to provide a starting point only.
For non-CPAN content (e.g. if you are a module author and do not want to wait for your freshly uploaded release to appear on CPAN, or if you need to build a patched version of a CPAN module), the process is slightly more involvevd. It requires
- additional bind mounts (
docker run -v "${PWD}:/orig:ro"
) to copy the module content into the container, - a manually provided version (in my case via
git describe --dirty
), and - disabling module signing (unless you pass your GPG keyring to the container).
I also manually specify the packages needed for building and testing. I assume
that this is not needed and can be performed automatically by dh-make-perl
--install-deps --install-build-deps
.
Module content and versioning depends on your setup, so I will not provide a
git repository for this case. Please refer to the makedeb-docker
and
makedeb-docker-helper
scripts in
Travel::Routing::DE::VRR,
Travel::Status::DE::IRIS
and
Travel::Status::DE::VRR
for examples.