| 1 | 1 | simandl | #!/usr/bin/env perl |
| 2 | | | |
| 3 | | | use warnings; |
| 4 | | | use diagnostics; |
| 5 | | | use strict; |
| 6 | | | |
| 7 | | | use Cwd; |
| 8 | | | |
| 9 | | | my $mydir=Cwd::cwd(); |
| 10 | | | my @path= split /\//,$mydir; |
| 11 | | | my $subdir=pop @path; |
| 12 | | | my $subsubdir=pop @path; |
| 13 | | | |
| 14 | | | my $modname=""; |
| 15 | | | my $type=""; |
| 16 | | | |
| 17 | | | |
| 18 | | | if ($subdir eq "lib") { $type="lib"; } |
| 19 | | | if ($subdir eq "modules") { $type="allmods"; } |
| 20 | | | if ($subdir eq "platform") { $type="module"; $modname=$subsubdir; chdir ".."; } |
| 21 | | | if ($subsubdir eq "modules") { $type="module"; $modname=$subdir; } |
| 22 | | | if ((-d "lib") and (-d "modules") and (-d "tools")) { $type="everything"; } |
| 23 | | | |
| 24 | | | print "$type\n"; |
| 25 | | | |
| 26 | | | if ($type eq "module") { check_module($modname); } |
| 27 | | | elsif ($type eq "allmods") { check_all_mods(); } |
| 28 | | | elsif ($type eq "lib") { check_main_libs(); } |
| 29 | | | elsif ($type eq "everything") { chdir "lib"; check_main_libs(); chdir "../modules"; check_all_mods(); } |
| 30 | | | |
| 31 | | | |
| 32 | | | |
| 33 | | | sub check_module { |
| 34 | | | my $modname=shift; |
| 35 | | | print "CHECKING MODULE ",uc $modname,"\n"; |
| 36 | | | opendir DIR,"./platform"; |
| 37 | | | my @files= grep /\.pm$/,readdir DIR; |
| 38 | | | closedir DIR; |
| 39 | | | use lib "./platform"; |
| 40 | | | foreach my $nn (@files) { |
| 41 | | | chomp $nn; |
| 42 | | | print " $modname/$nn\n"; |
| 43 | | | require "$nn"; |
| 44 | | | if ($nn ne "common.pm") { |
| 45 | | | scrub_package("HotSaNICmod"); |
| 46 | | | scrub_package("syssnmp"); |
| 47 | | | } |
| 48 | | | } |
| 49 | | | print "\n"; |
| 50 | | | } |
| 51 | | | |
| 52 | | | |
| 53 | | | sub check_all_mods { |
| 54 | | | opendir DIR,"."; |
| 55 | | | my @modules = grep !/\.|CVS/,readdir DIR; |
| 56 | | | closedir DIR; |
| 57 | | | foreach my $modname (@modules) { |
| 58 | | | if (-d $modname) { |
| 59 | | | print $modname; |
| 60 | | | chdir $modname; |
| 61 | | | check_module($modname); |
| 62 | | | chdir ".."; |
| 63 | | | } |
| 64 | | | } |
| 65 | | | } |
| 66 | | | |
| 67 | | | |
| 68 | | | sub check_main_libs { |
| 69 | | | print "CHECKING MAIN LIBRARIES\n"; |
| 70 | | | opendir DIR,"."; |
| 71 | | | my @files= grep /\.pm$/,readdir DIR; |
| 72 | | | closedir DIR; |
| 73 | | | chdir "CVS"; |
| 74 | | | use lib ".."; |
| 75 | | | foreach my $nn (@files) { |
| 76 | | | chomp $nn; |
| 77 | | | print " $nn\n"; |
| 78 | | | require "$nn"; |
| 79 | | | } |
| 80 | | | chdir ".."; |
| 81 | | | print "\n"; |
| 82 | | | } |
| 83 | | | |
| 84 | | | |
| 85 | | | sub scrub_package { |
| 86 | | | no strict 'refs'; |
| 87 | | | my $pack = shift; |
| 88 | | | die "Shouldn't delete main package" |
| 89 | | | if $pack eq "" || $pack eq "main"; |
| 90 | | | my $stash = *{$pack . '::'}{HASH}; |
| 91 | | | my $name; |
| 92 | | | foreach $name (keys %$stash) { |
| 93 | | | my $fullname = $pack . '::' . $name; |
| 94 | | | # Get rid of everything with that name. |
| 95 | | | undef $$fullname; |
| 96 | | | undef @$fullname; |
| 97 | | | undef %$fullname; |
| 98 | | | undef &$fullname; |
| 99 | | | undef *$fullname; |
| 100 | | | } |
| 101 | | | } |
| 102 | | | |