简体   繁体   English

在没有CPAN网络访问的计算机上安装具有大量依赖关系的Perl模块

[英]Install Perl modules with lots of dependencies on a machine without CPAN network access

I am trying to install the DateTime machine on a Linux server. 我正在尝试在Linux服务器上安装DateTime机器。 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. 不幸的是,这个Linux服务器有一些限制的网络访问策略,阻止我直接使用CPAN shell下载内容或安装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. 我也没有root访问权限。

I can, however, download anything to my work's Window machine, and upload to a file share on this server. 但是,我可以将任何内容下载到我工作的Window机器上,然后上传到该服务器上的文件共享。 So I started to pull down the DateTime dependencies one by one. 所以我开始逐个删除DateTime依赖项。 I would download a module, sometime it will have Makefile.PL, sometime it will have Build.PL. 我会下载一个模块,有时它会有Makefile.PL,有时它会有Build.PL。 I then rebase each Build or Makefile to my INSTALL_BASE, test each module. 然后我将每个Build或Makefile重新绑定到我的INSTALL_BASE,测试每个模块。 I did that for about 20 modules, and the trees seem to expand to ever smaller classes with no end in sight... 我做了大约20个模块,树木似乎扩展到更小的类,看不到尽头......

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? 有没有办法可以从具有所有DateTime依赖关系的CPAN访问权限(即我的Windows框)的机器下载到一个巨大的Perl包中,将其上传到Linux服务器,并在那里运行CPAN(无网络访问)把东西放在正确的地方? Thanks. 谢谢。

The most efficient way by far is to make a minicpan , install cpanm on the linux machine and alias localcpanm something like this: 到目前为止最有效的方法是制作一个minicpan ,在linux机器上安装cpanm ,并将localcpanm别名localcpanm

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. 我已经在长途火车旅行中使用了这种技术,并且网络访问不完整,取得了巨大的成功。

The first step is to automatically download all of the dependencies. 第一步是自动下载所有依赖项。 You can use cpanm to do this on your network connected machine: 您可以使用cpanm在网络连接的计算机上执行此操作:

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. 这会生成一个依赖项列表,但更重要的是将它们下载到dists目录中。 The -L /dev/null ensures that it doesn't pay attention to the modules already installed. -L /dev/null确保它不会注意已安装的模块。

Copy dists as is to your restricted box. dists按原样复制到受限制的框中。

Then, use cpanm on your restricted box to perform the local installation: 然后,在受限制的盒子上使用cpanm来执行本地安装:

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

where /path/to/dists is the absolute path to the dists directory. 其中/path/to/distsdists目录的绝对路径。 This will install things into the foo directory. 这将把东西安装到foo目录中。

对于这个问题有一些解决方案,例如参见Carton ,它就像ruby的捆绑器,或者Pinto ,它的目的是成为你自己的私人CPAN(据我所知)。

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. 我在工作中使用的一个解决方案是使用perlbrew开发服务器,一个Perl +模块和每个应用程序的应用程序,所有这些都在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. 在生产机器上,访问git存储库是部署应用程序和使用标记在版本之间切换所需的全部内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM