5 use ExtUtils::Packlist;
6 use ExtUtils::Installed;
8 use vars qw($Inst @Modules);
13 instmodsh - A shell to examine installed modules
21 A little interface to ExtUtils::Installed to examine installed modules,
22 validate your packlists and even create a tarball from an installed module.
27 my $Module_Help = <<EOF;
28 Available commands are:
29 f [all|prog|doc] - List installed files of a given type
30 d [all|prog|doc] - List the directories used by a module
31 v - Validate the .packlist - check for missing files
32 t <tarfile> - Create a tar archive of the module
33 h - Display module help
37 my %Module_Commands = (
38 f => \&list_installed,
39 d => \&list_directories,
40 v => \&validate_packlist,
41 t => \&create_archive,
49 MODULE_CMD: while (1) {
50 print("$module cmd? ");
52 my $reply = <STDIN>; chomp($reply);
53 my($cmd) = $reply =~ /^(\w)\b/;
57 if( $Module_Commands{$cmd} ) {
58 $Module_Commands{$cmd}->($reply, $module);
60 elsif( $cmd eq 'q' ) {
71 my($reply, $module) = @_;
73 my $class = (split(' ', $reply))[1];
74 $class = 'all' unless $class;
77 if (eval { @files = $Inst->files($module, $class); }) {
78 print("$class files in $module are:\n ",
79 join("\n ", @files), "\n");
87 sub list_directories {
88 my($reply, $module) = @_;
90 my $class = (split(' ', $reply))[1];
91 $class = 'all' unless $class;
94 if (eval { @dirs = $Inst->directories($module, $class); }) {
95 print("$class directories in $module are:\n ",
96 join("\n ", @dirs), "\n");
105 my($reply, $module) = @_;
107 my $file = (split(' ', $reply))[1];
108 my $tmp = "/tmp/inst.$$";
110 if( !(defined $file and length $file) ) {
111 print "No tar file specified\n";
113 elsif( eval { require Archive::Tar } ) {
114 Archive::Tar->create_archive($file, 0, $Inst->files($module));
117 my($first, @rest) = $Inst->files($module);
118 system('tar', 'cvf', $file, $first);
120 system('tar', 'rvf', $file, $f);
122 print "Can't use tar\n" if $?;
127 sub validate_packlist {
128 my($reply, $module) = @_;
130 if (my @missing = $Inst->validate($module)) {
131 print("Files missing from $module are:\n ",
132 join("\n ", @missing), "\n");
135 print("$module has no missing files\n");
145 ##############################################################################
150 Available commands are:
151 l - List all installed modules
152 m <module> - Select a module
159 my $reply = <STDIN>; chomp($reply);
164 print("Installed modules are:\n ", join("\n ", @Modules), "\n");
167 $reply =~ /^m\s+/ and do
169 do_module((split(' ', $reply))[1]);
183 ###############################################################################
185 $Inst = ExtUtils::Installed->new();
186 @Modules = $Inst->modules();
189 ###############################################################################