I have an intention of creating a empty local CPAN directory, and then inject the modules i need with the right version numbers.
So, i create a CPAN structure with CPAN::Mini like this:
my $local = '/tmp/CPAN';
my $minicpan = CPAN::Mini->new(
remote => "http://mirrors4.kernel.org/cpan/",
local => $local,
passive => 'yes',
dirmode => 0755,
repository => $local,
module_filters => [ sub { $_[0] !~ m/No::Giro/i } ], #Thus us just to fetch this module only
trace => 1
);
mkdir($local."/authors") or die("Could not create authors folder");
mkdir($local."/modules") or die("Could not create modules folder");
my @files = ('authors/01mailrc.txt.gz', 'modules/02packages.details.txt.gz', 'modules/03modlist.data.gz');
foreach my $file (@files){
print "Creating file $local/$file \n";
open(FILE, "+> $local/$file") or die("Could not create $local/$file");;
close (FILE);
}
And then i try to inject a module with CPAN::Mini::Inject:
use strict;
use warnings;
use Getopt::Long;
use CPAN::Mini::Inject;
my $module = undef;
my $authorid = undef;
my $version = undef;
my $file = undef;
GetOptions(
"module=s" => \$module,
"authorid=s" => \$authorid,
"version=s" => \$version,
"file=s" => \$file,
);
die ("--module not provided") if(!defined($module) || $module eq '');
die ("--authorid not provided") if(!defined($authorid) || $authorid eq '');
die ("--version not provided") if(!defined($version) || $version eq '');
die ("--file not provided") if(!defined($file) || $file eq '');
die("File $file does not exists") unless ((-e $file) || (-f $file) );
my $mcpi = CPAN::Mini::Inject->new;
$mcpi->loadcfg('/tmp/minicpan.conf');
$mcpi->parsecfg();
$mcpi->readlist();
$mcpi->add(
module => $module,
authorid => $authorid,
version => $version,
file => $file );
$mcpi->inject(1);
$mcpi->writelist();
exit(0);
But the 03modlist.data.gz file isnt getting updated (So its empty), so when i try to use cpan with the local repository i get and error which is related to this file. Does anyone know how to generate a valid modlist file? Or how to get CPAN::Mini or CPAN::Mini::Inject to do it for you?
Best regards