# no cpan-home, must prompt and get one
$CPAN::Frontend->myprint($prompts{cpan_home_where});
}
$default = $cpan_home;
my $loop = 0;
my $last_ans;
$CPAN::Frontend->myprint(" <cpan_home>\n");
PROMPT: while ($ans = prompt("CPAN build and cache directory?",$default)) {
print "\n";
if (File::Spec->file_name_is_absolute($ans)) {
my @cpan_home = split /[\/\\]/, $ans;
DIR: for my $dir (@cpan_home) {
if ($dir =~ /^~/ and (!$last_ans or $ans ne $last_ans)) {
$CPAN::Frontend
->mywarn("Warning: a tilde in the path will be ".
"taken as a literal tilde. Please ".
"confirm again if you want to keep it\n");
$last_ans = $default = $ans;
next PROMPT;
}
}
} else {
require Cwd;
my $cwd = Cwd::cwd();
my $absans = File::Spec->catdir($cwd,$ans);
$CPAN::Frontend->mywarn("The path '$ans' is not an ".
"absolute path. Please specify ".
"an absolute path\n");
$default = $absans;
next PROMPT;
}
eval { File::Path::mkpath($ans); }; # dies if it can't
if ($@) {
$CPAN::Frontend->mywarn("Couldn't create directory $ans.\n".
"Please retry.\n");
next PROMPT;
}
if (-d $ans && -w _) {
last PROMPT;
} else {
$CPAN::Frontend->mywarn("Couldn't find directory $ans\n".
"or directory is not writable. Please retry.\n");
if (++$loop > 5) {
$CPAN::Frontend->mydie("Giving up");
}
}
}
$CPAN::Config->{cpan_home} = $ans;
}
if (!$matcher or 'keep_source_where' =~ /$matcher/) {
my_dflt_prompt("keep_source_where",
File::Spec->catdir($CPAN::Config->{cpan_home},"sources"),
$matcher,
);
}
if (!$matcher or 'build_dir' =~ /$matcher/) {
my_dflt_prompt("build_dir",
File::Spec->catdir($CPAN::Config->{cpan_home},"build"),
$matcher
);
}
if (!$matcher or 'build_dir_reuse' =~ /$matcher/) {
my_yn_prompt(build_dir_reuse => 0, $matcher);
}
if (!$matcher or 'prefs_dir' =~ /$matcher/) {
my_dflt_prompt("prefs_dir",
File::Spec->catdir($CPAN::Config->{cpan_home},"prefs"),
$matcher
);
}
}
#
#= Config: auto_commit
#
my_yn_prompt(auto_commit => 0, $matcher);
#
#= Cache size, Index expire
#
if (!$matcher or 'build_cache' =~ /$matcher/) {
# large enough to build large dists like Tk
my_dflt_prompt(build_cache => 100, $matcher);
}
if (!$matcher or 'index_expire' =~ /$matcher/) {
my_dflt_prompt(index_expire => 1, $matcher);
}
if (!$matcher or 'scan_cache' =~ /$matcher/) {
my_prompt_loop(scan_cache => 'atstart', $matcher, 'atstart|never');
}
=8= |