3 #use warnings; # corelist and find throw tons of warnings
 
   6 use SL::InstallationCheck;
 
   9 my (%uselines, %modules, %supplied, %requires);
 
  11 # since the information which classes belong to a cpan distribution is not
 
  12 # easily obtained, I'll just hard code the bigger ones we use here. the same
 
  13 # hash will be filled later with information gathered from the source files.
 
  15   'Rose::DB::Object' => {
 
  16    'Rose::DB::Object::ConventionManager' => 1,
 
  17    'Rose::DB::Object::Manager'           => 1,
 
  18    'Rose::DB::Object::Metadata'          => 1,
 
  21     'Rose::Object::MakeMethods::Generic' => 1,
 
  24     'Template::Constants'                => 1,
 
  25     'Template::Exception'                => 1,
 
  26     'Template::Iterator'                 => 1,
 
  27     'Template::Plugin'                   => 1,
 
  28     'Template::Plugin::Filter'           => 1,
 
  33   return unless /(\.p[lm]|console)$/;
 
  35   # remember modules shipped with Lx-Office
 
  36   $supplied{modulize($File::Find::name)}++
 
  37     if $File::Find::dir =~ m#modules/#;
 
  39   open my $fh, '<', $_ or warn "can't open $_: $!";
 
  44     next if /Support::Files/; # our own test support module
 
  45     next if /use (warnings|strict|vars|lib|constant|utf8)/;
 
  47     my ($useline) = m/^use\s+(.*?)$/;
 
  49     next if  $useline =~ /^[\d.]+;/; # skip version requirements
 
  52     $uselines{$useline} ||= [];
 
  53     push @{ $uselines{$useline} }, $File::Find::name;
 
  57 for my $useline (keys %uselines) {
 
  58   $useline =~ s/#.*//; # kill comments
 
  60   # modules can be loaded implicitly with use base qw(Module) or use parent
 
  61   # 'Module'. catch these:
 
  62   my ($module, $args) = $useline =~ /
 
  67     )?                 # optional parent block
 
  72   # some comments looks very much like use lines
 
  73   # try to get rid of them
 
  74   next if $useline =~ /^it like a normal Perl node/;   # YAML::Dump comment
 
  75   next if $useline =~ /^most and offer that in a small/; # YAML
 
  77   my $version = Module::CoreList->first_release($module);
 
  78   $modules{$module} = $supplied{$module}     ? 'included'
 
  79                     : $version               ? sprintf '%2.6f', $version
 
  80                     : is_documented($module) ? 'required'
 
  83   # build requirement tree
 
  84   for my $file (@{ $uselines{$useline} }) {
 
  85     next if $file =~ /\.pl$/;
 
  86     my $orig_module = modulize($file);
 
  87     $requires{$orig_module} ||= {};
 
  88     $requires{$orig_module}{$module}++;
 
  92 # build transitive closure for documented dependancies
 
  96   for my $src_module (keys %requires) {
 
  97     for my $dst_module (keys %{ $requires{$src_module} }) {
 
  98       if (   $modules{$src_module} =~ /^required/
 
  99           && $modules{$dst_module} eq '!missing') {
 
 100         $modules{$dst_module} = "required"; # . ", via $src_module";
 
 107 print sprintf "%8s : %s", color_text($modules{$_}), $_
 
 109        $modules{$a} cmp $modules{$b}
 
 114   for (my ($name) = @_) {
 
 125   grep { $_->{name} eq $module } @SL::InstallationCheck::required_modules;
 
 130   return color(get_color($text)) . $text . color('reset');
 
 135     return 'yellow' if /^5./ && $_ > 5.008;
 
 136     return 'green'  if /^5./;
 
 137     return 'green'  if /^included/;
 
 138     return 'red'    if /^!missing/;
 
 153  # perl scipts/find-use.pl
 
 154  !missing : Perl::Tags
 
 155  !missing : Template::Constants
 
 160 This util is useful for package builders to identify all the CPAN dependencies
 
 161 we have. It requires Module::CoreList (which is core since 5.9) to determine if
 
 162 a module is distributed with perl or not.  The output will be one of the
 
 169 If a version string is displayed, the module is core since this version.
 
 170 Everything up to 5.8 is alright. 5.10 (aka 5.010) is acceptable, but should be
 
 171 documented. Please do not use 5.12 core modules without adding an explicit
 
 176 This module is included in C<modules/*>. Don't worry about it.
 
 180 This module is documented in C<SL:InstallationCheck> to be necessary, or is a
 
 181 dependancy of one of these. Everything alright.
 
 185 These modules are neither core, nor included, nor required. This is ok for
 
 186 developer tools, but should never occur for modules the actual program uses.
 
 190 http://www.ledgersmb.org/ - The LedgerSMB team
 
 191 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
 
 195 Distributed under the terms of the GNU General Public License v2.