Skip to content

Commit

Permalink
Introduce config variable cleanup_after_install
Browse files Browse the repository at this point in the history
  • Loading branch information
andk committed Aug 16, 2016
1 parent 561f554 commit cdfa254
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/CPAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,9 @@ currently defined:
bzip2 path to external prg
cache_metadata use serializer to cache metadata
check_sigs if signatures should be verified
cleanup_after_install
remove build directory immediately after a
successful install
colorize_debug Term::ANSIColor attributes for debugging output
colorize_output boolean if Term::ANSIColor should colorize output
colorize_print Term::ANSIColor attributes for normal output
Expand Down
9 changes: 8 additions & 1 deletion lib/CPAN/Distribution.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3955,6 +3955,11 @@ sub install {
$CPAN::Frontend->myprint(" $system -- OK\n");
$CPAN::META->is_installed($self->{build_dir});
$self->{install} = CPAN::Distrostatus->new("YES");
if ($CPAN::Config->{'cleanup_after_install'}) {
my $parent = File::Spec->catdir( $self->{build_dir}, File::Spec->updir );
chdir $parent or $CPAN::Frontend->mydie("Couldn't chdir to $parent: $!\n");
File::Path::rmtree($self->{build_dir});
}
} else {
$self->{install} = CPAN::Distrostatus->new("NO");
$CPAN::Frontend->mywarn(" $system -- NOT OK\n");
Expand All @@ -3981,7 +3986,9 @@ sub install {
}
}
delete $self->{force_update};
$self->store_persistent_state;
unless ($CPAN::Config->{'cleanup_after_install'}) {
$self->store_persistent_state;
}

$self->post_install();

Expand Down
9 changes: 9 additions & 0 deletions lib/CPAN/FirstTime.pm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ checks will be performed at all.
Always try to check and verify signatures if a SIGNATURE file is in
the package and Module::Signature is installed (yes/no)?
=item cleanup_after_install
Users who install modules and do not intend to look back, can free
occupied disk space quickly by letting CPAN.pm cleanup each build
directory immediately after a successful install.
Remove build directory after a successful install? (yes/no)?
=item colorize_output
When you have Term::ANSIColor installed, you can turn on colorized
Expand Down Expand Up @@ -881,6 +889,7 @@ sub init {

my_dflt_prompt(index_expire => 1, $matcher);
my_prompt_loop(scan_cache => 'atstart', $matcher, 'atstart|atexit|never');
my_yn_prompt(cleanup_after_install => 0, $matcher);

#
#= cache_metadata
Expand Down
1 change: 1 addition & 0 deletions lib/CPAN/HandleConfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ $VERSION = "5.5007"; # see also CPAN::Config::VERSION at end of file
"bzip2",
"cache_metadata",
"check_sigs",
"cleanup_after_install",
"colorize_debug",
"colorize_output",
"colorize_print",
Expand Down

0 comments on commit cdfa254

Please sign in to comment.