14

I am trying to install the DateTime machine on a Linux server. Unfortunately, this Linux server has some restricted network access policy that prevents me from using the CPAN shell directly to download content, or installing cpanminus. Changing the access policy is beyond my control, so I am looking for a workaround. I also don't have root access to this Linux server.

I can, however, download anything to my work's Window machine, and upload to a file share on this server. So I started to pull down the DateTime dependencies one by one. I would download a module, sometime it will have Makefile.PL, sometime it will have Build.PL. I then rebase each Build or Makefile to my INSTALL_BASE, test each module. I did that for about 20 modules, and the trees seem to expand to ever smaller classes with no end in sight...

I hope you can tell me a better way. Is there a way I can initiate a download from a machine with CPAN access (ie. my Windows box) of all the DateTime dependencies into one giant Perl package, upload it to the Linux server, and run CPAN there (without network access) to put things in the right place? Thanks.

frank
  • 1,283
  • 1
  • 19
  • 39
  • 2
    Have you made sure that there is a build environment on this locked down machine? Would be a pity if you'd spend a lot of time transferring distributions if it hasn't the tools to deal with them. – innaM Jun 20 '13 at 07:54

4 Answers4

11

The most efficient way by far is to make a minicpan, install cpanm on the linux machine and alias localcpanmsomething like this:

alias localcpanm='cpanm --mirror file:///Users/Shared/cpan/ --mirror-only'

I have used this technique on long train journeys with patchy network access with great success.

singingfish
  • 3,136
  • 22
  • 25
  • Thanks. Is there a method to utilize minicpan to create a mirror of only a subset of CPAN, ie. to a single DateTime module and all its dependencies? And later, be able to add to that mirror only any additional modules we are interested in? I think mirroring the whole CPAN is ok, but being able to do with less than the whole thing would be a nice option. – frank Jun 21 '13 at 01:44
  • Looks like CPAN::Mini::FromList might do that but the cpanratings review doesn't inspire confidence. – singingfish Jun 23 '13 at 10:18
  • 1
    cpanm can create the necessary "minicpan", illustrated in my answer to this question – Diab Jerius Jun 25 '13 at 17:16
9

The first step is to automatically download all of the dependencies. You can use cpanm to do this on your network connected machine:

cpanm -L /dev/null --save-dists dists --scandeps DateTime

This generates both a list of dependencies, but more importantly downloads them into the dists directory. The -L /dev/null ensures that it doesn't pay attention to the modules already installed.

Copy dists as is to your restricted box.

Then, use cpanm on your restricted box to perform the local installation:

cpanm --mirror file:///path/to/dists -L foo DateTime

where /path/to/dists is the absolute path to the dists directory. This will install things into the foo directory.

Diab Jerius
  • 2,310
  • 13
  • 18
1

There are some solutions for this problem, see for example Carton which is like ruby's bundler or else Pinto which aims to be your own private CPAN (as I understand it).

Joel Berger
  • 20,180
  • 5
  • 49
  • 104
1

One solution I use at work is to have a development server with perlbrew, one Perl + modules and the app per app and all this in a git repo. On the production machines access to the git repository is all that's needed to deploy the app and switch between versions using tags.

Alexander Hartmaier
  • 2,178
  • 12
  • 21