Mehrere Fehler behoben und Texte leichter lesbar gemacht.
[kivitendo-erp.git] / SL / InstallationCheck.pm
1 package SL::InstallationCheck;
2
3 use English '-no_match_vars';
4 use IO::File;
5
6 use vars qw(@required_modules @optional_modules);
7
8 use strict;
9
10 BEGIN {
11 @required_modules = (
12   { name => "parent",                              url => "http://search.cpan.org/~corion/" },
13   { name => "Archive::Zip",   version => 12,       url => "http://search.cpan.org/~adamk/" },
14   { name => "Class::Accessor",                     url => "http://search.cpan.org/~kasei/" },
15   { name => "CGI::Ajax",                           url => "http://search.cpan.org/~bct/" },
16   { name => "DateTime",                            url => "http://search.cpan.org/~drolsky/" },
17   { name => "DBI",                                 url => "http://search.cpan.org/~timb/" },
18   { name => "DBD::Pg",                             url => "http://search.cpan.org/~dbdpg/" },
19   { name => "Email::Address",                      url => "http://search.cpan.org/~rjbs/" },
20   { name => "FCGI",                                url => "http://search.cpan.org/~mstrout/" },
21   { name => "IO::Wrap",                            url => "http://search.cpan.org/~dskoll/" },
22   { name => "List::MoreUtils",                     url => "http://search.cpan.org/~vparseval/" },
23   { name => "PDF::API2",                           url => "http://search.cpan.org/~areibens/" },
24   { name => "Template",        version => '2.18',  url => "http://search.cpan.org/~abw/" },
25   { name => "Text::CSV_XS",                        url => "http://search.cpan.org/~hmbrand/" },
26   { name => "Text::Iconv",                         url => "http://search.cpan.org/~mpiotr/" },
27   { name => "URI",                                 url => "http://search.cpan.org/~gaas/" },
28   { name => "XML::Writer",                         url => "http://search.cpan.org/~josephw/" },
29   { name => "YAML",                                url => "http://search.cpan.org/~ingy/" },
30 );
31
32 @optional_modules = ();
33
34 $_->{fullname} = join ' ', grep $_, @$_{qw(name version)}
35   for @required_modules, @optional_modules;
36 }
37
38 sub module_available {
39   my $module  = $_[0];
40   my $version = $_[1] || '' ;
41
42   return eval "use $module $version; 1";
43 }
44
45 my %conditional_dependencies;
46
47 sub check_for_conditional_dependencies {
48   return if $conditional_dependencies{net_ldap}++;
49
50   my $self = {};
51   eval do { local (@ARGV, $/) = 'config/authentication.pl'; <> } or return;
52
53   push @required_modules, { 'name' => 'Net::LDAP', 'url' => 'http://search.cpan.org/~gbarr/' }
54     if $self->{module} && ($self->{module} eq 'LDAP');
55 }
56
57 sub test_all_modules {
58   return grep { !module_available($_->{name}) } @required_modules;
59 }
60
61 1;