Merge branch 'master' of http://repo.or.cz/r/msysgit into devel
[msysgit/historical-msysgit.git] / lib / perl5 / 5.6.1 / ExtUtils / inst
blobcbf2d01194a0d372f1cfb4dc8fd8687ebba87f30
1 #!/usr/local/bin/perl -w
3 use strict;
4 use IO::File;
5 use ExtUtils::Packlist;
6 use ExtUtils::Installed;
8 use vars qw($Inst @Modules);
10 ################################################################################
12 sub do_module($)
14 my ($module) = @_;
15 my $help = <<EOF;
16 Available commands are:
17 f [all|prog|doc] - List installed files of a given type
18 d [all|prog|doc] - List the directories used by a module
19 v - Validate the .packlist - check for missing files
20 t <tarfile> - Create a tar archive of the module
21 q - Quit the module
22 EOF
23 print($help);
24 while (1)
26 print("$module cmd? ");
27 my $reply = <STDIN>; chomp($reply);
28 CASE:
30 $reply =~ /^f\s*/ and do
32 my $class = (split(' ', $reply))[1];
33 $class = 'all' if (! $class);
34 my @files;
35 if (eval { @files = $Inst->files($module, $class); })
37 print("$class files in $module are:\n ",
38 join("\n ", @files), "\n");
39 last CASE;
41 else
42 { print($@); }
44 $reply =~ /^d\s*/ and do
46 my $class = (split(' ', $reply))[1];
47 $class = 'all' if (! $class);
48 my @dirs;
49 if (eval { @dirs = $Inst->directories($module, $class); })
51 print("$class directories in $module are:\n ",
52 join("\n ", @dirs), "\n");
53 last CASE;
55 else
56 { print($@); }
58 $reply =~ /^t\s*/ and do
60 my $file = (split(' ', $reply))[1];
61 my $tmp = "/tmp/inst.$$";
62 if (my $fh = IO::File->new($tmp, "w"))
64 $fh->print(join("\n", $Inst->files($module)));
65 $fh->close();
66 system("tar cvf $file -I $tmp");
67 unlink($tmp);
68 last CASE;
70 else { print("Can't open $file: $!\n"); }
71 last CASE;
73 $reply eq 'v' and do
75 if (my @missing = $Inst->validate($module))
77 print("Files missing from $module are:\n ",
78 join("\n ", @missing), "\n");
80 else
82 print("$module has no missing files\n");
84 last CASE;
86 $reply eq 'q' and do
88 return;
90 # Default
91 print($help);
96 ################################################################################
98 sub toplevel()
100 my $help = <<EOF;
101 Available commands are:
102 l - List all installed modules
103 m <module> - Select a module
104 q - Quit the program
106 print($help);
107 while (1)
109 print("cmd? ");
110 my $reply = <STDIN>; chomp($reply);
111 CASE:
113 $reply eq 'l' and do
115 print("Installed modules are:\n ", join("\n ", @Modules), "\n");
116 last CASE;
118 $reply =~ /^m\s+/ and do
120 do_module((split(' ', $reply))[1]);
121 last CASE;
123 $reply eq 'q' and do
125 exit(0);
127 # Default
128 print($help);
133 ################################################################################
135 $Inst = ExtUtils::Installed->new();
136 @Modules = $Inst->modules();
137 toplevel();
139 ################################################################################