How to automate module installation from a local MiniCPAN repository?

1.1k views Asked by At

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: e.g. /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, e.g. 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)

1

There are 1 answers

0
Ciprian Lungu On

try :

#!/usr/bin/perl -w

system <cpan install My::Module>