简体   繁体   中英

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)

$HOME/.cpan/CPAN/MyConfig.pm exists, with urllist set to ['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 .

The author is in .../01mailrc.txt.gz , module is in .../modules/02packages.details.txt.gz

The module is found and installs via the 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) )

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

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

(CPAN.pm is v1.9402)

try :

#!/usr/bin/perl -w

system <cpan install My::Module>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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