jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [tools/] [checklibs.pl] - Rev 28 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env perl

use warnings;
use diagnostics;
use strict;

use Cwd;

my $mydir=Cwd::cwd();
my @path= split /\//,$mydir;
my $subdir=pop @path;
my $subsubdir=pop @path;

my $modname="";
my $type="";


if ($subdir eq "lib") { $type="lib"; }
if ($subdir eq "modules") { $type="allmods"; }
if ($subdir eq "platform") { $type="module"; $modname=$subsubdir; chdir ".."; }
if ($subsubdir eq "modules") { $type="module"; $modname=$subdir; }
if ((-d "lib") and (-d "modules") and (-d "tools")) { $type="everything"; }

print "$type\n";

if    ($type eq "module")     { check_module($modname); }
elsif ($type eq "allmods")    { check_all_mods(); }
elsif ($type eq "lib")        { check_main_libs(); }
elsif ($type eq "everything") { chdir "lib"; check_main_libs(); chdir "../modules"; check_all_mods(); }



sub check_module {
  my $modname=shift;
  print "CHECKING MODULE ",uc $modname,"\n";
  opendir DIR,"./platform";
  my @files= grep /\.pm$/,readdir DIR;
  closedir DIR;
  use lib "./platform";
  foreach my $nn (@files) {
    chomp $nn;
    print "  $modname/$nn\n";
    require "$nn";
    if ($nn ne "common.pm") {
      scrub_package("HotSaNICmod");
      scrub_package("syssnmp");
      }
    }
  print "\n";
  }


sub check_all_mods {
  opendir DIR,".";
  my @modules = grep !/\.|CVS/,readdir DIR;
  closedir DIR;
  foreach my $modname (@modules) {
    if (-d $modname) {
      print $modname;
      chdir $modname;
      check_module($modname);
      chdir "..";
      }
    }
  }


sub check_main_libs {
  print "CHECKING MAIN LIBRARIES\n";
  opendir DIR,".";
  my @files= grep /\.pm$/,readdir DIR;
  closedir DIR;
  chdir "CVS";
  use lib "..";
  foreach my $nn (@files) {
    chomp $nn;
    print "  $nn\n";
    require "$nn";
    }
  chdir "..";
  print "\n";
  }


sub scrub_package {
  no strict 'refs';
  my $pack = shift;
  die "Shouldn't delete main package" 
  if $pack eq "" || $pack eq "main";
  my $stash = *{$pack . '::'}{HASH};
  my $name;
  foreach $name (keys %$stash) {
    my $fullname = $pack . '::' . $name;
    # Get rid of everything with that name.
    undef $$fullname;
    undef @$fullname;
    undef %$fullname;
    undef &$fullname;
    undef *$fullname;
    }
  }  


Powered by WebSVN 2.2.1