diff options
author | Steve Peters <steve@fisharerojo.org> | 2007-01-20 03:20:11 +0000 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2007-01-20 03:20:11 +0000 |
commit | b72dd56fb0d60fb6da69e621d692ef4dc931ad43 (patch) | |
tree | c63a8d018388190cdaeef4797f5b10bf8977b775 /lib/CPAN | |
parent | 613f191e047db38572099edee06ae7ede4343b5b (diff) | |
download | perl-b72dd56fb0d60fb6da69e621d692ef4dc931ad43.tar.gz |
Upgrade to CPAN-1.88_69.
p4raw-id: //depot/perl@29892
Diffstat (limited to 'lib/CPAN')
-rw-r--r-- | lib/CPAN/FirstTime.pm | 71 | ||||
-rw-r--r-- | lib/CPAN/HandleConfig.pm | 47 |
2 files changed, 99 insertions, 19 deletions
diff --git a/lib/CPAN/FirstTime.pm b/lib/CPAN/FirstTime.pm index 9490934b95..8b412ab83d 100644 --- a/lib/CPAN/FirstTime.pm +++ b/lib/CPAN/FirstTime.pm @@ -19,7 +19,7 @@ use File::Basename (); use File::Path (); use File::Spec (); use vars qw($VERSION $urllist); -$VERSION = sprintf "%.6f", substr(q$Rev: 1379 $,4)/1000000 + 5.4; +$VERSION = sprintf "%.6f", substr(q$Rev: 1457 $,4)/1000000 + 5.4; =head1 NAME @@ -242,6 +242,12 @@ Shall we use it as the general CPAN build and cache directory? } # + #= Config: auto_commit + # + + my_yn_prompt(auto_commit => 0, $matcher); + + # #= Cache size, Index expire # @@ -318,9 +324,16 @@ Shall we use it as the general CPAN build and cache directory? #= External programs # - my @external_progs = qw/bzip2 gzip tar unzip make - curl lynx wget ncftpget ncftp ftp - gpg patch/; + my @external_progs = qw/bzip2 gzip tar unzip + + make + + curl lynx wget ncftpget ncftp ftp + + gpg + + patch applypatch + /; my(@path) = split /$Config{'path_sep'}/, $ENV{'PATH'}; if (!$matcher or "@external_progs" =~ /$matcher/) { $CPAN::Frontend->myprint($prompts{external_progs}); @@ -507,17 +520,40 @@ Shall we use it as the general CPAN build and cache directory? } # - #= the CPAN shell itself + #= the CPAN shell itself (prompt, color) # my_yn_prompt(commandnumber_in_prompt => 1, $matcher); my_yn_prompt(term_ornaments => 1, $matcher); - if ("colorize_output colorize_print colorize_warn" =~ $matcher) { + if ("colorize_output colorize_print colorize_warn colorize_debug" =~ $matcher) { my_yn_prompt(colorize_output => 0, $matcher); if ($CPAN::Config->{colorize_output}) { + if ($CPAN::META->has_inst("Term::ANSIColor")) { + my $T="gYw"; + print " on_ on_y ". + " on_ma on_\n"; + print " on_black on_red green ellow ". + "on_blue genta on_cyan white\n"; + + for my $FG ("", "bold", + map {$_,"bold $_"} "black","red","green", + "yellow","blue", + "magenta", + "cyan","white"){ + printf "%12s ", $FG; + for my $BG ("",map {"on_$_"} qw(black red green yellow + blue magenta cyan white)){ + print $FG||$BG ? + Term::ANSIColor::colored(" $T ","$FG $BG") : " $T "; + } + print "\n"; + } + print "\n"; + } for my $tuple ( ["colorize_print", "bold blue on_white"], ["colorize_warn", "bold red on_white"], + ["colorize_debug", "black on_cyan"], ) { my_dflt_prompt($tuple->[0] => $tuple->[1], $matcher); if ($CPAN::META->has_inst("Term::ANSIColor")) { @@ -598,7 +634,7 @@ Shall we use it as the general CPAN build and cache directory? $CPAN::Config->{inhibit_startup_message} = 0; $CPAN::Frontend->myprint("\n\n"); - if ($matcher) { + if ($matcher && !$CPAN::Config->{auto_commit}) { $CPAN::Frontend->myprint("Please remember to call 'o conf commit' to ". "make the config permanent!\n\n"); } else { @@ -1417,14 +1453,16 @@ colorize_output => qq{ When you have Term::ANSIColor installed, you can turn on colorized output to have some visual differences between normal CPAN.pm output, -warnings, and the output of the modules being installed. Set your -favorite colors after some experimenting with the Term::ANSIColor -module. Do you want to turn on colored output?}, +warnings, debugging output, and the output of the modules being +installed. Set your favorite colors after some experimenting with the +Term::ANSIColor module. Do you want to turn on colored output?}, colorize_print => qq{Color for normal output?}, colorize_warn => qq{Color for warnings?}, +colorize_debug => qq{Color for debugging messages?}, + build_requires_install_policy_intro => qq{ When a module declares another one as a 'build_requires' prerequisite @@ -1471,7 +1509,18 @@ host should be tried first. randomize_urllist => "Randomize parameter", -); +auto_commit_intro => qq{ + +Normally CPAN.pm keeps config variables in memory and changes need to +be saved in a separate 'o conf commit' command to make them permanent +between sessions. If you set the 'auto_commit' option to true, changes +to a config variable are always automatically committed to disk. + +}, + +auto_commit => qq{Always commit changes to config variables to disk?}, + + ); die "Coding error in \@prompts declaration. Odd number of elements, above" if (@prompts % 2); diff --git a/lib/CPAN/HandleConfig.pm b/lib/CPAN/HandleConfig.pm index 3d03b56cf0..e8859fc272 100644 --- a/lib/CPAN/HandleConfig.pm +++ b/lib/CPAN/HandleConfig.pm @@ -2,7 +2,7 @@ package CPAN::HandleConfig; use strict; use vars qw(%can %keys $VERSION); -$VERSION = sprintf "%.6f", substr(q$Rev: 1379 $,4)/1000000 + 5.4; +$VERSION = sprintf "%.6f", substr(q$Rev: 1467 $,4)/1000000 + 5.4; %can = ( commit => "Commit changes to disk", @@ -16,6 +16,8 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 1379 $,4)/1000000 + 5.4; # A2: svn diff -r 985:986 # where andk added yaml_module %keys = map { $_ => undef } ( + "applypatch", + "auto_commit", "build_cache", "build_dir", "build_dir_reuse", @@ -23,6 +25,7 @@ $VERSION = sprintf "%.6f", substr(q$Rev: 1379 $,4)/1000000 + 5.4; "bzip2", "cache_metadata", "check_sigs", + "colorize_debug", "colorize_output", "colorize_print", "colorize_warn", @@ -124,13 +127,21 @@ sub edit { unless (exists $keys{$o}) { $CPAN::Frontend->mywarn("Warning: unknown configuration variable '$o'\n"); } + my $changed; + + # one day I used randomize_urllist for a boolean, so we must # list them explicitly --ak - if ($o =~ /^(wait_list|urllist|dontload_list)$/) { + if (0) { + } elsif ($o =~ /^(wait_list|urllist|dontload_list)$/) { + + # + # ARRAYS + # + $func = shift @args; $func ||= ""; CPAN->debug("func[$func]args[@args]") if $CPAN::DEBUG; - my $changed; # Let's avoid eval, it's easier to comprehend without. if ($func eq "push") { push @{$CPAN::Config->{$o}}, @args; @@ -156,7 +167,6 @@ sub edit { $self->prettyprint($o); } if ($changed) { - $CPAN::CONFIG_DIRTY = 1; if ($o eq "urllist") { # reset the cached values undef $CPAN::FTP::Thesite; @@ -166,24 +176,42 @@ sub edit { $CPAN::META->{dontload_hash} = {}; } } - return $changed; } elsif ($o =~ /_hash$/) { + + # + # HASHES + # + if (@args==1 && $args[0] eq ""){ @args = (); } elsif (@args % 2) { push @args, ""; } $CPAN::Config->{$o} = { @args }; - $CPAN::CONFIG_DIRTY = 1; + $changed = 1; } else { + + # + # SCALARS + # + if (defined $args[0]){ $CPAN::CONFIG_DIRTY = 1; $CPAN::Config->{$o} = $args[0]; + $changed = 1; } $self->prettyprint($o) if exists $keys{$o} or defined $CPAN::Config->{$o}; - return 1; } + if ($changed) { + if ($CPAN::Config->{auto_commit}) { + $self->commit; + } else { + $CPAN::CONFIG_DIRTY = 1; + $CPAN::Frontend->myprint("Please use 'o conf commit' to ". + "make the config permanent!\n\n"); + } + } } } @@ -530,9 +558,12 @@ $configpm initialized. CPAN::FirstTime::init($configpm, %args); } + +# returns mandatory but missing entries in the Config sub missing_config_data { my(@miss); for ( + "auto_commit", "build_cache", "build_dir", "cache_metadata", @@ -653,7 +684,7 @@ sub prefs_lookup { use strict; use vars qw($AUTOLOAD $VERSION); - $VERSION = sprintf "%.2f", substr(q$Rev: 1379 $,4)/100; + $VERSION = sprintf "%.2f", substr(q$Rev: 1467 $,4)/100; # formerly CPAN::HandleConfig was known as CPAN::Config sub AUTOLOAD { |