c395f1de59f4ad738f7cfc01c2a4cb8b8f6a2b04
[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 => '1.16',  url => "http://search.cpan.org/~adamk/" },
14   { name => "Class::Accessor", version => '0.30',  url => "http://search.cpan.org/~kasei/" },
15   { name => "CGI::Ajax",       version => '0.697', url => "http://search.cpan.org/~bct/" },
16   { name => "DateTime",                            url => "http://search.cpan.org/~drolsky/" },
17   { name => "DBI",             version => '1.50',  url => "http://search.cpan.org/~timb/" },
18   { name => "DBD::Pg",         version => '1.49',  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 => "List::MoreUtils", version => '0.21',  url => "http://search.cpan.org/~vparseval/" },
22   { name => "PDF::API2",       version => '2.000', url => "http://search.cpan.org/~areibens/" },
23   { name => "Readonly",                            url => "http://search.cpan.org/~roode/" },
24   { name => "Rose::Object",                        url => "http://search.cpan.org/~jsiracusa/" },
25   { name => "Rose::DB",                            url => "http://search.cpan.org/~jsiracusa/" },
26   { name => "Rose::DB::Object",                    url => "http://search.cpan.org/~jsiracusa/" },
27   { name => "Template",        version => '2.18',  url => "http://search.cpan.org/~abw/" },
28   { name => "Text::CSV_XS",    version => '0.23',  url => "http://search.cpan.org/~hmbrand/" },
29   { name => "Text::Iconv",     version => '1.2',   url => "http://search.cpan.org/~mpiotr/" },
30   { name => "URI",             version => '1.35',  url => "http://search.cpan.org/~gaas/" },
31   { name => "XML::Writer",     version => '0.602', url => "http://search.cpan.org/~josephw/" },
32   { name => "YAML",            version => '0.62',  url => "http://search.cpan.org/~ingy/" },
33 );
34
35 @optional_modules = ();
36
37 $_->{fullname} = join ' ', grep $_, @$_{qw(name version)}
38   for @required_modules, @optional_modules;
39 }
40
41 sub module_available {
42   my $module  = $_[0];
43   my $version = $_[1] || '' ;
44
45   return eval "use $module $version; 1";
46 }
47
48 my %conditional_dependencies;
49
50 sub check_for_conditional_dependencies {
51   return if $conditional_dependencies{net_ldap}++;
52
53   my $self = {};
54   eval do { local (@ARGV, $/) = 'config/authentication.pl'; <> } or return;
55
56   push @required_modules, { 'name' => 'Net::LDAP', 'url' => 'http://search.cpan.org/~gbarr/' }
57     if $self->{module} && ($self->{module} eq 'LDAP');
58 }
59
60 sub test_all_modules {
61   return grep { !module_available($_->{name}) } @required_modules;
62 }
63
64 1;