3 #use warnings; # corelist and find throw tons of warnings
6 use SL::InstallationCheck;
10 my (%uselines, %modules, %supplied, %requires);
12 # since the information which classes belong to a cpan distribution is not
13 # easily obtained, I'll just hard code the bigger ones we use here. the same
14 # hash will be filled later with information gathered from the source files.
17 'DateTime::Duration' => 1,
18 'DateTime::Infinite' => 1,
20 'Rose::DB::Object' => {
21 'Rose::DB::Object::ConventionManager' => 1,
22 'Rose::DB::Object::Manager' => 1,
23 'Rose::DB::Object::Metadata' => 1,
26 'Rose::Object::MakeMethods::Generic' => 1,
29 'Template::Constants' => 1,
30 'Template::Exception' => 1,
31 'Template::Iterator' => 1,
32 'Template::Plugin' => 1,
33 'Template::Plugin::Filter' => 1,
34 'Template::Plugin::HTML' => 1,
37 'namespace::clean' => 1,
42 'files-with-match|l' => \ my $l,
46 return unless /(\.p[lm]|console)$/;
48 # remember modules shipped with Lx-Office
49 $supplied{modulize($File::Find::name)}++
50 if $File::Find::dir =~ m#modules/#;
52 open my $fh, '<', $_ or warn "can't open $_: $!";
57 next if /Support::Files/; # our own test support module
58 next if /use (warnings|strict|vars|lib|constant|utf8)/;
60 my ($useline) = m/^use\s+(.*?)$/;
62 next if $useline =~ /^[\d._]+;/; # skip version requirements
65 $uselines{$useline} ||= [];
66 push @{ $uselines{$useline} }, $File::Find::name;
70 for my $useline (keys %uselines) {
71 $useline =~ s/#.*//; # kill comments
73 # modules can be loaded implicitly with use base qw(Module) or use parent
74 # 'Module'. catch these:
75 my ($module, $args) = $useline =~ /
80 )? # optional parent block
85 # some comments looks very much like use lines
86 # try to get rid of them
87 next if $useline =~ /^it like a normal Perl node/; # YAML::Dump comment
88 next if $useline =~ /^most and offer that in a small/; # YAML
90 my $version = Module::CoreList->first_release($module);
91 $modules{$module} = { status => $supplied{$module} ? 'included'
92 : $version ? sprintf '%2.6f', $version
93 : is_required($module) ? 'required'
94 : is_optional($module) ? 'optional'
95 : is_developer($module) ? 'developer'
97 files => $uselines{$useline},
100 # build requirement tree
101 for my $file (@{ $uselines{$useline} }) {
102 next if $file =~ /\.pl$/;
103 my $orig_module = modulize($file);
104 $requires{$orig_module} ||= {};
105 $requires{$orig_module}{$module}++;
109 # build transitive closure for documented dependancies
113 for my $src_module (keys %requires) {
114 for my $dst_module (keys %{ $requires{$src_module} }) {
115 if ( $modules{$src_module}
116 && $modules{$dst_module}
117 && $modules{$src_module}->{status} =~ /^(required|devel|optional)/
118 && $modules{$dst_module}->{status} eq '!missing') {
119 $modules{$dst_module}->{status} = "required"; # . ", via $src_module";
127 print sprintf "%8s : %s", color_text($modules{$_}->{status}), $_;
129 print " $_" for @{ $modules{$_}->{files} || [] };
132 $modules{$a}->{status} cmp $modules{$b}->{status}
137 for (my ($name) = @_) {
148 grep { $_->{name} eq $module } @SL::InstallationCheck::required_modules;
153 grep { $_->{name} eq $module } @SL::InstallationCheck::optional_modules;
158 grep { $_->{name} eq $module } @SL::InstallationCheck::developer_modules;
163 return color(get_color($text)) . $text . color('reset');
168 return 'yellow' if /^5./ && $_ > 5.008;
169 return 'green' if /^5./;
170 return 'green' if /^included/;
171 return 'red' if /^!missing/;
186 # perl scipts/find-use.pl
187 !missing : Perl::Tags
188 !missing : Template::Constants
193 This util is useful for package builders to identify all the CPAN dependencies
194 we have. It requires Module::CoreList (which is core since 5.9) to determine if
195 a module is distributed with perl or not. The output will be one of the
202 If a version string is displayed, the module is core since this version.
203 Everything up to 5.8 is alright. 5.10 (aka 5.010) is acceptable, but should be
204 documented. Please do not use 5.12 core modules without adding an explicit
209 This module is included in C<modules/*>. Don't worry about it.
213 This module is documented in C<SL:InstallationCheck> to be necessary, or is a
214 dependancy of one of these. Everything alright.
218 These modules are neither core, nor included, nor required. This is ok for
219 developer tools, but should never occur for modules the actual program uses.
225 http://www.ledgersmb.org/ - The LedgerSMB team
226 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
230 Distributed under the terms of the GNU General Public License v2.