Archive

Posts Tagged ‘cpan2dist’

If you do a corporate CPAN, please do it properly!

May 25th, 2009 1 comment

Coming from the “bad implementations of good ideas” department: Corporate CPAN.

It’s a good idea, but a completely wrong solution. If someone is going to implement this, the proper way is not creating a PAUSE and CPAN mirror or anything like it. Corporate requirements are different. What you really need is a revival of http://debian.pkgs.cpan.org/ and also complete repositories for RHEL5, Debian, Ubuntu LTS, SLES9/10 etc. Those can be mirrored at will by usual and well-tested tools.

Thank you.

Update: Removed last sentence, it’s been a “thinko” on my side :(

Taming cpan2dist on Ubuntu 8.10

January 4th, 2009 3 comments

cpan2dist is great. Easily one of the examples why people at Debian (and its derivates) absolutely love Perl and CPAN. However, it requires some fiddling to get right and since I’ve just done that today I’d like to write this stuff down for generations to come.

A quick introduction for those who are unfamiliar with cpan2dist: it fetches a Perl package from CPAN and installs it into your system using distribution’s tools. Thus you can resolve possible distribution upgrades painlessly, since every Perl package is also shown in your package management. It’s part of Perl 5.10 distribution and makes native package installation easy.

There are however some catches and the first hurdle comes at the very beginning: distribution-specific packaging is done with plugins and sadly Intrepid does not include the Debian plugin for cpan2dist, CPANPLUS::Dist::Deb. Since you can’t install that one from packages yet (due to lack of CPANPLUS::Dist::Deb, welcome to recursion), you’d have to install it manually — the good thing is, it will be the only package installed manually and it also can be replaced with a packaged one after bootstrapping the whole system. Just run

1
cpanp install CPANPLUS::Dist::Deb

and the first step is done!

Now cpan2dist can be used. Let’s reinstall CPANPLUS::Dist::Deb, this time as a Debian package!

1
cpan2dist --format CPANPLUS::Dist::Deb --buildprereq --install --skiptest CPANPLUS::Dist::Deb

It should give you a sudo prompt at some point, this is because it installs the Debian package already, so you should be done in a couple of seconds.

The options’ meanings (in this order): the desired format of the packages, pre-requisites should be all built, packages should be installed, tests should not be executed before build (time saver) and module CPANPLUS::Dist::Deb is being built.

However, we are not done yet. You’d notice that cpan2dist tries to resolve some dependencies which are provided by basic Perl packages perl, perl-base and perl-modules. These might, but in most cases should not be downloaded and built from CPAN. Luckily, cpan2dist can be provided with an “ignore list”, the downside is that the default one is tiny und thus mostly useless. We’d have to recreate this list from our system:

1
dpkg -L perl perl-base perl-modules | grep \.pm$ | sed 's/^\/usr\/\(share\|lib\)\/perl\/[.0123456789]*\/\(.*\)\.pm$/^\2$/g' | sed 's/\//::/g' > ignorelist

This is my recipe. I get the list of all *.pm files from perl, perl-base and perl-modules and re-create the module name from its path. Every entry becomes a pattern (e.g. ^Test::Simple$) so that module names wouldn’t match as substrings and the whole list is dumped to ignorelist. Now we have to add an --ignorelist ignorelist option to the cpan2dist command line.

This should round it up — if you are lucky, everything goes well and you’d have an installed module as a Debian package. If you have some bad karma on a particular day, you’d end up with some errors, all of which can be solved with some manual package installation and careful reading.

One problem remains though: cpan2dist doesn’t seem to check whether a particular package is available from the archive. But that’s only a small nuisance in an otherwise really useful package.