Updating custom CPAN modules on Debian

On Debian based distributions, a handy tool called dh-make-perl can be installed to ease the installation of CPAN Perl modules on the system.
This tool will create a Debian package of the CPAN module, and can also install this package automatically. The advantage of this procedure is that when the CPAN module is picked by the Debian Perl Group for maintenance, an updated Debian will be installable through apt-get.

Of course, most people don’t want to wait on a group of other people to update a piece of software.

I wrote this script to make my life a little bit easier, but it contains no rocket science. I’ve written it in Perl but it could have been just as easily written in Bash. But Perl is much cooler than Bash, and being cool is all that matters!

The script actually uses some command line tools, that should be installed. apt-cache and egrep are installed by default on Debian(-based) systems, dh-make-perl must be installed separately.

Once dh-make-perl is installed, check out the man page for its options and arguments.

What are the steps required in the script:

  • get a list of Perl packages
  • filter out packages installed by dh-make-perl
  • check if we really need to upgrade
  • create new packages out of the CPAN versions
  • optionally display the required packages

Packages created by dh-make-perl can be filtered out based on the package description. dh-make-perl adds ‘…automagically extracted from the module by dh-make-perl‘ to the package description when creating a Debian package.

It is possible that the package building of the CPAN module fails because the required modules or packages are missing. This information will be displayed when the scripts finishes. You will have to install this missing requirements and relaunch the script afterwards.

When build the Debian with dh-make-perl, the option ‘–recursive‘ will be used. This will also create Debian packages of required modules defined by the CPAN module.

When all these packages have been created, installed them with the dpkg command:

I’ve used the $(ls -rt *.dpkg) syntax because the packages will be in the order like they have been built.

The script:

Some output produced by the script:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.