helpers/cpan_uninstall.pl in automateit-0.71221 vs helpers/cpan_uninstall.pl in automateit-0.71226

- old
+ new

@@ -1,9 +1,14 @@ #!/usr/bin/env perl # Example: ./uninstall.pl Acme::please +use warnings "all"; +use File::Basename; +my $wrapper = dirname($0)."/cpan_wrapper.pl"; +require $wrapper; + sub usage { my($message) = @_; print <<EOB; usage: uninstall.pl [--quiet|--help|--dryrun] module [modules...] EOB @@ -13,15 +18,11 @@ } else { exit 0; } } -use warnings "all"; -use ExtUtils::Packlist; -use ExtUtils::Installed; use Getopt::Long; - our $quiet = 0; our $dryrun = 0; our $help = 0; GetOptions( 'quiet' => \$quiet, @@ -37,27 +38,21 @@ @modules = @ARGV; unless ($#modules >= 0) { usage "No modules specified"; } -sub nuke { - my($target) = @_; - if ($dryrun == 0) { - unlink($target) || die "$! -- $target" - } -} +$CpanWrapper::DRYRUN = $dryrun; +if (0 && $CpanWrapper::DRYRUN) { die } # Squelch warnings -my $packlists = ExtUtils::Installed->new(); - foreach my $module (@modules) { + unless (CpanWrapper->is_installed($module)) { + print "! Module isn't installed: $module\n"; + next; + } + print "* Uninstalling module: $module\n" unless $quiet; - foreach my $item ($packlists->files($module)) { - print "- File: $item\n" unless $quiet; - nuke $item; + my(@files) = CpanWrapper->uninstall($module); + foreach my $file (@files) { + print "- File: $file\n" unless $quiet; } - - my $packlist = $packlists->packlist($module)->packlist_file(); - print "- List: $packlist\n" unless $quiet; - # NOTE: Leave packlist alone so it can be uninstalled if something goes catastrophically wrong with this uninstaller. - #IK# nuke $packlist; }