After a bit of poking around in the source of CPAN.pm, the shortest bootstrap of a user's home directory that ignores the system-wide CPAN config I found was:
perl -MFile::Path -MCPAN::Config -MCPAN::FirstTime -e ' $CPAN::Config = {}; mkpath("$ENV{HOME}/.cpan/CPAN"); CPAN::FirstTime::init("$ENV{HOME}/.cpan/CPAN/MyConfig.pm", autoconfig => "yes") ' I've attached a patch that makes it so that CPAN.pm has a new function, "userconfig", and when the current user does not have permission to create their lockfile, *and* they don't have a MyConfig.pm yet, they are given the opportunity to create their own CPAN config, using all of the system-wide defaults *except* paths where CPAN does it's work. Let me know what you think. Cheers, Tyler
diff -dur CPAN-1.83_59.orig/lib/CPAN.pm CPAN-1.83_59/lib/CPAN.pm --- CPAN-1.83_59.orig/lib/CPAN.pm 2006-01-29 13:46:58.000000000 -0800 +++ CPAN-1.83_59/lib/CPAN.pm 2006-01-29 14:10:04.000000000 -0800 @@ -54,7 +54,7 @@ @EXPORT = qw( autobundle bundle expand force notest get cvs_import install make readme recompile shell test clean - perldoc recent + perldoc recent userconfig ); sub soft_chdir_with_alternatives ($); @@ -238,6 +238,27 @@ } } } + +#-> sub CPAN::userconfig ; +sub userconfig { + my($cpanpm, %args) = @_; + require CPAN::FirstTime; + $cpanpm = $INC{'CPAN/MyConfig.pm'} || "$ENV{HOME}/.cpan/CPAN/MyConfig.pm"; + File::Path::mkpath(File::Basename::dirname($cpanpm)) unless -e $cpanpm; + if(!$INC{'CPAN/Config.pm'}) { + eval { require CPAN::Config; }; + } + $CPAN::Config ||= {}; + $CPAN::Config = { + %$CPAN::Config, + build_dir => undef, + cpan_home => undef, + keep_source_where => undef, + histfile => undef, + }; + CPAN::FirstTime::init($cpanpm, %args); +} + package CPAN::CacheMgr; use strict; @CPAN::CacheMgr::ISA = qw(CPAN::InfoObj CPAN); @@ -675,8 +696,15 @@ $incc or $myincc - }); + if(!$INC{'CPAN/MyConfig.pm'}) { + $CPAN::Frontend->myprint("You don't seem to have a user configuration (MyConfig.pm) yet.\n"); + my $new = ExtUtils::MakeMaker::prompt("Do you want to create a user configuration now?", "yes"); + if($new =~ m{^y}i) { + CPAN::userconfig(); + return &checklock; + } + } } $CPAN::Frontend->mydie("Could not open >$lockfile: $!"); }