Update to PathTools-3.22.
[p5sagit/p5-mst-13.2.git] / lib / CPAN / FirstTime.pm
CommitLineData
8d97e4a1 1# -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
5f05dabc 2package CPAN::Mirrored::By;
e82b9348 3use strict;
5f05dabc 4
5sub new {
6 my($self,@arg) = @_;
7 bless [@arg], $self;
8}
da199366 9sub continent { shift->[0] }
10sub country { shift->[1] }
5f05dabc 11sub url { shift->[2] }
12
13package CPAN::FirstTime;
5f05dabc 14use strict;
135a59c2 15
f915a99a 16use ExtUtils::MakeMaker ();
05454584 17use FileHandle ();
09d9d230 18use File::Basename ();
05454584 19use File::Path ();
5de3f0da 20use File::Spec;
8962fc49 21use vars qw($VERSION $urllist);
135a59c2 22$VERSION = sprintf "%.6f", substr(q$Rev: 924 $,4)/1000000 + 5.4;
5f05dabc 23
24=head1 NAME
25
26CPAN::FirstTime - Utility for CPAN::Config file Initialization
27
28=head1 SYNOPSIS
29
30CPAN::FirstTime::init()
31
32=head1 DESCRIPTION
33
c9869e1c 34The init routine asks a few questions and writes a CPAN/Config.pm or
35CPAN/MyConfig.pm file (depending on what it is currently using).
36
26844e27 37=head1 LICENSE
38
39This program is free software; you can redistribute it and/or
40modify it under the same terms as Perl itself.
5f05dabc 41
42=cut
43
9ddc4ed0 44use vars qw( %prompts );
45
5f05dabc 46sub init {
554a9ef5 47 my($configpm, %args) = @_;
5f05dabc 48 use Config;
26844e27 49 # extra args after 'o conf init'
9ddc4ed0 50 my $matcher = $args{args} && @{$args{args}} ? $args{args}[0] : '';
26844e27 51 if ($matcher =~ /^\/(.*)\/$/) {
52 # case /regex/ => take the first, ignore the rest
53 $matcher = $1;
54 shift @{$args{args}};
55 if (@{$args{args}}) {
56 local $" = " ";
57 $CPAN::Frontend->mywarn("Ignoring excessive arguments '@{$args{args}}'");
58 $CPAN::Frontend->mysleep(2);
59 }
60 } elsif (0 == length $matcher) {
61 } else {
62 # case WORD... => all arguments must be valid
63 for my $arg (@{$args{args}}) {
64 unless (exists $CPAN::HandleConfig::keys{$arg}) {
65 $CPAN::Frontend->mywarn("'$arg' is not a valid configuration variable");
66 return;
67 }
8962fc49 68 }
26844e27 69 $matcher = "\\b(".join("|",@{$args{args}}).")\\b";
8962fc49 70 }
c9869e1c 71 CPAN->debug("matcher[$matcher]") if $CPAN::DEBUG;
554a9ef5 72
f610777f 73 unless ($CPAN::VERSION) {
74 require CPAN::Nox;
75 }
87892b73 76 require CPAN::HandleConfig;
77 CPAN::HandleConfig::require_myconfig_or_config();
5f05dabc 78 $CPAN::Config ||= {};
da199366 79 local($/) = "\n";
80 local($\) = "";
13bc20ff 81 local($|) = 1;
da199366 82
5fc0f0f6 83 my($ans,$default);
f610777f 84
da199366 85 #
8962fc49 86 #= Files, directories
da199366 87 #
88
8962fc49 89 unless ($matcher) {
90 $CPAN::Frontend->myprint($prompts{manual_config});
91 }
09d9d230 92
554a9ef5 93 my $manual_conf;
94
7fefbd44 95 local *_real_prompt;
554a9ef5 96 if ( $args{autoconfig} ) {
97 $manual_conf = "no";
8962fc49 98 } elsif ($matcher) {
99 $manual_conf = "yes";
554a9ef5 100 } else {
8962fc49 101 my $_conf = prompt("Would you like me to configure as much as possible ".
102 "automatically?", "yes");
103 $manual_conf = ($_conf and $_conf =~ /^y/i) ? "no" : "yes";
554a9ef5 104 }
8962fc49 105 CPAN->debug("manual_conf[$manual_conf]") if $CPAN::DEBUG;
09d9d230 106 my $fastread;
107 {
f915a99a 108 if ($manual_conf =~ /^y/i) {
09d9d230 109 $fastread = 0;
09d9d230 110 } else {
111 $fastread = 1;
36263cb3 112 $CPAN::Config->{urllist} ||= [];
f915a99a 113
114 local $^W = 0;
c9d9b473 115 # prototype should match that of &MakeMaker::prompt
8962fc49 116 my $current_second = time;
117 my $current_second_count = 0;
118 my $i_am_mad = 0;
f915a99a 119 *_real_prompt = sub ($;$) {
09d9d230 120 my($q,$a) = @_;
121 my($ret) = defined $a ? $a : "";
554a9ef5 122 $CPAN::Frontend->myprint(sprintf qq{%s [%s]\n\n}, $q, $ret);
123 eval { require Time::HiRes };
124 unless ($@) {
8962fc49 125 if (time == $current_second) {
126 $current_second_count++;
127 if ($current_second_count > 20) {
128 # I don't like more than 20 prompts per second
129 $i_am_mad++;
130 }
131 } else {
132 $current_second = time;
133 $current_second_count = 0;
134 $i_am_mad-- if $i_am_mad>0;
135 }
136 if ($i_am_mad>0){
137 #require Carp;
138 #Carp::cluck("SLEEEEEEEEPIIIIIIIIIIINGGGGGGGGGGG");
139 Time::HiRes::sleep(0.1);
140 }
554a9ef5 141 }
09d9d230 142 $ret;
143 };
144 }
145 }
9ddc4ed0 146
8962fc49 147 if (!$matcher or 'cpan_home keep_source_where build_dir' =~ /$matcher/){
148 $CPAN::Frontend->myprint($prompts{config_intro});
9ddc4ed0 149
8962fc49 150 if (!$matcher or 'cpan_home' =~ /$matcher/) {
151 my $cpan_home = $CPAN::Config->{cpan_home}
152 || File::Spec->catdir($ENV{HOME}, ".cpan");
5f05dabc 153
8962fc49 154 if (-d $cpan_home) {
155 $CPAN::Frontend->myprint(qq{
5f05dabc 156
157I see you already have a directory
158 $cpan_home
159Shall we use it as the general CPAN build and cache directory?
160
554a9ef5 161});
8962fc49 162 } else {
163 # no cpan-home, must prompt and get one
164 $CPAN::Frontend->myprint($prompts{cpan_home_where});
165 }
f610777f 166
8962fc49 167 $default = $cpan_home;
168 while ($ans = prompt("CPAN build and cache directory?",$default)) {
169 unless (File::Spec->file_name_is_absolute($ans)) {
170 require Cwd;
171 my $cwd = Cwd::cwd();
172 my $absans = File::Spec->catdir($cwd,$ans);
173 $CPAN::Frontend->mywarn("The path '$ans' is not an ".
174 "absolute path. Please specify ".
175 "an absolute path\n");
176 $default = $absans;
177 next;
178 }
179 eval { File::Path::mkpath($ans); }; # dies if it can't
180 if ($@) {
181 $CPAN::Frontend->mywarn("Couldn't create directory $ans.\n".
182 "Please retry.\n");
183 next;
184 }
185 if (-d $ans && -w _) {
186 last;
187 } else {
188 $CPAN::Frontend->mywarn("Couldn't find directory $ans\n".
189 "or directory is not writable. Please retry.\n");
190 }
191 }
192 $CPAN::Config->{cpan_home} = $ans;
193 }
5f05dabc 194
8962fc49 195 if (!$matcher or 'keep_source_where' =~ /$matcher/) {
196 my_dflt_prompt("keep_source_where",
197 File::Spec->catdir($CPAN::Config->{cpan_home},"sources"),
198 $matcher,
199 );
200 }
5f05dabc 201
8962fc49 202 if (!$matcher or 'build_dir' =~ /$matcher/) {
203 my_dflt_prompt("build_dir",
204 File::Spec->catdir($CPAN::Config->{cpan_home},"build"),
205 $matcher
206 );
207 }
208 }
5f05dabc 209
da199366 210 #
8962fc49 211 #= Cache size, Index expire
da199366 212 #
213
8962fc49 214 if (!$matcher or 'build_cache' =~ /$matcher/){
215 $CPAN::Frontend->myprint($prompts{build_cache_intro});
5f05dabc 216
8962fc49 217 # large enough to build large dists like Tk
218 my_dflt_prompt(build_cache => 100, $matcher);
219 }
5e05dca5 220
8962fc49 221 if (!$matcher or 'index_expire' =~ /$matcher/) {
222 $CPAN::Frontend->myprint($prompts{index_expire_intro});
5e05dca5 223
8962fc49 224 my_dflt_prompt(index_expire => 1, $matcher);
c9869e1c 225 }
9d61fa1d 226
8962fc49 227 if (!$matcher or 'scan_cache' =~ /$matcher/){
228 $CPAN::Frontend->myprint($prompts{scan_cache_intro});
9d61fa1d 229
8962fc49 230 my_prompt_loop(scan_cache => 'atstart', $matcher, 'atstart|never');
231 }
9d61fa1d 232
233 #
8962fc49 234 #= cache_metadata
5fc0f0f6 235 #
5fc0f0f6 236
8962fc49 237 my_yn_prompt(cache_metadata => 1, $matcher);
5fc0f0f6 238
239 #
8962fc49 240 #= Do we follow PREREQ_PM?
554a9ef5 241 #
554a9ef5 242
8962fc49 243 if (!$matcher or 'prerequisites_policy' =~ /$matcher/){
244 $CPAN::Frontend->myprint($prompts{prerequisites_policy_intro});
9ddc4ed0 245
8962fc49 246 my_prompt_loop(prerequisites_policy => 'ask', $matcher,
247 'follow|ask|ignore');
248 }
554a9ef5 249
135a59c2 250 if (!$matcher or 'build_requires_install_policy' =~ /$matcher/){
251 $CPAN::Frontend->myprint($prompts{build_requires_install_policy_intro});
252
253 my_prompt_loop(build_requires_install_policy => 'ask/yes', $matcher,
254 'yes|no|ask/yes|ask/no');
255 }
256
554a9ef5 257 #
8962fc49 258 #= Module::Signature
f610777f 259 #
8962fc49 260 if (!$matcher or 'check_sigs' =~ /$matcher/) {
261 my_yn_prompt(check_sigs => 0, $matcher);
262 }
f610777f 263
da199366 264 #
8962fc49 265 #= CPAN::Reporter
ed84aac9 266 #
8962fc49 267 if (!$matcher or 'test_report' =~ /$matcher/) {
268 my_yn_prompt(test_report => 0, $matcher);
269 if (
270 $CPAN::Config->{test_report} &&
271 $CPAN::META->has_inst("CPAN::Reporter") &&
272 CPAN::Reporter->can('configure')
273 ) {
274 $CPAN::Frontend->myprint("\nProceeding to configure CPAN::Reporter.\n");
275 CPAN::Reporter::configure();
276 $CPAN::Frontend->myprint("\nReturning to CPAN configuration.\n");
277 }
278 }
ed84aac9 279
280 #
8962fc49 281 #= External programs
da199366 282 #
283
8962fc49 284 my @external_progs = qw/bzip2 gzip tar unzip make
554a9ef5 285 curl lynx wget ncftpget ncftp ftp
8962fc49 286 gpg/;
287 my(@path) = split /$Config{'path_sep'}/, $ENV{'PATH'};
288 if (!$matcher or "@external_progs" =~ /$matcher/) {
289 $CPAN::Frontend->myprint($prompts{external_progs});
290
291 my $old_warn = $^W;
292 local $^W if $^O eq 'MacOS';
293 local $^W = $old_warn;
294 my $progname;
295 for $progname (@external_progs) {
2ccf00a7 296 next if $matcher && $progname !~ /$matcher/;
8962fc49 297 if ($^O eq 'MacOS') {
298 $CPAN::Config->{$progname} = 'not_here';
299 next;
300 }
8962fc49 301
302 my $progcall = $progname;
2ccf00a7 303 unless ($matcher) {
304 # we really don't need ncftp if we have ncftpget, but
305 # if they chose this dialog via matcher, they shall have it
306 next if $progname eq "ncftp" && $CPAN::Config->{ncftpget} gt " ";
307 }
8962fc49 308 my $path = $CPAN::Config->{$progname}
309 || $Config::Config{$progname}
310 || "";
311 if (File::Spec->file_name_is_absolute($path)) {
312 # testing existence is not good enough, some have these exe
313 # extensions
314
315 # warn "Warning: configured $path does not exist\n" unless -e $path;
316 # $path = "";
317 } elsif ($path =~ /^\s+$/) {
318 # preserve disabled programs
319 } else {
320 $path = '';
321 }
322 unless ($path) {
323 # e.g. make -> nmake
324 $progcall = $Config::Config{$progname} if $Config::Config{$progname};
325 }
09d9d230 326
8962fc49 327 $path ||= find_exe($progcall,[@path]);
328 $CPAN::Frontend->mywarn("Warning: $progcall not found in PATH\n") unless
329 $path; # not -e $path, because find_exe already checked that
330 $ans = prompt("Where is your $progname program?",$path) || $path;
331 $CPAN::Config->{$progname} = $ans;
332 }
5f05dabc 333 }
8962fc49 334
335 if (!$matcher or 'pager' =~ /$matcher/) {
336 my $path = $CPAN::Config->{'pager'} ||
337 $ENV{PAGER} || find_exe("less",[@path]) ||
338 find_exe("more",[@path]) || ($^O eq 'MacOS' ? $ENV{EDITOR} : 0 )
339 || "more";
340 $ans = prompt("What is your favorite pager program?",$path);
341 $CPAN::Config->{'pager'} = $ans;
55e314ee 342 }
8962fc49 343
344 if (!$matcher or 'shell' =~ /$matcher/) {
345 my $path = $CPAN::Config->{'shell'};
346 if (File::Spec->file_name_is_absolute($path)) {
347 $CPAN::Frontend->mywarn("Warning: configured $path does not exist\n")
348 unless -e $path;
349 $path = "";
350 }
351 $path ||= $ENV{SHELL};
352 $path ||= $ENV{COMSPEC} if $^O eq "MSWin32";
353 if ($^O eq 'MacOS') {
354 $CPAN::Config->{'shell'} = 'not_here';
355 } else {
356 $path =~ s,\\,/,g if $^O eq 'os2'; # Cosmetic only
357 $ans = prompt("What is your favorite shell?",$path);
358 $CPAN::Config->{'shell'} = $ans;
359 }
f14b5cec 360 }
da199366 361
362 #
8962fc49 363 #= Installer, arguments to make etc.
da199366 364 #
365
8962fc49 366 if (!$matcher or 'prefer_installer' =~ /$matcher/){
367 $CPAN::Frontend->myprint($prompts{prefer_installer_intro});
e82b9348 368
8962fc49 369 my_prompt_loop(prefer_installer => 'EUMM', $matcher, 'MB|EUMM');
370 }
e82b9348 371
8962fc49 372 if (!$matcher or 'makepl_arg make_arg' =~ /$matcher/){
373 $CPAN::Frontend->myprint($prompts{makepl_arg_intro});
e82b9348 374
8962fc49 375 my_dflt_prompt(makepl_arg => "", $matcher);
376 my_dflt_prompt(make_arg => "", $matcher);
377 }
e82b9348 378
44d21104 379 require CPAN::HandleConfig;
380 if (exists $CPAN::HandleConfig::keys{make_install_make_command}) {
381 # as long as Windows needs $self->_build_command, we cannot
382 # support sudo on windows :-)
383 my_dflt_prompt(make_install_make_command => $CPAN::Config->{make} || "",
384 $matcher);
385 }
e82b9348 386
9ddc4ed0 387 my_dflt_prompt(make_install_arg => $CPAN::Config->{make_arg} || "",
388 $matcher);
e82b9348 389
8962fc49 390 if (!$matcher or 'mbuildpl_arg mbuild_arg' =~ /$matcher/){
391 $CPAN::Frontend->myprint($prompts{mbuildpl_arg_intro});
e82b9348 392
8962fc49 393 my_dflt_prompt(mbuildpl_arg => "", $matcher);
e82b9348 394
8962fc49 395 my_dflt_prompt(mbuild_arg => "", $matcher);
396 }
e82b9348 397
44d21104 398 if (exists $CPAN::HandleConfig::keys{mbuild_install_build_command}) {
399 # as long as Windows needs $self->_build_command, we cannot
400 # support sudo on windows :-)
401 my_dflt_prompt(mbuild_install_build_command => "./Build", $matcher);
402 }
8d97e4a1 403
9ddc4ed0 404 my_dflt_prompt(mbuild_install_arg => "", $matcher);
5f05dabc 405
da199366 406 #
8962fc49 407 #= Alarm period
408 #
409
410 if (!$matcher or 'inactivity_timeout' =~ /$matcher/) {
411 $CPAN::Frontend->myprint($prompts{inactivity_timeout_intro});
412 $default = $CPAN::Config->{inactivity_timeout} || 0;
413 $CPAN::Config->{inactivity_timeout} =
414 prompt("Timeout for inactivity during {Makefile,Build}.PL?",$default);
415 }
416
417 #
418 #= Proxies
da199366 419 #
420
8962fc49 421 my @proxy_vars = qw/ftp_proxy http_proxy no_proxy/;
422 my @proxy_user_vars = qw/proxy_user proxy_pass/;
423 if (!$matcher or "@proxy_vars @proxy_user_vars" =~ /$matcher/){
424 $CPAN::Frontend->myprint($prompts{proxy_intro});
10b2abe6 425
8962fc49 426 for (@proxy_vars) {
427 if (!$matcher or /$matcher/){
428 $default = $CPAN::Config->{$_} || $ENV{$_} || "";
429 $CPAN::Config->{$_} = prompt("Your $_?",$default);
430 }
431 }
10b2abe6 432
8962fc49 433 if ($CPAN::Config->{ftp_proxy} ||
434 $CPAN::Config->{http_proxy}) {
10b2abe6 435
8962fc49 436 $default = $CPAN::Config->{proxy_user} || $CPAN::LWP::UserAgent::USER || "";
da199366 437
8962fc49 438 $CPAN::Frontend->myprint($prompts{proxy_user});
09d9d230 439
8962fc49 440 if ($CPAN::Config->{proxy_user} = prompt("Your proxy user id?",$default)) {
441 $CPAN::Frontend->myprint($prompts{proxy_pass});
c9869e1c 442
8962fc49 443 if ($CPAN::META->has_inst("Term::ReadKey")) {
444 Term::ReadKey::ReadMode("noecho");
445 } else {
446 $CPAN::Frontend->myprint($prompts{password_warn});
447 }
448 $CPAN::Config->{proxy_pass} = prompt_no_strip("Your proxy password?");
449 if ($CPAN::META->has_inst("Term::ReadKey")) {
450 Term::ReadKey::ReadMode("restore");
451 }
452 $CPAN::Frontend->myprint("\n\n");
453 }
454 }
5f05dabc 455 }
456
8962fc49 457 #
458 #= how FTP works
459 #
9ddc4ed0 460
8962fc49 461 my_yn_prompt(ftp_passive => 1, $matcher);
c049f953 462
8962fc49 463 #
464 #= how cwd works
465 #
c049f953 466
8962fc49 467 if (!$matcher or 'getcwd' =~ /$matcher/){
468 $CPAN::Frontend->myprint($prompts{getcwd_intro});
c049f953 469
8962fc49 470 my_prompt_loop(getcwd => 'cwd', $matcher,
471 'cwd|getcwd|fastcwd|backtickcwd');
472 }
473
474 #
475 #= the CPAN shell itself
476 #
477
478 my_yn_prompt(commandnumber_in_prompt => 1, $matcher);
479 my_yn_prompt(term_ornaments => 1, $matcher);
480 if ("colorize_output colorize_print colorize_warn" =~ $matcher) {
481 my_yn_prompt(colorize_output => 0, $matcher);
482 if ($CPAN::Config->{colorize_output}) {
483 for my $tuple (
2ccf00a7 484 ["colorize_print", "bold blue on_white"],
485 ["colorize_warn", "bold red on_white"],
8962fc49 486 ) {
487 my_dflt_prompt($tuple->[0] => $tuple->[1], $matcher);
488 if ($CPAN::META->has_inst("Term::ANSIColor")) {
489 eval { Term::ANSIColor::color($CPAN::Config->{$tuple->[0]})};
490 if ($@) {
491 $CPAN::Config->{$tuple->[0]} = $tuple->[1];
492 $CPAN::Frontend->mywarn($@."setting to default '$tuple->[1]'\n");
493 }
494 }
c049f953 495 }
c049f953 496 }
497 }
498
09d9d230 499 #
8962fc49 500 #== term_is_latin
501 #
502
503 if (!$matcher or 'term_is_latin' =~ /$matcher/){
504 $CPAN::Frontend->myprint($prompts{term_is_latin});
505 my_yn_prompt(term_is_latin => 1, $matcher);
506 }
507
508 #
509 #== save history in file 'histfile'
510 #
511
512 if (!$matcher or 'histfile histsize' =~ /$matcher/) {
513 $CPAN::Frontend->myprint($prompts{histfile_intro});
514 defined($default = $CPAN::Config->{histfile}) or
515 $default = File::Spec->catfile($CPAN::Config->{cpan_home},"histfile");
516 $ans = prompt("File to save your history?", $default);
517 $CPAN::Config->{histfile} = $ans;
518
519 if ($CPAN::Config->{histfile}) {
520 defined($default = $CPAN::Config->{histsize}) or $default = 100;
521 $ans = prompt("Number of lines to save?", $default);
522 $CPAN::Config->{histsize} = $ans;
523 }
524 }
525
526 #
527 #== do an ls on the m or the d command
528 #
529 if (!$matcher or 'show_upload_date' =~ /$matcher/) {
530 $CPAN::Frontend->myprint($prompts{show_upload_date_intro});
531
532 defined($default = $CPAN::Config->{show_upload_date}) or
533 $default = 'n';
534 $ans = prompt("Always try to show upload date with 'd' and 'm' command (yes/no)?",
535 ($default ? 'yes' : 'no'));
536 $CPAN::Config->{show_upload_date} = ($ans =~ /^[y1]/i ? 1 : 0);
537 }
538
539 #
540 #= MIRRORED.BY and conf_sites()
09d9d230 541 #
542
8962fc49 543 if ($matcher){
544 if ("urllist" =~ $matcher) {
545 # conf_sites would go into endless loop with the smash prompt
546 local *_real_prompt;
547 *_real_prompt = \&CPAN::Shell::colorable_makemaker_prompt;
548 conf_sites();
549 }
550 } elsif ($fastread) {
551 $CPAN::Frontend->myprint("Autoconfigured everything but 'urllist'.\n".
552 "Please call 'o conf init urllist' to configure ".
553 "your CPAN server(s) now!");
554 } else {
555 conf_sites();
556 }
09d9d230 557
8962fc49 558 # We don't ask this one now, it's plain silly and maybe is not
559 # even used correctly everywhere.
ca79d794 560 $CPAN::Config->{inhibit_startup_message} = 0;
5f05dabc 561
554a9ef5 562 $CPAN::Frontend->myprint("\n\n");
8962fc49 563 if ($matcher) {
564 $CPAN::Frontend->myprint("Please remember to call 'o conf commit' to ".
565 "make the config permanent!\n\n");
566 } else {
567 CPAN::HandleConfig->commit($configpm);
568 }
5f05dabc 569}
570
9ddc4ed0 571sub my_dflt_prompt {
572 my ($item, $dflt, $m) = @_;
573 my $default = $CPAN::Config->{$item} || $dflt;
574
575 $DB::single = 1;
576 if (!$m || $item =~ /$m/) {
577 $CPAN::Config->{$item} = prompt($prompts{$item}, $default);
578 } else {
579 $CPAN::Config->{$item} = $default;
580 }
581}
582
8962fc49 583sub my_yn_prompt {
584 my ($item, $dflt, $m) = @_;
585 my $default;
586 defined($default = $CPAN::Config->{$item}) or $default = $dflt;
587
588 $DB::single = 1;
589 if (!$m || $item =~ /$m/) {
590 if (my $intro = $prompts{$item . "_intro"}) {
591 $CPAN::Frontend->myprint($intro);
592 }
593 my $ans = prompt($prompts{$item}, $default ? 'yes' : 'no');
594 $CPAN::Config->{$item} = ($ans =~ /^[y1]/i ? 1 : 0);
595 } else {
596 $CPAN::Config->{$item} = $default;
597 }
598}
599
9ddc4ed0 600sub my_prompt_loop {
601 my ($item, $dflt, $m, $ok) = @_;
602 my $default = $CPAN::Config->{$item} || $dflt;
603 my $ans;
604
605 $DB::single = 1;
606 if (!$m || $item =~ /$m/) {
607 do { $ans = prompt($prompts{$item}, $default);
608 } until $ans =~ /$ok/;
609 $CPAN::Config->{$item} = $ans;
610 } else {
611 $CPAN::Config->{$item} = $default;
612 }
613}
614
615
09d9d230 616sub conf_sites {
617 my $m = 'MIRRORED.BY';
5de3f0da 618 my $mby = File::Spec->catfile($CPAN::Config->{keep_source_where},$m);
09d9d230 619 File::Path::mkpath(File::Basename::dirname($mby));
620 if (-f $mby && -f $m && -M $m < -M $mby) {
621 require File::Copy;
622 File::Copy::copy($m,$mby) or die "Could not update $mby: $!";
623 }
911a92db 624 my $loopcount = 0;
de34a54b 625 local $^T = time;
d8773709 626 my $overwrite_local = 0;
627 if ($mby && -f $mby && -M _ <= 60 && -s _ > 0) {
628 my $mtime = localtime((stat _)[9]);
629 my $prompt = qq{Found $mby as of $mtime
630
c049f953 631I\'d use that as a database of CPAN sites. If that is OK for you,
632please answer 'y', but if you want me to get a new database now,
633please answer 'n' to the following question.
d8773709 634
c049f953 635Shall I use the local database in $mby?};
d8773709 636 my $ans = prompt($prompt,"y");
637 $overwrite_local = 1 unless $ans =~ /^y/i;
638 }
de34a54b 639 while ($mby) {
d8773709 640 if ($overwrite_local) {
8962fc49 641 $CPAN::Frontend->myprint(qq{Trying to overwrite $mby\n});
d8773709 642 $mby = CPAN::FTP->localize($m,$mby,3);
643 $overwrite_local = 0;
644 } elsif ( ! -f $mby ){
8962fc49 645 $CPAN::Frontend->myprint(qq{You have no $mby\n I\'m trying to fetch one\n});
36263cb3 646 $mby = CPAN::FTP->localize($m,$mby,3);
911a92db 647 } elsif (-M $mby > 60 && $loopcount == 0) {
8962fc49 648 $CPAN::Frontend->myprint(qq{Your $mby is older than 60 days,\n I\'m trying }.
649 qq{to fetch one\n});
650 $mby = CPAN::FTP->localize($m,$mby,3);
651 $loopcount++;
36263cb3 652 } elsif (-s $mby == 0) {
8962fc49 653 $CPAN::Frontend->myprint(qq{You have an empty $mby,\n I\'m trying to fetch one\n});
36263cb3 654 $mby = CPAN::FTP->localize($m,$mby,3);
655 } else {
656 last;
657 }
09d9d230 658 }
8962fc49 659 local $urllist = [];
09d9d230 660 read_mirrored_by($mby);
de34a54b 661 bring_your_own();
8962fc49 662 $CPAN::Config->{urllist} = $urllist;
09d9d230 663}
664
5f05dabc 665sub find_exe {
666 my($exe,$path) = @_;
55e314ee 667 my($dir);
668 #warn "in find_exe exe[$exe] path[@$path]";
5f05dabc 669 for $dir (@$path) {
5de3f0da 670 my $abs = File::Spec->catfile($dir,$exe);
13bc20ff 671 if (($abs = MM->maybe_command($abs))) {
5f05dabc 672 return $abs;
673 }
674 }
675}
676
f610777f 677sub picklist {
678 my($items,$prompt,$default,$require_nonempty,$empty_warning)=@_;
8962fc49 679 CPAN->debug("picklist('$items','$prompt','$default','$require_nonempty',".
680 "'$empty_warning')") if $CPAN::DEBUG;
f610777f 681 $default ||= '';
682
5fc0f0f6 683 my $pos = 0;
f610777f 684
685 my @nums;
8962fc49 686 SELECTION: while (1) {
ec385757 687
5fc0f0f6 688 # display, at most, 15 items at a time
689 my $limit = $#{ $items } - $pos;
690 $limit = 15 if $limit > 15;
691
692 # show the next $limit items, get the new position
8962fc49 693 $pos = display_some($items, $limit, $pos, $default);
5fc0f0f6 694 $pos = 0 if $pos >= @$items;
695
696 my $num = prompt($prompt,$default);
697
698 @nums = split (' ', $num);
8962fc49 699 {
700 my %seen;
701 @nums = grep { !$seen{$_}++ } @nums;
702 }
5fc0f0f6 703 my $i = scalar @$items;
26844e27 704 unrangify(\@nums);
8962fc49 705 if (grep (/\D/ || $_ < 1 || $_ > $i, @nums)){
706 $CPAN::Frontend->mywarn("invalid items entered, try again\n");
707 if ("@nums" =~ /\D/) {
26844e27 708 $CPAN::Frontend->mywarn("(we are expecting only numbers between 1 and $i)\n");
8962fc49 709 }
710 next SELECTION;
711 }
712 if ($require_nonempty && !@nums) {
713 $CPAN::Frontend->mywarn("$empty_warning\n");
5fc0f0f6 714 }
8962fc49 715 $CPAN::Frontend->myprint("\n");
5fc0f0f6 716
717 # a blank line continues...
8962fc49 718 next SELECTION unless @nums;
5fc0f0f6 719 last;
f610777f 720 }
f610777f 721 for (@nums) { $_-- }
722 @{$items}[@nums];
723}
724
26844e27 725sub unrangify ($) {
726 my($nums) = $_[0];
727 my @nums2 = ();
728 while (@{$nums||[]}) {
729 my $n = shift @$nums;
730 if ($n =~ /^(\d+)-(\d+)$/) {
731 my @range = $1 .. $2;
732 # warn "range[@range]";
733 push @nums2, @range;
734 } else {
735 push @nums2, $n;
736 }
737 }
738 push @$nums, @nums2;
739}
740
ec385757 741sub display_some {
8962fc49 742 my ($items, $limit, $pos, $default) = @_;
743 $pos ||= 0;
ec385757 744
8962fc49 745 my @displayable = @$items[$pos .. ($pos + $limit)];
ec385757 746 for my $item (@displayable) {
8962fc49 747 $CPAN::Frontend->myprint(sprintf "(%d) %s\n", ++$pos, $item);
ec385757 748 }
8962fc49 749 my $hit_what = $default ? "SPACE RETURN" : "RETURN";
750 $CPAN::Frontend->myprint(sprintf("%d more items, hit %s to show them\n",
751 (@$items - $pos),
752 $hit_what,
753 ))
754 if $pos < @$items;
755 return $pos;
ec385757 756}
757
5f05dabc 758sub read_mirrored_by {
de34a54b 759 my $local = shift or return;
9ddc4ed0 760 my(%all,$url,$expected_size,$default,$ans,$host,
761 $dst,$country,$continent,@location);
05454584 762 my $fh = FileHandle->new;
763 $fh->open($local) or die "Couldn't open $local: $!";
f14b5cec 764 local $/ = "\012";
05454584 765 while (<$fh>) {
5f05dabc 766 ($host) = /^([\w\.\-]+)/ unless defined $host;
767 next unless defined $host;
768 next unless /\s+dst_(dst|location)/;
769 /location\s+=\s+\"([^\"]+)/ and @location = (split /\s*,\s*/, $1) and
770 ($continent, $country) = @location[-1,-2];
771 $continent =~ s/\s\(.*//;
f610777f 772 $continent =~ s/\W+$//; # if Jarkko doesn't know latitude/longitude
5f05dabc 773 /dst_dst\s+=\s+\"([^\"]+)/ and $dst = $1;
774 next unless $host && $dst && $continent && $country;
775 $all{$continent}{$country}{$dst} = CPAN::Mirrored::By->new($continent,$country,$dst);
776 undef $host;
777 $dst=$continent=$country="";
778 }
05454584 779 $fh->close;
5f05dabc 780 $CPAN::Config->{urllist} ||= [];
8962fc49 781 my @previous_urls = @{$CPAN::Config->{urllist}};
f610777f 782
8962fc49 783 $CPAN::Frontend->myprint($prompts{urls_intro});
5f05dabc 784
f610777f 785 my (@cont, $cont, %cont, @countries, @urls, %seen);
8962fc49 786 my $no_previous_warn =
787 "Sorry! since you don't have any existing picks, you must make a\n" .
788 "geographic selection.";
789 my $offer_cont = [sort keys %all];
790 if (@previous_urls) {
791 push @$offer_cont, "(edit previous picks)";
792 $default = @$offer_cont;
793 }
794 @cont = picklist($offer_cont,
f610777f 795 "Select your continent (or several nearby continents)",
8962fc49 796 $default,
f610777f 797 ! @previous_urls,
798 $no_previous_warn);
799
800
801 foreach $cont (@cont) {
802 my @c = sort keys %{$all{$cont}};
803 @cont{@c} = map ($cont, 0..$#c);
804 @c = map ("$_ ($cont)", @c) if @cont > 1;
805 push (@countries, @c);
5f05dabc 806 }
8962fc49 807 if (@previous_urls && @countries) {
808 push @countries, "(edit previous picks)";
809 $default = @countries;
810 }
f610777f 811
812 if (@countries) {
813 @countries = picklist (\@countries,
814 "Select your country (or several nearby countries)",
8962fc49 815 $default,
f610777f 816 ! @previous_urls,
817 $no_previous_warn);
818 %seen = map (($_ => 1), @previous_urls);
819 # hmmm, should take list of defaults from CPAN::Config->{'urllist'}...
820 foreach $country (@countries) {
8962fc49 821 next if $country =~ /edit previous picks/;
f610777f 822 (my $bare_country = $country) =~ s/ \(.*\)//;
823 my @u = sort keys %{$all{$cont{$bare_country}}{$bare_country}};
824 @u = grep (! $seen{$_}, @u);
825 @u = map ("$_ ($bare_country)", @u)
8962fc49 826 if @countries > 1;
f610777f 827 push (@urls, @u);
828 }
829 }
830 push (@urls, map ("$_ (previous pick)", @previous_urls));
5fc0f0f6 831 my $prompt = "Select as many URLs as you like (by number),
26844e27 832put them on one line, separated by blanks, hyphenated ranges allowed
833 e.g. '1 4 5' or '7 1-4 8'";
f610777f 834 if (@previous_urls) {
8962fc49 835 $default = join (' ', ((scalar @urls) - (scalar @previous_urls) + 1) ..
836 (scalar @urls));
837 $prompt .= "\n(or just hit RETURN to keep your previous picks)";
f610777f 838 }
839
840 @urls = picklist (\@urls, $prompt, $default);
841 foreach (@urls) { s/ \(.*\)//; }
8962fc49 842 push @$urllist, @urls;
de34a54b 843}
f610777f 844
de34a54b 845sub bring_your_own {
8962fc49 846 my %seen = map (($_ => 1), @$urllist);
de34a54b 847 my($ans,@urls);
f610777f 848 do {
de34a54b 849 my $prompt = "Enter another URL or RETURN to quit:";
850 unless (%seen) {
851 $prompt = qq{CPAN.pm needs at least one URL where it can fetch CPAN files from.
852
853Please enter your CPAN site:};
854 }
855 $ans = prompt ($prompt, "");
f610777f 856
857 if ($ans) {
de34a54b 858 $ans =~ s|/?\z|/|; # has to end with one slash
f610777f 859 $ans = "file:$ans" unless $ans =~ /:/; # without a scheme is a file:
860 if ($ans =~ /^\w+:\/./) {
8d97e4a1 861 push @urls, $ans unless $seen{$ans}++;
de34a54b 862 } else {
8962fc49 863 $CPAN::Frontend->
864 myprint(sprintf(qq{"%s" doesn\'t look like an URL at first sight.
8d97e4a1 865I\'ll ignore it for now.
866You can add it to your %s
867later if you\'re sure it\'s right.\n},
8962fc49 868 $ans,
869 $INC{'CPAN/MyConfig.pm'}
870 || $INC{'CPAN/Config.pm'}
871 || "configuration file",
872 ));
f610777f 873 }
874 }
de34a54b 875 } while $ans || !%seen;
f610777f 876
8962fc49 877 push @$urllist, @urls;
f610777f 878 # xxx delete or comment these out when you're happy that it works
8962fc49 879 $CPAN::Frontend->myprint("New set of picks:\n");
880 map { $CPAN::Frontend->myprint(" $_\n") } @$urllist;
5f05dabc 881}
882
f915a99a 883
884sub _strip_spaces {
885 $_[0] =~ s/^\s+//; # no leading spaces
886 $_[0] =~ s/\s+\z//; # no trailing spaces
887}
888
f915a99a 889sub prompt ($;$) {
7fefbd44 890 unless (defined &_real_prompt) {
891 *_real_prompt = \&CPAN::Shell::colorable_makemaker_prompt;
892 }
f915a99a 893 my $ans = _real_prompt(@_);
894
895 _strip_spaces($ans);
896
897 return $ans;
898}
899
900
901sub prompt_no_strip ($;$) {
902 return _real_prompt(@_);
903}
904
905
9ddc4ed0 906BEGIN {
907
908my @prompts = (
909
910manual_config => qq[
911
912CPAN is the world-wide archive of perl resources. It consists of about
8962fc49 913300 sites that all replicate the same contents around the globe. Many
914countries have at least one CPAN site already. The resources found on
915CPAN are easily accessible with the CPAN.pm module. If you want to use
916CPAN.pm, lots of things have to be configured. Fortunately, most of
917them can be determined automatically. If you prefer the automatic
918configuration, answer 'yes' below.
919
920If you prefer to enter a dialog instead, you can answer 'no' to this
921question and I'll let you configure in small steps one thing after the
922other. (Note: you can revisit this dialog anytime later by typing 'o
923conf init' at the cpan prompt.)
9ddc4ed0 924
925],
926
927config_intro => qq{
928
929The following questions are intended to help you with the
930configuration. The CPAN module needs a directory of its own to cache
931important index files and maybe keep a temporary mirror of CPAN files.
932This may be a site-wide directory or a personal directory.
933
934},
935
936# cpan_home => qq{ },
937
938cpan_home_where => qq{
939
940First of all, I\'d like to create this directory. Where?
941
942},
943
944keep_source_where => qq{
945
8962fc49 946Unless you are accessing the CPAN via the filesystem directly CPAN.pm
947needs to keep the source files it downloads somewhere. Please supply a
948directory where the downloaded files are to be kept.},
9ddc4ed0 949
950build_cache_intro => qq{
951
952How big should the disk cache be for keeping the build directories
953with all the intermediate files\?
954
955},
956
957build_cache =>
958"Cache size for build directory (in MB)?",
959
8962fc49 960build_dir =>
961
962"Directory where the build process takes place?",
9ddc4ed0 963
964scan_cache_intro => qq{
965
966By default, each time the CPAN module is started, cache scanning is
967performed to keep the cache size in sync. To prevent this, answer
968'never'.
969
970},
971
972scan_cache => "Perform cache scanning (atstart or never)?",
973
8962fc49 974cache_metadata_intro => qq{
9ddc4ed0 975
976To considerably speed up the initial CPAN shell startup, it is
977possible to use Storable to create a cache of metadata. If Storable
978is not available, the normal index mechanism will be used.
979
980},
981
8962fc49 982cache_metadata => qq{Cache metadata (yes/no)?},
983
984term_is_latin_intro => qq{
9ddc4ed0 985
986The next option deals with the charset (aka character set) your
987terminal supports. In general, CPAN is English speaking territory, so
988the charset does not matter much, but some of the aliens out there who
989upload their software to CPAN bear names that are outside the ASCII
990range. If your terminal supports UTF-8, you should say no to the next
991question. If it supports ISO-8859-1 (also known as LATIN1) then you
992should say yes. If it supports neither, your answer does not matter
993because you will not be able to read the names of some authors
994anyway. If you answer no, names will be output in UTF-8.
995
996},
997
8962fc49 998term_is_latin => qq{Your terminal expects ISO-8859-1 (yes/no)?},
999
c9869e1c 1000histfile_intro => qq{
9ddc4ed0 1001
1002If you have one of the readline packages (Term::ReadLine::Perl,
1003Term::ReadLine::Gnu, possibly others) installed, the interactive CPAN
1004shell will have history support. The next two questions deal with the
1005filename of the history file and with its size. If you do not want to
1006set this variable, please hit SPACE RETURN to the following question.
1007
1008},
1009
c9869e1c 1010histfile => qq{File to save your history?},
1011
9ddc4ed0 1012show_upload_date_intro => qq{
1013
1014The 'd' and the 'm' command normally only show you information they
1015have in their in-memory database and thus will never connect to the
1016internet. If you set the 'show_upload_date' variable to true, 'm' and
1017'd' will additionally show you the upload date of the module or
1018distribution. Per default this feature is off because it may require a
1019net connection to get at the upload date.
1020
1021},
1022
1023show_upload_date =>
1024"Always try to show upload date with 'd' and 'm' command (yes/no)?",
1025
1026prerequisites_policy_intro => qq{
1027
1028The CPAN module can detect when a module which you are trying to build
1029depends on prerequisites. If this happens, it can build the
1030prerequisites for you automatically ('follow'), ask you for
1031confirmation ('ask'), or just ignore them ('ignore'). Please set your
1032policy to one of the three values.
1033
1034},
1035
1036prerequisites_policy =>
c9869e1c 1037"Policy on building prerequisites (follow, ask or ignore)?",
9ddc4ed0 1038
ed84aac9 1039check_sigs_intro => qq{
1040
1041CPAN packages can be digitally signed by authors and thus verified
1042with the security provided by strong cryptography. The exact mechanism
1043is defined in the Module::Signature module. While this is generally
1044considered a good thing, it is not always convenient to the end user
1045to install modules that are signed incorrectly or where the key of the
1046author is not available or where some prerequisite for
1047Module::Signature has a bug and so on.
1048
1049With the check_sigs parameter you can turn signature checking on and
1050off. The default is off for now because the whole tool chain for the
1051functionality is not yet considered mature by some. The author of
1052CPAN.pm would recommend setting it to true most of the time and
1053turning it off only if it turns out to be annoying.
1054
1055Note that if you do not have Module::Signature installed, no signature
1056checks will be performed at all.
1057
1058},
1059
1060check_sigs =>
1061qq{Always try to check and verify signatures if a SIGNATURE file is in the package
1062and Module::Signature is installed (yes/no)?},
1063
8962fc49 1064test_report_intro =>
1065qq{
1066
1067The goal of the CPAN Testers project (http://testers.cpan.org/) is to
1068test as many CPAN packages as possible on as many platforms as
1069possible. This provides valuable feedback to module authors and
1070potential users to identify bugs or platform compatibility issues and
1071improves the overall quality and value of CPAN.
1072
1073One way you can contribute is to send test results for each module
1074that you install. If you install the CPAN::Reporter module, you have
1075the option to automatically generate and email test reports to CPAN
1076Testers whenever you run tests on a CPAN package.
1077
1078See the CPAN::Reporter documentation for additional details and
1079configuration settings. If your firewall blocks outgoing email,
1080you will need to configure CPAN::Reporter before sending reports.
1081
1082},
1083
1084test_report =>
1085qq{Email test reports if CPAN::Reporter is installed (yes/no)?},
1086
9ddc4ed0 1087external_progs => qq{
1088
1089The CPAN module will need a few external programs to work properly.
1090Please correct me, if I guess the wrong path for a program. Don\'t
1091panic if you do not have some of them, just press ENTER for those. To
8962fc49 1092disable the use of a program, you can type a space followed by ENTER.
9ddc4ed0 1093
1094},
1095
1096prefer_installer_intro => qq{
1097
1098When you have Module::Build installed and a module comes with both a
1099Makefile.PL and a Build.PL, which shall have precedence? The two
1100installer modules we have are the old and well established
8962fc49 1101ExtUtils::MakeMaker (for short: EUMM) which uses the Makefile.PL and
9ddc4ed0 1102the next generation installer Module::Build (MB) works with the
1103Build.PL.
1104
1105},
1106
1107prefer_installer =>
1108qq{In case you could choose, which installer would you prefer (EUMM or MB)?},
1109
1110makepl_arg_intro => qq{
1111
1112Every Makefile.PL is run by perl in a separate process. Likewise we
1113run \'make\' and \'make install\' in separate processes. If you have
1114any parameters \(e.g. PREFIX, LIB, UNINST or the like\) you want to
1115pass to the calls, please specify them here.
1116
1117If you don\'t understand this question, just press ENTER.
1118},
1119
1120makepl_arg => qq{
1121Parameters for the 'perl Makefile.PL' command?
1122Typical frequently used settings:
1123
1124 PREFIX=~/perl # non-root users (please see manual for more hints)
1125
1126Your choice: },
1127
1128make_arg => qq{Parameters for the 'make' command?
1129Typical frequently used setting:
1130
1131 -j3 # dual processor system
1132
1133Your choice: },
1134
1135
1136make_install_make_command => qq{Do you want to use a different make command for 'make install'?
1137Cautious people will probably prefer:
1138
1139 su root -c make
1140or
1141 sudo make
1142or
1143 /path1/to/sudo -u admin_account /path2/to/make
1144
1145or some such. Your choice: },
1146
1147
1148make_install_arg => qq{Parameters for the 'make install' command?
1149Typical frequently used setting:
1150
1151 UNINST=1 # to always uninstall potentially conflicting files
1152
1153Your choice: },
1154
1155
1156mbuildpl_arg_intro => qq{
1157
1158The next questions deal with Module::Build support.
1159
1160A Build.PL is run by perl in a separate process. Likewise we run
1161'./Build' and './Build install' in separate processes. If you have any
1162parameters you want to pass to the calls, please specify them here.
1163
1164},
1165
1166mbuildpl_arg => qq{Parameters for the 'perl Build.PL' command?
1167Typical frequently used settings:
1168
1169 --install_base /home/xxx # different installation directory
1170
1171Your choice: },
1172
1173mbuild_arg => qq{Parameters for the './Build' command?
1174Setting might be:
1175
1176 --extra_linker_flags -L/usr/foo/lib # non-standard library location
1177
1178Your choice: },
1179
1180
1181mbuild_install_build_command => qq{Do you want to use a different command for './Build install'?
1182Sudo users will probably prefer:
1183
1184 su root -c ./Build
1185or
1186 sudo ./Build
1187or
1188 /path1/to/sudo -u admin_account ./Build
1189
1190or some such. Your choice: },
1191
1192
1193mbuild_install_arg => qq{Parameters for the './Build install' command?
1194Typical frequently used setting:
1195
1196 --uninst 1 # uninstall conflicting files
1197
1198Your choice: },
1199
1200
1201
1202inactivity_timeout_intro => qq{
1203
1204Sometimes you may wish to leave the processes run by CPAN alone
8962fc49 1205without caring about them. Because the Makefile.PL or the Build.PL
1206sometimes contains question you\'re expected to answer, you can set a
1207timer that will kill a 'perl Makefile.PL' process after the specified
1208time in seconds.
9ddc4ed0 1209
1210If you set this value to 0, these processes will wait forever. This is
1211the default and recommended setting.
1212
1213},
1214
1215inactivity_timeout =>
1216qq{Timeout for inactivity during {Makefile,Build}.PL? },
1217
1218
c9869e1c 1219proxy_intro => qq{
9ddc4ed0 1220
1221If you\'re accessing the net via proxies, you can specify them in the
1222CPAN configuration or via environment variables. The variable in
1223the \$CPAN::Config takes precedence.
1224
1225},
1226
1227proxy_user => qq{
1228
1229If your proxy is an authenticating proxy, you can store your username
1230permanently. If you do not want that, just press RETURN. You will then
1231be asked for your username in every future session.
1232
1233},
1234
1235proxy_pass => qq{
1236
1237Your password for the authenticating proxy can also be stored
1238permanently on disk. If this violates your security policy, just press
1239RETURN. You will then be asked for the password in every future
1240session.
1241
1242},
1243
1244urls_intro => qq{
1245
1246Now we need to know where your favorite CPAN sites are located. Push
1247a few sites onto the array (just in case the first on the array won\'t
1248work). If you are mirroring CPAN to your local workstation, specify a
1249file: URL.
1250
8962fc49 1251First, pick a nearby continent and country by typing in the number(s)
1252in front of the item(s) you want to select. You can pick several of
1253each, separated by spaces. Then, you will be presented with a list of
1254URLs of CPAN mirrors in the countries you selected, along with
1255previously selected URLs. Select some of those URLs, or just keep the
1256old list. Finally, you will be prompted for any extra URLs -- file:,
1257ftp:, or http: -- that host a CPAN mirror.
9ddc4ed0 1258
1259},
1260
1261password_warn => qq{
1262
1263Warning: Term::ReadKey seems not to be available, your password will
1264be echoed to the terminal!
1265
1266},
1267
8962fc49 1268commandnumber_in_prompt => qq{
1269
1270The prompt of the cpan shell can contain the current command number
1271for easier tracking of the session or be a plain string. Do you want
1272the command number in the prompt (yes/no)?},
1273
1274ftp_passive => qq{
1275
1276Shall we always set FTP_PASSIVE envariable when dealing with ftp
1277download (yes/no)?},
1278
1279# taken from the manpage:
1280getcwd_intro => qq{
1281
1282CPAN.pm changes the current working directory often and needs to
1283determine its own current working directory. Per default it uses
1284Cwd::cwd but if this doesn't work on your system for some reason,
1285alternatives can be configured according to the following table:
1286
1287 cwd Cwd::cwd
1288 getcwd Cwd::getcwd
1289 fastcwd Cwd::fastcwd
1290 backtickcwd external command cwd
1291
1292},
1293
1294getcwd => qq{Preferred method for determining the current working directory?},
1295
1296index_expire_intro => qq{
1297
1298The CPAN indexes are usually rebuilt once or twice per hour, but the
1299typical CPAN mirror mirrors only once or twice per day. Depending on
1300the quality of your mirror and your desire to be on the bleeding edge,
1301you may want to set the following value to more or less than one day
1302(which is the default). It determines after how many days CPAN.pm
1303downloads new indexes.
1304
1305},
1306
1307index_expire => qq{Let the index expire after how many days?},
1308
1309term_ornaments => qq{
1310
1311When using Term::ReadLine, you can turn ornaments on so that your
1312input stands out against the output from CPAN.pm. Do you want to turn
1313ornaments on?},
1314
1315colorize_output => qq{
1316
1317When you have Term::ANSIColor installed, you can turn on colorized
1318output to have some visual differences between normal CPAN.pm output,
1319warnings, and the output of the modules being installed. Set your
1320favorite colors after some experimenting with the Term::ANSIColor
1321module. Do you want to turn on colored output?},
1322
1323colorize_print => qq{Color for normal output?},
1324
1325colorize_warn => qq{Color for warnings?},
1326
135a59c2 1327build_requires_install_policy_intro => qq{
1328
1329When a module declares another one as a 'build_requires' prerequisite
1330this means that the other module is only needed for building or
1331testing the module but need not be installed permanently. In this case
1332you may wish to install that other module nonetheless or just keep it
1333in the 'build_dir' directory to have it available only temporarily.
1334Installing saves time on future installations but makes the perl
1335installation bigger.
1336
1337You can choose if you want to always install (yes), never install (no)
1338or be always asked. In the latter case you can set the default answer
1339for the question to yes (ask/yes) or no (ask/no).
1340
1341},
1342
1343build_requires_install_policy =>
1344qq{Policy on installing 'build_requires' modules (yes, no, ask/yes,
1345ask/no)?},
1346
9ddc4ed0 1347);
1348
1349die "Coding error in \@prompts declaration. Odd number of elements, above"
1350 if (@prompts % 2);
1351
1352%prompts = @prompts;
1353
1354if (scalar(keys %prompts) != scalar(@prompts)/2) {
9ddc4ed0 1355 my %already;
9ddc4ed0 1356 for my $item (0..$#prompts) {
1357 next if $item % 2;
8962fc49 1358 die "$prompts[$item] is duplicated\n" if $already{$prompts[$item]}++;
9ddc4ed0 1359 }
9ddc4ed0 1360}
1361
8962fc49 1362} # EOBEGIN
9ddc4ed0 1363
5f05dabc 13641;