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.
31 my $Module_Help = <<EOF;
32 Available commands are:
33 f [all|prog|doc] - List installed files of a given type
34 d [all|prog|doc] - List the directories used by a module
35 v - Validate the .packlist - check for missing files
36 t <tarfile> - Create a tar archive of the module
37 h - Display module help
41 my %Module_Commands = (
42 f => \&list_installed,
43 d => \&list_directories,
44 v => \&validate_packlist,
45 t => \&create_archive,
53 MODULE_CMD: while (1) {
54 print("$module cmd? ");
56 my $reply = <STDIN>; chomp($reply);
57 my($cmd) = $reply =~ /^(\w)\b/;
61 if( $Module_Commands{$cmd} ) {
62 $Module_Commands{$cmd}->($reply, $module);
64 elsif( $cmd eq 'q' ) {
75 my($reply, $module) = @_;
77 my $class = (split(' ', $reply))[1];
78 $class = 'all' unless $class;
81 if (eval { @files = $Inst->files($module, $class); }) {
82 print("$class files in $module are:\n ",
83 join("\n ", @files), "\n");
91 sub list_directories {
92 my($reply, $module) = @_;
94 my $class = (split(' ', $reply))[1];
95 $class = 'all' unless $class;
98 if (eval { @dirs = $Inst->directories($module, $class); }) {
99 print("$class directories in $module are:\n ",
100 join("\n ", @dirs), "\n");
109 my($reply, $module) = @_;
111 my $file = (split(' ', $reply))[1];
113 if( !(defined $file and length $file) ) {
114 print "No tar file specified\n";
116 elsif( eval { require Archive::Tar } ) {
117 Archive::Tar->create_archive($file, 0, $Inst->files($module));
120 my($first, @rest) = $Inst->files($module);
121 system('tar', 'cvf', $file, $first);
123 system('tar', 'rvf', $file, $f);
125 print "Can't use tar\n" if $?;
130 sub validate_packlist {
131 my($reply, $module) = @_;
133 if (my @missing = $Inst->validate($module)) {
134 print("Files missing from $module are:\n ",
135 join("\n ", @missing), "\n");
138 print("$module has no missing files\n");
148 ##############################################################################
153 Available commands are:
154 l - List all installed modules
155 m <module> - Select a module
162 my $reply = <STDIN>; chomp($reply);
167 print("Installed modules are:\n ", join("\n ", @Modules), "\n");
170 $reply =~ /^m\s+/ and do
172 do_module((split(' ', $reply))[1]);
186 ###############################################################################
188 $Inst = ExtUtils::Installed->new();
189 @Modules = $Inst->modules();
192 ###############################################################################