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