Perl Module Config Files

This post was written by on 24th Jul 2009

We have now written a follow up post to this on Creating Perl module RPM’s.

We have been investigating the various build/packaging options for perl modules.

Up to now we have been using the standard method of ‘h2xs -AXn Module::Name‘. This generates a template module with a ExtUtils::MakeMaker build file.

We can then use cpan2rpm to create rpm files that we can put on our internal yum repositories.

This allows us to easily install/upgrade the same module across our various servers.

The problem has come when we wanted to have a slightly modified rpm e.g. have the rpm create a standard user, install a binary and/or init script, or create a config file.

The ExtUtils / cpan2rpm combination does not appear to have this functionality. We started looking at putting it in, but it was becoming increasingly difficult to do so.

So we started looking at Module::Build instead of ExtUtls. With this it is easier to make custom builds, and because of this seems to becoming increasingly popular as the Perl module builder.

For instance the Build.PL to enable a config file install into /etc and a logrotate script can be as follows:

use 5.008005;
use Module::Build;

my $build = Module::Build->new (
module_name => 'ModuleName',
license => 'perl',
dist_author => 'A.N. Other <a.n.other@example.com>',
dist_version_from => 'lib/ModuleName.pm',
etc_files => {
'etc/logrotate.d/modulename' => 'etc/logrotate.d/modulename',
'etc/modulename.conf' => 'etc/modulename.conf'
},
install_path => { 'etc' => '/etc' },
);
$build->add_build_element('etc');
$build->create_build_script;

We still need to use our modified cpan2rpm if we need any pre or post install scripts in the rpm. But so far this appears to be working.

Tags

Read more posts like this one in API & technical

Add your comment

What do you think of this blog post? That nagging feeling won’t go away until you let the world know your thoughts.