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

This is actually something I'd rather put in CUFP ... but I don't have any code (yet) to do it. But I think it'd be a cool way to handle certain issues. My issues. And not the ones that only a shrink could help with.

The brief version: Given a list of (local) tarballs that are distributions of modules as are available on CPAN, what is the easiest automatic way to install them locally?

The long version.

I would like to take tarballs from CPAN, check them in to our version control system, and then, during an automated build (e.g., "make all"), install them inside that tree. The reasons for this include:

Two obvious possibilities arise. First off, so far all modules we want to do this for (which are not already part of the base 5.8.x perl distributions) are pure perl. So we could just take the .pm files, put them in the right place, set up the use lib calls appropriately, and be done with it. Advantage: easy to set up. Disadvantage: difficult to maintain (upgrading or deleting are both more painful).

Second option is to simply write a script that untars the tarball (I'll likely gunzip the tarball first just to avoid gzip dependancies on some platforms), cd's to the directory, runs "perl Makefile.PL PREFIX=$somewhere_in_build_tree && gnumake && gnumake install", and goes on to the next file. How to work out that dependency tree, should there ever become one, will be an interesting challenge. Advantage: once set up, should be as trivial to maintain as possible. Disadvantage: possibly reinventing someone else's wheel.

So the question is, using stock perl 5.8.x, is there anything out there I can bootstrap into this? I've looked at ExtUtils::AutoInstall (Mentioned in Re: Running CPAN without Being root by simonm) but that's kind of the opposite of what I'm looking for - it wants to do things interactively for another Makefile.PL, and isn't part of stock 5.8.x. Other interesting nodes include Automatic module installation by Juerd - but it's for installing from CPAN, and, well, is a bit scary ;-) I want to set up the installations where I can easily select the level to install (by placing it in a tarball in the version control system), and Juerd's implementation would need to be completely reworked anyway.

If there is no wheel out there yet invented, I'm going to have to pick my way through tachyon's A Guide to Installing Modules while writing that second one. (Let no one say I didn't super search this. They can say I didn't use the right terms, but they can't say I didn't try ;->)

Bottom line: I want to run "install_em_all.pl", walk away, and come back X amount of time later to find all tarballs done installing to a local directory. That I may need to write the logic to glob *.tar, or I need to write the logic to select the LIB directory to install to are minor. The rest probably isn't so big, either, but I'm guessing there are gotchas that I don't know about (yet).

One final note: some of these modules use Makefile.PL, others use Build.PL. Anything I take advantage of would necessarily need to handle both. Writing my own, if that's what is required, will obviously also need to do so.

Replies are listed 'Best First'.
Re: Automated module install
by perrin (Chancellor) on Apr 08, 2005 at 00:31 UTC
    For Krang we used the Expect module for this. It worked pretty well, although you will have to code special cases for modules that ask interactive questions.
Re: Automated module install
by blahblahblah (Priest) on Apr 08, 2005 at 04:18 UTC
    I wrote a quick script to do exactly this a while ago. There's nothing fancy about it, but it saved me a bunch of typing when I had to install the same set of modules on a handful of unix and linux machines.

    I automated some of the modules' setup options that could be controlled by passing args or by supplying a config file. For the ones that prompted for input, I manually typed the input. Since I only did this on 4 or 5 machines and they were all different flavors of unix/linux with different perl versions, I also added a lot of prompts to my script so I could watch the progress and make sure it worked correctly.

    Like I said, there's nothing special about my script, but it might be useful to you as a starting point. So, here it is, complete with comments about some modules that needed special handling:

Re: Automated module install
by chanio (Priest) on Apr 08, 2005 at 20:33 UTC
    I use Webmin when using LINUX.- It is a great & solid perl tool. And not only to install PMs...

    It might be a good source of inspiration if you want to build your own PM installer. It works clearer and easier than ActivePerl's PPM.- It is all, 'menu driven' in the browser.

    You should see it! The site, works just like the local one (your local server).

    .{\('v')/}   C H E E R   U P !
     _`(___)' ___a_l_b_e_r_t_o_________
    
    Wherever I lay my KNOPPIX disk, a new FREE LINUX nation could be established.