views:

395

answers:

3

I need to install my Perl-based software on networked machines which aren't connected to the internet. Therefore, I would like to download specific versions and/or latest versions of the Perl modules and I would also like to know if there is an install procedure required for these modules.

Background:
The machines aren't connected to the internet for security reasons and its deemed unnecessary also.

I would place the downloaded modules on a machine that I call the 'install server' and it contains my Perl based software and would also contain the local copies of the Perl modules.

I call a machine that I want to install my Perl-based software on, the 'target machine', also not connected to the internet. There can be several target machines, each can run this software that I want to install. I log onto the target machine and run an install script which would connect to the install machine via the local network to obtain the Perl-based software and dependent Perl modules and installs them.

So I need to know:

  1. How/Where to get specific versions of Perl modules, e.g. CGI.pm etc
  2. How to install these Perl modules. Is it a case of just placing them in a directory somewhere, e.g. a library path and making sure that this directory path is in the @INC library path environmental variable, if it is not already?

I would prefer not to have to do anything like make install etc. as part of installing the modules. I would like to modules to be pre-compiled or prepared as necessary so it is as simple as possible to install them. I want to avoid additional dependencies like make and its configuration, and having to parse its output to check whether it was successful.

Please help me by asking the above specific questions as I am not able to change the concept of 'install machine' and 'target machine' which aren't connected to the internet - I have to provide a solution that works within this arrangement.

+4  A: 

1) How/Where to get specific versions of Perl modules, e.g. CGI.pm etc

http://search.cpan.org/

If you don't want the latest version, you can get an earlier version by following the link in the breadcrumbs.

2) How to install these Perl modules. Is it a case of just placing them in a directory somewhere, e.g. a library path and making sure that this directory path is in the @INC library path environmental variable, if it is not already?

That sometimes work, but you really should go through the perl Makefile.PL && make && make test && make install process.

Doing this would require that you manually chase all the dependencies though. You would probably be better off with something like minicpan.

David Dorward
You should emphasize the minicpan in your answer. It is the RIGHT solution for this problem.
tsee
@David Dorward - thanks for replying so soon after my posting the question.As mentioned in the original question, I wanted to avoid make install etc. because it adds complexity in that I would have to manually find dependencies, I would have to ensure make is present and works correctly. I'd happily follow this process if there was a consistent robust automated system that cleanly handled all outcomes of the make.
Rob
It would seem disingenuous to call Perl a portable intepreted language if make has to be used to provide pre-compiled modules to satisfy a program's dependencies. Having read further, I see that its possible that modules can contain C code so that might explain why make is necessary. It's a shame because it does add more steps to precisely defining configuration management and installation procedures.
Rob
I was hoping to be able to just get the required modules as Perl code text files and place them in a directory location that @INC is aware of and then my program would run successfully. Unfortunately it doesn't appear to be a simple as that (shouldn't it be?) but @tsee's answer below with the PAR module might be the solution that best suits my situation.
Rob
Rob: For many simple modules, copying the .pm files in an appropriate subdirectory of a directory in @INC does *indeed* work. But this approach is fraught with peril.
tsee
@Rob: Perl is portable, but that doesn't stop people from creating non-portable things with it. CPAN is just third-party code.
brian d foy
Folks. Thank you for your further comments.@tsee: "For many simple modules, copying the .pm files in an appropriate subdirectory of a directory in @INC does indeed work. But this approach is fraught with peril"I accept this but as improvement to 3rd-party libraries, would it not be useful to have a flag in the header, a kind of pragma statement confirming that a module is pure Perl - not dependent on non-Perl languages, binaries or compilation. modules that *are* depend on make or non-Perl languages for successful run and install, perhaps the steps could be built-into the module itself.
Rob
@brian d foy: "Perl is portable, but that doesn't stop people from creating non-portable things with it. CPAN is just third-party code"Those non-portable things can complicate configuration management and installation as there might not be a uniform common way to deal with all non-portable components that a particular module depends on. Each module would have to be treated on a case-by-case basis.
Rob
I don't know how big the "problem" of Perl modules depending on non-portable code is: I would like to think it was only for the necessary things - like low level platform specific device drivers and perhaps performance optimisations. But the latter ought to be core to the language as it is very powerful for example hashes.However big the extent of Perl modules requiring the make process to be installed, it's enough to make me include it in writing a consistent, repeatable and robust installation process and also attempting to automate that process as much as possible. Not a trivial task!
Rob
I'd like to consider all your comments and try to post here with a definitive answer for obtaining and installing 3rd-party modules. An answer that is robust, repeatable and consistent.
Rob
+7  A: 

The usual way to solve "I want to install stuff from CPAN but without network" problems is to use a minicpan as David Dorward wrote in his answer. But since you're going one step further, saying that you'd rather not do any real installation on the client (target) machines at all, and that you want to use precompiled modules if possible, I urge you to check out PAR and specifically PAR::Repository (server) and PAR::Repository::Client.

Since this approach needs some research before you're up to speed, I wouldn't suggest it for "I just need Foo.pm" like problems. Once you're talking about a handful of dependencies and at least a handful of clients, then it becomes a more appropriate solution.

For an outline of how it works, check out the slides of my talk at YAPC::EU 2008. It also hints at solutions to the bootstrapping problem of making the PAR::Repository::Client module available on the clients (hint: PAR can generate self-contained executables).

tsee
Thanks tsee for this answer. A local CPAN mirror is probably not the right solution for me at this stage as I have a fairly small list of specific modules that I want to obtain to satisfy the dependencies my program has. Also, I do not 'own' the machine's where the local CPAN would reside and may therefore be restricted regarding space available or installing what I don't need.That this PAR solution appears to be a module itself might seem to present a chicken-egg situation; I would hope that the PAR module itself would be easy to obtain and install and run to solve my problem.
Rob
So thank you tsee for suggesting - PAR - an alternative to a local CPAN mirror. I will readup on it.
Rob
Rob: You can use PAR(::Packer) to produce self-contained binary executables.
tsee
I've accepted this answer because it covers all the possible solutions with commentary on each. PAR sounds closest to my needs as I would like to simplify the automation of installing Perl modules on multiple machines. Since I have a limited variety of Linux distros to support (i.e. Debian 5 x86 and Mandriva x86) and the fact that I want to standardise on versions of modules used then I can setup an install local server with pre-compiled modules to serve these.
Rob
+7  A: 

You can create a MiniCPAN that has just the latest versions of everything from CPAN. You can insert additional, non-public modules into it with CPAN::Mini::Inject. If you need to greater control over versions (i.e. not choosing the latest versions), you might want to create a DPAN.

With any of these solutions, you can configure your CPAN client to pull from your local source. That could be a directory you know ahead of time or something that you figure out dynamically, like a CD or a thumb-drive. It's just a matter of setting up the configuration correctly.

You might be able to get away with creating operating-system packages for most of your work, but that still means you have to compile them at least the first time.

brian d foy