Debitoren-/Kreditoren-/Dialogbuchungen: Fremdschlüsselspalte "department_id" nicht...
[kivitendo-erp.git] / scripts / installation_check.pl
index 1cebcb2..9637f55 100755 (executable)
@@ -13,7 +13,28 @@ BEGIN {
   $master_templates = './templates/print/';
 }
 
+unless (eval { require Config::Std; 1 }){
+  print STDERR <<EOL ;
++------------------------------------------------------------------------------+
+  Perl Modul Config::Std could not be loaded.
+
+  Debian: you may install the needed *.deb package with:
+    apt-get install libconfig-std-perl
+
+  RPM: There is a rpm package "perl-Config-Std"
+
+  Suse: you may install the needed *.rpm package with:
+    zypper install perl-Config-Std
+
++------------------------------------------------------------------------------+
+EOL
+
+  exit 72;
+}
+
 use SL::InstallationCheck;
+use SL::LxOfficeConf;
+
 
 my %check;
 Getopt::Long::Configure ("bundling");
@@ -29,11 +50,15 @@ GetOptions(
 );
 
 # if nothing is requested check "required"
-$check{r} = 1 unless defined $check{a} ||
-                     defined $check{l} ||
-                     defined $check{o} ||
-                     defined $check{d};
-my $default_run ='1' if $check{r};  # no parameter, therefore print a note after default run
+my $default_run;
+if (!defined $check{a}
+ && !defined $check{l}
+ && !defined $check{o}
+ && !defined $check{d}) {
+  $check{r} = 1;
+  $default_run ='1';  # no parameter, therefore print a note after default run
+}
+
 if ($check{a}) {
   foreach my $check (keys %check) {
     $check{$check} = 1 unless defined $check{$check};
@@ -43,10 +68,16 @@ 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;
-  print_header('Standard check for required modules done. See additional parameters for more checks (-- help)') if $default_run;
+  print_header('Standard check for required modules done. See additional parameters for more checks (--help)') if $default_run;
 }
 if ($check{o}) {
   print_header('Checking Optional Modules');
@@ -62,7 +93,7 @@ if ($check{l}) {
 
 sub check_latex {
   my ($res) = check_kpsewhich();
-  print_result("Looking for LaTeX kpsewhich", $res ? ('ok', 'green') : ('NOT ok', 'red'));
+  print_result("Looking for LaTeX kpsewhich", $res);
   if ($res) {
     check_template_dir($_) for SL::InstallationCheck::template_dirs($master_templates);
   }
@@ -126,7 +157,8 @@ sub check_module {
   my $line = "Looking for $module->{fullname}";
   my ($res, $ver) = SL::InstallationCheck::module_available($module->{"name"}, $module->{version});
   if ($res) {
-    print_line($line, $ver || 'no version', 'green');
+    my $ver_string = ref $ver && $ver->can('numify') ? $ver->numify : $ver ? $ver : 'no version';
+    print_line($line, $ver_string, 'green');
   } else {
     print_result($line, $res);
   }
@@ -135,9 +167,9 @@ sub check_module {
   return if $res;
 
   my $needed_text =
-      $role{optional} ? 'It is OPTIONAL for Lx-Office but RECOMMENDED for improved functionality.'
-    : $role{required} ? 'It is NEEDED by Lx-Office and must be installed.'
-    : $role{devel}    ? 'It is OPTIONAL for Lx-Office and only useful for developers.'
+      $role{optional} ? 'It is OPTIONAL for kivitendo but RECOMMENDED for improved functionality.'
+    : $role{required} ? 'It is NEEDED by kivitendo and must be installed.'
+    : $role{devel}    ? 'It is OPTIONAL for kivitendo and only useful for developers.'
     :                   'It is not listed as a dependancy yet. Please tell this the developers.';
 
   my @source_texts = module_source_texts($module);
@@ -193,10 +225,7 @@ sub print_result {
 
 sub print_line {
   my ($text, $res, $color) = @_;
-  print $text, " ", ('.' x (78 - length($text) - length($res)));
-  print mycolor($res, $color);
-  print "\n";
-  return;
+  print $text, " ", ('.' x (78 - length($text) - length($res))), " ", mycolor($res, $color), $/;
 }
 
 sub print_header {
@@ -212,7 +241,7 @@ __END__
 
 =head1 NAME
 
-scripts/installation_check.pl - check Lx-Office dependancies
+scripts/installation_check.pl - check kivitendo dependancies
 
 =head1 SYNOPSIS
 
@@ -220,9 +249,9 @@ scripts/installation_check.pl - check Lx-Office dependancies
 
 =head1 DESCRIPTION
 
-Check dependencys. List all perl modules needed by Lx-Office, probes for them,
+Check dependencys. List all perl modules needed by kivitendo, probes for them,
 and warns if one is not available.  List all LaTeX document classes and
-packages needed by Lx-Office master templates, probes for them, and warns if
+packages needed by kivitendo master templates, probes for them, and warns if
 one is not available.