« Digital Camera on the Way | Main | OSCON 2004 Presentation Accepted »

March 2, 2004

Build Script for Perl Modules

Today I completed a build script which creates a slew of Solaris packages, one for every Perl module needed to run our application. The count right now is 45. This is a huge relief, building packages can take anywhere from 1-2 hours . . . each.

There were two items that made this more interesting than just another shell script. First, I wanted to install the perl modules in a clean, local directory to make packaging easy and enable a non-root user to build the packages. For the most part the modules respect the make install PREFIX option so I could have the installation directed to a local dir.

Second, once I had the install location worked out there was the question of making the current installing module available to the remaining modules. What I ended up doing is pointing PERL5LIB at another local directory and doing a cp -r from the install directory to PERL5LIB which would allow me to wipe the install dir for the next module but keep a copy of the module available.

The script has two hashes, the key for both is the package name (ie. xmlparser). One hash is the CPAN name (ie. XML::Parser) and the other a dependencies array, consisting of package names needed before installing.

Essentially the script goes through this process for each of the packages, which are defined in a specific order to ensure dependencies are met:
1 - install directory cleaned out
2 - get, configure, make, make test and make install module using programmers interface to CPAN (packages installed in ~/build/perl_modules/perl)
3 - installed files copied to PERL5LIB (~/build/perl_modules/lib)
4 - prototype file created from files in ~/build/perl_modules/perl
5 - dependencies calculated from hash and put into depend file
6 - name and version (from CPAN) used to create pkginfo file
7 - pkgmk creates package, pkgtrans moves it to datastream file

There are two packages that can't be beaten into working with the script, HTML::Embperl and Net::SSLeay. I moved HTML::Embperl over to our apache package (it needs the apache source to install). Net::SSLeay won't install in the local dir, so I added a small section before the package loop which uses CPAN to get the latest version but then does the configure and install in a separate shell where I can manually specify the Makefile.PL args and install it into the local dir. Then continue with steps 3-7 to get the package.

There are a few places in the script where I'm required to give some input (path to apache binary). I thought of several different ways to avoid this, but in the end decided I can watch the script and give it what it wants.

The great thing about this is at any point I can easily add and remove modules from the list and easily generate a completely up to date set of perl module packages. Is good both for convenience and for assurance that things are being built the same way over time.

Posted by mike at March 2, 2004 4:45 PM