Install Perl modules with lots of dependencies on

2019-01-22 14:52发布

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.

标签: perl cpan
4条回答
姐就是有狂的资本
2楼-- · 2019-01-22 15:09

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.

查看更多
祖国的老花朵
3楼-- · 2019-01-22 15:16

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).

查看更多
Fickle 薄情
4楼-- · 2019-01-22 15:20

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.

查看更多
再贱就再见
5楼-- · 2019-01-22 15:25

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.

查看更多
登录 后发表回答