]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Bessere Erkennung von optionalen Paketen im Installationscheck
authorSven Schöling <s.schoeling@linet-services.de>
Wed, 25 Apr 2012 12:03:54 +0000 (14:03 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 25 Apr 2012 12:03:54 +0000 (14:03 +0200)
- 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
SL/LxOfficeConf.pm
scripts/installation_check.pl

index 3100ac67f0f5d4061ab65d4bdaebbb61ccc64381..758707d214fcf4bc7b7f8a21dfd29773e5205c71 100644 (file)
@@ -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');
 }
 
index 51ad991d916cfad4ed80d65233bef4320355c01a..3cd462cff1a743e4ec3c3bd4cc06f068f31bbf30 100644 (file)
@@ -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 {
index def85906c9f3b88bc9ec34a88e1aecbb1063fe51..a50d184d2863e06a91d2e05c5e34dae7b92fb1a0 100755 (executable)
@@ -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;