From e3ff1eb6af5a2f6410be2bc28860d6237613cf3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 25 Apr 2012 14:03:54 +0200 Subject: [PATCH] Bessere Erkennung von optionalen Paketen im Installationscheck MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - IO::Socket::SSL wird jetzt als optional geführt. Wird für LDAP Verbindungen gebraucht wenn TLS benutzt werden soll. - Wenn Config::Std nicht gefunden wurde, und damit die Konfiguration nicht eingelesen werden kann, wird Net::LDAP als optional geführt und eine Warnung ausgegeben, dass evtl nicht aufgelöste Abhängigkeiten existieren. --- SL/InstallationCheck.pm | 4 +++- SL/LxOfficeConf.pm | 36 +++++++++++++++++++++++++++++------ scripts/installation_check.pl | 7 +++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/SL/InstallationCheck.pm b/SL/InstallationCheck.pm index 3100ac67f..758707d21 100644 --- a/SL/InstallationCheck.pm +++ b/SL/InstallationCheck.pm @@ -36,6 +36,8 @@ BEGIN { @optional_modules = ( { name => "Digest::SHA", url => "http://search.cpan.org/~mshelor/", debian => 'libdigest-sha-perl' }, + { name => "IO::Socket::SSL", url => "http://search.cpan.org/~sullr/", debian => 'libio-socket-ssl-perl' }, + { name => "Net::LDAP", url => "http://search.cpan.org/~gbarr/", debian => 'libnet-ldap-perl' }, ); @developer_modules = ( @@ -97,7 +99,7 @@ my %conditional_dependencies; sub check_for_conditional_dependencies { return if $conditional_dependencies{net_ldap}++; - push @required_modules, { 'name' => 'Net::LDAP', 'url' => 'http://search.cpan.org/~gbarr/' } + push @required_modules, grep { $_->{name} eq 'Net::LDAP' } @optional_modules if $::lx_office_conf{authentication} && ($::lx_office_conf{authentication}->{module} eq 'LDAP'); } diff --git a/SL/LxOfficeConf.pm b/SL/LxOfficeConf.pm index 51ad991d9..3cd462cff 100644 --- a/SL/LxOfficeConf.pm +++ b/SL/LxOfficeConf.pm @@ -2,27 +2,51 @@ package SL::LxOfficeConf; use strict; -use Config::Std; -use Encode; - my $environment_initialized; +sub safe_require { + my ($class, $may_fail); + my $failed; + $failed = !eval { + require Config::Std; + require Encode; + }; + + if ($failed) { + if ($may_fail) { + warn $@; + return 0; + } else { + die $@; + } + } + + Config::Std->import; + Encode->import; + + return 1; +} + sub read { - my ($class, $file_name) = @_; + my ($class, $file_name, $may_fail) = @_; - read_config 'config/lx_office.conf.default' => %::lx_office_conf; + return unless $class->safe_require($may_fail); + + read_config('config/lx_office.conf.default' => \%::lx_office_conf); _decode_recursively(\%::lx_office_conf); $file_name ||= 'config/lx_office.conf'; if (-f $file_name) { - read_config $file_name => my %local_conf; + read_config($file_name => \ my %local_conf); _decode_recursively(\%local_conf); _flat_merge(\%::lx_office_conf, \%local_conf); } _init_environment(); _determine_application_paths(); + + return 1; } sub _decode_recursively { diff --git a/scripts/installation_check.pl b/scripts/installation_check.pl index def85906c..a50d184d2 100755 --- a/scripts/installation_check.pl +++ b/scripts/installation_check.pl @@ -14,6 +14,7 @@ BEGIN { } use SL::InstallationCheck; +use SL::LxOfficeConf; my %check; Getopt::Long::Configure ("bundling"); @@ -47,6 +48,12 @@ if ($check{a}) { $| = 1; +if (!SL::LxOfficeConf->read(undef, 'may fail')) { + print_header('Could not load the config file. If you have dependancies from any features enabled in the configuration these will still show up as optional because of this. Please rerun this script after installing the dependancies needed to load the cofiguration.') +} else { + SL::InstallationCheck::check_for_conditional_dependencies(); +} + if ($check{r}) { print_header('Checking Required Modules'); check_module($_, required => 1) for @SL::InstallationCheck::required_modules; -- 2.20.1