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,
40 'Email::MIME::Creator' => 1,
44 'TAP::Parser::Aggregator' => 1,
49 'files-with-match|l' => \ my $l,
53 return unless /(\.p[lm]|console)$/;
55 # remember modules shipped with kivitendo
56 $supplied{modulize($File::Find::name)}++
57 if $File::Find::dir =~ m#modules/#;
59 open my $fh, '<', $_ or warn "can't open $_: $!";
64 next if /Support::Files/; # our own test support module
65 next if /use (warnings|strict|vars|lib|constant|utf8)/;
67 my ($useline) = m/^use\s+(.*?)$/;
69 next if $useline =~ /^[\d._]+;/; # skip version requirements
72 $uselines{$useline} ||= [];
73 push @{ $uselines{$useline} }, $File::Find::name;
77 for my $useline (keys %uselines) {
78 $useline =~ s/#.*//; # kill comments
80 # modules can be loaded implicitly with use base qw(Module) or use parent
81 # 'Module'. catch these:
82 my ($module, $args) = $useline =~ /
87 )? # optional parent block
92 # some comments looks very much like use lines
93 # try to get rid of them
94 next if $useline =~ /^it like a normal Perl node/; # YAML::Dump comment
95 next if $useline =~ /^most and offer that in a small/; # YAML
97 my $version = Module::CoreList->first_release($module);
98 $modules{$module} = { status => $supplied{$module} ? 'included'
99 : $version ? sprintf '%2.6f', $version
100 : is_required($module) ? 'required'
101 : is_optional($module) ? 'optional'
102 : is_developer($module) ? 'developer'
104 files => $uselines{$useline},
107 # build requirement tree
108 for my $file (@{ $uselines{$useline} }) {
109 next if $file =~ /\.pl$/;
110 my $orig_module = modulize($file);
111 $requires{$orig_module} ||= {};
112 $requires{$orig_module}{$module}++;
116 # have all documented modules mentioned here
117 $modules{$_->{name}} ||= { status => 'required' } for @SL::InstallationCheck::required_modules;
118 $modules{$_->{name}} ||= { status => 'optional' } for @SL::InstallationCheck::optional_modules;
119 $modules{$_->{name}} ||= { status => 'developer' } for @SL::InstallationCheck::developer_modules;
121 # build transitive closure for documented dependancies
125 for my $src_module (keys %requires) {
126 for my $dst_module (keys %{ $requires{$src_module} }) {
127 if ( $modules{$src_module}
128 && $modules{$dst_module}
129 && $modules{$src_module}->{status} =~ /^(required|devel|optional)/
130 && $modules{$dst_module}->{status} eq '!missing') {
131 $modules{$dst_module}->{status} = "required"; # . ", via $src_module";
139 print sprintf "%8s : %s", color_text($modules{$_}->{status}), $_;
141 print " $_" for @{ $modules{$_}->{files} || [] };
144 $modules{$a}->{status} cmp $modules{$b}->{status}
149 for (my ($name) = @_) {
160 grep { $_->{name} eq $module } @SL::InstallationCheck::required_modules;
165 grep { $_->{name} eq $module } @SL::InstallationCheck::optional_modules;
170 grep { $_->{name} eq $module } @SL::InstallationCheck::developer_modules;
175 return color(get_color($text)) . $text . color('reset');
180 return 'yellow' if /^5./ && $_ > 5.008;
181 return 'green' if /^5./;
182 return 'green' if /^included/;
183 return 'red' if /^!missing/;
198 # perl scipts/find-use.pl
199 !missing : Perl::Tags
200 !missing : Template::Constants
205 This util is useful for package builders to identify all the CPAN dependencies
206 we have. It requires Module::CoreList (which is core since 5.9) to determine if
207 a module is distributed with perl or not. The output will be one of the
214 If a version string is displayed, the module is core since this version.
215 Everything up to 5.8 is alright. 5.10 (aka 5.010) is acceptable, but should be
216 documented. Please do not use 5.12 core modules without adding an explicit
221 This module is included in C<modules/*>. Don't worry about it.
225 This module is documented in C<SL:InstallationCheck> to be necessary, or is a
226 dependancy of one of these. Everything alright.
230 These modules are neither core, nor included, nor required. This is ok for
231 developer tools, but should never occur for modules the actual program uses.
237 http://www.ledgersmb.org/ - The LedgerSMB team
238 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
242 Distributed under the terms of the GNU General Public License v2.