Merge fix
[kivitendo-erp.git] / scripts / installation_check.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 BEGIN {
6   unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
7   push    @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
8 }
9
10 use SL::InstallationCheck;
11
12 $| = 1;
13
14 check($_, 0) for @SL::InstallationCheck::required_modules;
15 check($_, 1) for @SL::InstallationCheck::optional_modules;
16
17 sub check {
18   my ($module, $optional) = @_;
19
20   print "Looking for $module->{fullname}...";
21   my $res = SL::InstallationCheck::module_available($module->{"name"}, $module->{version});
22   print $res ? '' : " NOT", " ok\n";
23
24   return if $res;
25
26   my $needed_text = $optional
27     ? 'It is OPTIONAL for Lx-Office but recommended for improved functionality.'
28     : 'It is NEEDED by Lx-Office and must be installed.';
29
30   my @source_texts = source_texts($module);
31   local $" = $/;
32   print <<EOL;
33 +-----------------------------------------------------------------------------+
34   $module->{fullname} could not be loaded.
35
36   This module is either too old or not available on your system.
37   $needed_text
38
39   Here are some ideas how to get it:
40
41 @source_texts
42 +-----------------------------------------------------------------------------+
43 EOL
44 }
45
46 sub source_texts {
47   my ($module) = @_;
48   my @texts;
49   push @texts, <<EOL;
50   - You can get it from CPAN:
51       perl -MCPAN -e "install $module->{name}"
52 EOL
53   push @texts, <<EOL if $module->{url};
54   - You can download it from this URL and install it manually:
55       $module->{url}
56 EOL
57   push @texts, <<EOL if $module->{debian};
58   - On Debian, Ubuntu and other distros you can install it with apt-get:
59       sudo apt-get install $module->{debian}
60     Note these may be out of date as well if you system is old.
61 EOL
62  # TODO: SuSE and Fedora packaging. Windows packaging.
63
64   return @texts;
65 }