Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Local CPAN modules

by Jeppe (Monk)
on Feb 04, 2008 at 17:09 UTC ( [id://666001]=perlquestion: print w/replies, xml ) Need Help??

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

Esteemed monks,

I'm writing a build/test/installation script for the application we develop and maintain. As a part of this script, I would like to install a considerable number of CPAN modules, and I cannot count on an internet connection. In fact, we would like to not download automatically from the internet. Working on a static list of modules and a static list of versions of the modules means less time hunting down unexpected interactions..

However, there is an interesting challenge involved:

Let's say I've got all my modules in a directory, in tarball distributions. How do I then figure out which one require which one? I plan on creating a Makefile that represents the requirements and run that. But how do I figure out what module depends on what module?

Replies are listed 'Best First'.
Re: Local CPAN modules
by Corion (Patriarch) on Feb 04, 2008 at 17:13 UTC

    My approach is to create a local CPAN mirror by using CPAN::Mini. This will be a fully functional CPAN mirror that will maybe even still fit on a CD.

    If you don't want to go the route of shipping the full CPAN with your product, you can look at DrHyde's work for cpandeps ("temporary offline" unfortunately), but I guess he's got the code for tracking the dependencies online somewhere as well.

Re: Local CPAN modules
by Tanktalus (Canon) on Feb 05, 2008 at 00:39 UTC

    Been there, done that. :-)

    What I do is simply do this:

    1. Untar everything (check if it's untarred already)
    2. Loop:
      1. If Build.PL exists:
        • Run $^X -I$install_base/lib Build.PL --install_base $install_base, and catch the output.
        • Check for /ERROR: Prerequisite (\S+) isn't installed/. If found, go to next item in loop.
        • Run $^X Build install (if failed, go to next item)
        • Delete current build from to-do hash.
        else if Makefile.PL exists:
        • Run $^X -I$install_base/lib Makefile.PL LIB=$install_base/lib PREFIX=$install_base, and catch the output.
        • Check for /prerequisite\s*(\S+)\s.*not found/. If found, go to next item in loop.
        • Run make install (if failed, go to next item)
        • Delete current build from to-do hash.
    3. After each iteration of the loop, if the size of the to-do hash is non-zero and hasn't changed (meaning some prereqs may not be satisfied, or some installs failed), bail. (This is important :->)
    Obviously, I do this in perl. I don't even want to know how to do it in make - at least, automatically, that is. If it were in make, I'd just set up a bunch of targets where "DBD-mySQL: DBI" or something ... but that sounds painful, too :-)

      Thanks! I had that algorithm in the back of my head, but I had hoped to do something .. more elegant. Oh well. No tux and lotsa elbow grease will get the job done!
Re: Local CPAN modules
by perrin (Chancellor) on Feb 04, 2008 at 18:10 UTC
    What problem are you trying to solve? Modules that require others to be installed before they will install? There are very few of these and most are obvious (e.g. DBD::mysql requires DBI).

    If you just want to know if you got all the dependencies, there are multiple tools on CPAN for determining module dependencies, like Module-ScanDeps.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://666001]
Approved by Corion
Front-paged by andreas1234567
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-19 22:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found