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.
16 'DateTime::Duration' => 1,
17 'DateTime::Infinite' => 1,
19 'Rose::DB::Object' => {
20 'Rose::DB::Object::ConventionManager' => 1,
21 'Rose::DB::Object::Manager' => 1,
22 'Rose::DB::Object::Metadata' => 1,
25 'Rose::Object::MakeMethods::Generic' => 1,
28 'Template::Constants' => 1,
29 'Template::Exception' => 1,
30 'Template::Iterator' => 1,
31 'Template::Plugin' => 1,
32 'Template::Plugin::Filter' => 1,
37 return unless /(\.p[lm]|console)$/;
39 # remember modules shipped with Lx-Office
40 $supplied{modulize($File::Find::name)}++
41 if $File::Find::dir =~ m#modules/#;
43 open my $fh, '<', $_ or warn "can't open $_: $!";
48 next if /Support::Files/; # our own test support module
49 next if /use (warnings|strict|vars|lib|constant|utf8)/;
51 my ($useline) = m/^use\s+(.*?)$/;
53 next if $useline =~ /^[\d._]+;/; # skip version requirements
56 $uselines{$useline} ||= [];
57 push @{ $uselines{$useline} }, $File::Find::name;
61 for my $useline (keys %uselines) {
62 $useline =~ s/#.*//; # kill comments
64 # modules can be loaded implicitly with use base qw(Module) or use parent
65 # 'Module'. catch these:
66 my ($module, $args) = $useline =~ /
71 )? # optional parent block
76 # some comments looks very much like use lines
77 # try to get rid of them
78 next if $useline =~ /^it like a normal Perl node/; # YAML::Dump comment
79 next if $useline =~ /^most and offer that in a small/; # YAML
81 my $version = Module::CoreList->first_release($module);
82 $modules{$module} = $supplied{$module} ? 'included'
83 : $version ? sprintf '%2.6f', $version
84 : is_documented($module) ? 'required'
87 # build requirement tree
88 for my $file (@{ $uselines{$useline} }) {
89 next if $file =~ /\.pl$/;
90 my $orig_module = modulize($file);
91 $requires{$orig_module} ||= {};
92 $requires{$orig_module}{$module}++;
96 # build transitive closure for documented dependancies
100 for my $src_module (keys %requires) {
101 for my $dst_module (keys %{ $requires{$src_module} }) {
102 if ( $modules{$src_module} =~ /^required/
103 && $modules{$dst_module} eq '!missing') {
104 $modules{$dst_module} = "required"; # . ", via $src_module";
111 print sprintf "%8s : %s", color_text($modules{$_}), $_
113 $modules{$a} cmp $modules{$b}
118 for (my ($name) = @_) {
129 grep { $_->{name} eq $module } @SL::InstallationCheck::required_modules;
134 return color(get_color($text)) . $text . color('reset');
139 return 'yellow' if /^5./ && $_ > 5.008;
140 return 'green' if /^5./;
141 return 'green' if /^included/;
142 return 'red' if /^!missing/;
157 # perl scipts/find-use.pl
158 !missing : Perl::Tags
159 !missing : Template::Constants
164 This util is useful for package builders to identify all the CPAN dependencies
165 we have. It requires Module::CoreList (which is core since 5.9) to determine if
166 a module is distributed with perl or not. The output will be one of the
173 If a version string is displayed, the module is core since this version.
174 Everything up to 5.8 is alright. 5.10 (aka 5.010) is acceptable, but should be
175 documented. Please do not use 5.12 core modules without adding an explicit
180 This module is included in C<modules/*>. Don't worry about it.
184 This module is documented in C<SL:InstallationCheck> to be necessary, or is a
185 dependancy of one of these. Everything alright.
189 These modules are neither core, nor included, nor required. This is ok for
190 developer tools, but should never occur for modules the actual program uses.
194 http://www.ledgersmb.org/ - The LedgerSMB team
195 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
199 Distributed under the terms of the GNU General Public License v2.