Perl 5 point 10 in layman terms

As a developer, one of the great things I love about Gentoo (Linux distribution with BSD 'ports-like' package management) is the feeling it gives you that eveything you do to your system has an undo button. (For the record, I have at least come to my senses about this need in a production situation.)  A great example of this is layman, which I think is fair to say is a slightly more intuitive version of managing an apt sources file.  Today I realised there is a portage overlay (for use with layman) that I have been missing out on and perhaps it's because it's a fairly recent addition but it comes just in time for me to try and get more serious about hacking in Perl.

With the perl-experimental overlay I anticipated the knock-on effect might be that I am no longer tempted to write a script for keeping my /etc/portage/package.keywords file sorted alphabetically automatically.  I was half-right (thanks to a useful awk command from the Gentoo wiki) but in the end this need paled in significance compared to the delights of coming across a more up-to-date utility for handling cpan builds and then ending up with a system for reliably predicting where generated ebuilds from this utility will land in the filesystem. Not that it matters that much, I suppose.

If you're new to overlays, these are the steps for setting up perl-experimental on a fresh Gentoo system:

# emerge layman
# emerge dev-util/git
# layman -a perl-experimental

At this point I had to run the following before I could eix-sync/eix-update or use emerge --search:

# emerge --regen

The next thing is updating your /etc/make.conf file so that portage will be aware of layman specific ebuilds. Add this line to the end:

source /usr/local/portage/layman/make.conf

Now to (optionally) unmask packages in the overlay you can use the following awky goodness, as documented in the official Gentoo wiki...

# ls -1 /usr/local/portage/layman/perl-experimental/dev-perl/ | \
  awk '{ print "dev-perl/" $1 " ~x86"}' \
 >> /etc/portage/package.keywords

In order for upgrading to Perl 5.10 I had to add the following to the same file (package.keywords):

dev-lang/perl **

And I also had to append this to /etc/portage/package.unmask:

>=dev-lang/perl-5.10.1

As I mentioned earlier I was then on the look out for installing some Perl modules using cpan and I was happily trying to do this with g-cpan until it stopped working and I was pointed in the direction of cpan2dist by the guys in #gentoo-perl.  After reading the documentation for this module on the CPAN website, installing it and playing around with it a bit I realised that a sensible thing to do might be to create a separate local overlay for it. This meant:

# mkdir /usr/local/portage/cpan

And then adding into /etc/make.conf after the line mentioned above:

PORTDIR_OVERLAY="/usr/local/portage/cpan$PORTDIR_OVERLAY"

Soon I might create some kind of script to run calls to cpan2dist so I don't forget to add the overlay path as follows:

# cpan2dist --format CPANPLUS::Dist::Gentoo \
--buildprereq --dist-opts overlay=/usr/local/portage/cpan \
[module you want to build]

After doing all that you should see a corresponding overlay number eg. "[1]" next to the ebuilds that are in the new cpan overlay when you next run eix [module name] to those that are listed by the overlays after running eix-update.