root/honeyclient/branches/exp/bhenderson-browser_automation/bin/uninstall_honeyclient.pl

Revision 1499, 1.4 kB (checked in by kindlund, 9 months ago)

Merging simpler_agent branch into trunk.

  • Property svn:executable set to *
  • Property svn:keywords set to Id "$file"
Line 
1 #!/usr/bin/perl -w
2
3 # $Id$
4
5 use strict;
6 use warnings;
7 use IO::Dir;
8 use ExtUtils::Packlist;
9 use ExtUtils::Installed;
10 use ExtUtils::MakeMaker qw(prompt);
11
12 our $PACKAGE_NAME = "HoneyClient";
13
14 sub emptydir($) {
15     my ($dir) = @_;
16     my $dh = IO::Dir->new($dir) || return(0);
17     my @count = $dh->read();
18     $dh->close();
19     return(@count == 2 ? 1 : 0);
20 }
21
22 # Find all the installed instances.
23 print "Finding all installed " . $PACKAGE_NAME . " packages...\n";
24 my $installed = ExtUtils::Installed->new();
25 my @module_list = grep(/^$PACKAGE_NAME.*/, $installed->modules());
26
27 if (scalar(@module_list) <= 0) {
28     print "No " . $PACKAGE_NAME . " packages found.\n";
29     exit;
30 }
31
32 foreach my $module (@module_list) {
33     my $version = $installed->version($module) || "?.?";
34     print "\nFound package: " . $module . " v" . $version . "\n";
35     my $question = prompt("Do you want to uninstall " . $module . "?", "no");
36     if ($question && $question =~ /^y.*/i) {
37         # Remove all the files
38         foreach my $file (sort($installed->files($module))) {
39             print "rm $file\n";
40             unlink($file);
41         }
42         my $pf = $installed->packlist($module)->packlist_file();
43         print "rm $pf\n";
44         unlink($pf);
45         foreach my $dir (sort($installed->directory_tree($module))) {
46             if (emptydir($dir)) {
47                 print "rmdir $dir\n";
48                 rmdir($dir);
49             }
50         }
51     }
52 }
53
54 print "\nFinished.\n";
Note: See TracBrowser for help on using the browser.