简体   繁体   English

如何自动从本地MiniCPAN信息库安装模块?

[英]How to automate module installation from a local MiniCPAN repository?

Having problems getting CPAN to work with a MiniCPAN repository from within a script (aim is a code deployment system to build local modules together with modules from CPAN, install to a local-lib, and then sync out to servers) 在使CPAN从脚本中与MiniCPAN存储库一起使用时遇到问题(目标是一个代码部署系统,用于与CPAN中的模块一起构建本地模块,安装到本地库,然后同步到服务器)

$HOME/.cpan/CPAN/MyConfig.pm exists, with urllist set to ['file:///home/user/minicpan/'] $HOME/.cpan/CPAN/MyConfig.pm存在,并且网址列表设置为['file:///home/user/minicpan/']

The (non-CPAN) module distribution was injected sucessfully into the minicpan repo, and file exists: eg /home/user/minicpan/authors/U/US/USER/My-Module-0.01.tar.gz . (非CPAN)模块分发已成功注入minicpan仓库中,并且文件存在:例如/home/user/minicpan/authors/U/US/USER/My-Module-0.01.tar.gz

The author is in .../01mailrc.txt.gz , module is in .../modules/02packages.details.txt.gz 作者在.../01mailrc.txt.gz ,模块在.../modules/02packages.details.txt.gz

The module is found and installs via the cpan shell. 找到该模块,并通过cpan shell安装。

Fails through following code: 通过以下代码失败:

CPAN::HandleConfig->load;
CPAN::Shell::setup_output;
CPAN::Index->reload;

# dumping config here shows urllist set correctly,
# and config exactly the same as through shell
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
print Dumper($CPAN::Config);

CPAN::Shell->install("My::Module");

Either doesn't find module ( "Cannot install My::Module, don't know what it is." ) or claims is up to date ( My::Module is up to date (0.01) ) 找不到模块( "Cannot install My::Module, don't know what it is." )或声明是最新的( My::Module is up to date (0.01)

Module is not installed in the local-lib (and not anywhere else on machine, eg in /usr/...) Local-lib environment variables are set via eval $(perl -I$HOME/foo/lib/perl5 -Mlocal::lib=$HOME/locallib) in bash profile 模块未安装在本地库中(而不是在机器上的其他任何位置,例如,在/ usr / ...中)。本地库环境变量是通过eval $(perl -I$HOME/foo/lib/perl5 -Mlocal::lib=$HOME/locallib) bash配置文件中的eval $(perl -I$HOME/foo/lib/perl5 -Mlocal::lib=$HOME/locallib)

After getting either error (including 'Module is up to date'), a normal 'install' in the shell works without force, as does perl -MCPAN -e "install My::Module" , so I presume it's the config not set correctly, but the CPAN.pm docs are rather hard to follow... 遇到任何一个错误(包括“模块是最新的”)后,shell中的常规“安装”都无需用力,就像perl -MCPAN -e "install My::Module" ,所以我认为未设置配置正确,但是CPAN.pm文档很难遵循...

(CPAN.pm is v1.9402) (CPAN.pm是v1.9402)

try : 尝试:

#!/usr/bin/perl -w

system <cpan install My::Module>

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

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