Here http://stackoverflow.com/questions/3462058/how-do-i-automate-cpan-configuration I've found some answers which led to some questions. I tried cpan -j config.pm, but as far as I can see it is meant for per installation usage, not for changing the config-file permanently.
With the $CPAN::Config-method the force CPAN::FirstTime to not default to manual-part didn't work here so I tried without it:
#!/usr/bin/perl
use strict;
use warnings;
use Config;
use CPAN;
use CPAN::FirstTime;
$ENV{PERL_MM_USE_DEFAULT}=1;
$ENV{PERL_MM_NONINTERACTIVE}=1;
$ENV{AUTOMATED_TESTING}=1;
my $cpan_home = '/home/me/.cpan';
mkdir $cpan_home or die $! if not -d $cpan_home;
mkdir "$cpan_home/CPAN" or die $! if not -d "$cpan_home/CPAN";
CPAN::FirstTime::init( "$cpan_home/CPAN/MyConfig.pm" );
delete $CPAN::Config->{links};
$CPAN::Config->{applypatch} = '';
# ...
$CPAN::Config->{build_dir} = "$cpan_home/build";
$CPAN::Config->{cpan_home} = $cpan_home;
$CPAN::Config->{histfile} = "$cpan_home/histfile";
$CP$CPAN::Config->{keep_source_where} = "$cpan_home/sources";
$CPAN::Config->{make_install_make_command} = 'sudo make';
$CPAN::Config->{mbuild_install_build_command} = 'sudo ./Build';
$CPAN::Config->{prefs_dir} = "$cpan_home/prefs";
# ...
$CPAN::Config->{yaml_module} = 'YAML';
CPAN::HandleConfig->commit("$cpan_home/CPAN/MyConfig.pm");
CPAN::install('Bundle::CPAN');
# ...
# etc.
exit 0;
Is this OK? The only bad thing that I have noticed so far is the waiting, until the cpan-mirror-urls are found. And what is the delete $CPAN::Config->{links}; for?