carcassonne has asked for the wisdom of the Perl Monks concerning the following question:

Folks,

I have to install about 10 modules from CPAN on a machine to get an application going. Since the machine does not have an internet connection, I transfered the archived modules to it and installed them manually, with lots of 'perl Makefile.PL' and all that.

Is there already a way to automate this process ? I could write a bash script (or even better, a small Perl program ;-) to do the installations but surely there's already at least one solution out there,

Amongst the undoubtly many solutions, which one would you recommened ? This is for Linux-only systems. One nice criteria would be that the solution does not require itself 10 modules to run...

Thanks !

Update:

On CPAN I found megadistro, a recent package that, after a fe wtries, seems to successfully get from the CPAN specified modules, build them, and produce either a RPM, a Debian, or simply a tar.gz package.

I've chosen the tar.gz option for testing since this is part of the requirements.

My CPAN(PLUS) module(s) are set to operate as root. So far, I did not look into making it work as an ordinary user. So, to use megadistro I logged in as root. Warning: megadistro will not create the /root/.megadistro directory to put the archive file of all the modules. You have to create it beforehand.

1) I've created a text file with a few module names:

Acme::Bleach Acme::EyeDrops Acme::BadExample

2) I've created some test directories for megadistro to operate:

~/MegaDistro/mega_build/ ~/MegaDistro/mega_dl/ ~/MegaDistro/mega_extract/

3) I've launched megadistro like this, to produce a tar.gz file:

megadistro --build-only \ --modlist=~/MegaDistro/megadistro.list \ --fetchdir=~/MegaDistro/mega_dl \ --extractdir=~/MegaDistro/mega_extract \ --builddir=~/MegaDistro/mega_build

Megadistro then spent some time at the following line (on a X86_64 dual core fast machine it stayed there foreover, so I killed it, but on a plain x86 it works fine):

Rebuilding module indicies...

It then produced the following file in /root/.megadistro:

megadistro-20060303.tar.gz

And this archive file contains stuff like:

usr/lib/perl5/vendor_perl/5.8.6/i586-linux-thread-multi/auto/Acme/Blea +ch usr/lib/perl5/vendor_perl/5.8.6/Acme/Bleach.pm usr/lib/perl5/vendor_perl/5.8.6/Acme/EyeDrops.pm usr/lib/perl5/vendor_perl/5.8.6/Acme/BadExample.pm usr/share/man/man3/Acme::Bleach.3pm usr/share/man/man3/Acme::EyeDrops.3pm (so on so forth...)

So, it looks good. When megadistro hits a problem testing an application, it will interactively ask for forcing the install (Y/n). Could be a good idea to specify this as a parameter. It will also, or so it seems, download from the CPAN the dependencies.

Let us know if you try it too !

Replies are listed 'Best First'.
Re: Repeated offline installs of same CPAN modules
by Aristotle (Chancellor) on Mar 01, 2006 at 20:19 UTC

    You could run a local repository using CPAN::Mini.

    Makeshifts last the longest.

Re: Repeated offline installs of same CPAN modules
by izut (Chaplain) on Mar 01, 2006 at 21:32 UTC

    If you're using Red Hat or some of its derivates, you can use the amazing cpan2rpm application. I use it in my RHEL environment at work.

    Update: On Gentoo, you can also use g-cpan, and create the respective packages for offline install using qpkg.

    Igor 'izut' Sutton
    your code, your rules.

Re: Repeated offline installs of same CPAN modules
by Fletch (Bishop) on Mar 01, 2006 at 20:50 UTC

    Another possibility would be to figure out what files the module installs and wrap those up using whatever package management system your flavour of Linux uses (RPM, dpkg, etc.). Then you just rpm -Uvh Local-P5-Foo-1.2.3.i386.rpm on all the machines (or throw it into your kickstart configuration, or whatever the Debian analogue to that is).

      Yes, the low-down solution is to identify all the required files, pack them, and unfold on same-architecture target systems. If there's nothing else, I'll go that way.

      But by asking I was hoping that someone would suggest something like a 'Presto-Installer 0.78' or somesuch that would simply take the indivual CPAN archived modules, and make them.

      After all, a bash script can do that.

        I was hoping that someone would suggest something like a 'Presto-Installer

        I asked this before, and I still resort to the manual method. Why? Before I like to keep all my downloaded modules in the same directory, so I can scan their names when searching for them. Whereas most cpan modules want a repository style tree, where the modules are buried in those alphabetical named directories. It was still easy, because Perl dosn't need you to "make clean" before rebuilding. So when I needed to rebuild my modules for a recent upgrade to 5.8.8, all I needed to do was (in Midnight Commander) start at the top of modules directory,and as root, enter the individual modules directory, and do "perl Makfile.PL", followed by "make install". I could march thru 100 modules in about 30 minutes. Now this could easily be scripted. The only problem would be when a module needs a pre-requisite module, and issues an error. So you need to do it attended. But I found that most of the time, you can install the pre-requisite later, as long as it is in your list, so you can ignore them and install anyways.


        I'm not really a human, but I play one on earth. flash japh