10 unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
11 push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
13 # this is a default dir. may be wrong in your installation, change it then
14 $master_templates = './templates/print/';
17 unless (eval { require Config::Std; 1 }){
19 +------------------------------------------------------------------------------+
20 Perl Modul Config::Std could not be loaded.
22 Debian: you may install the needed *.deb package with:
23 apt-get install libconfig-std-perl
25 Red Hat/Fedora/CentOS: you may install the needed *.rpm package with:
26 yum install perl-Config-Std
28 SUSE: you may install the needed *.rpm package with:
29 zypper install perl-Config-Std
31 +------------------------------------------------------------------------------+
37 use SL::InstallationCheck;
42 Getopt::Long::Configure ("bundling");
44 "v|verbose" => \ my $v,
45 "a|all" => \ $check{a},
46 "o|optional!" => \ $check{o},
47 "d|devel!" => \ $check{d},
48 "l|latex!" => \ $check{l},
49 "r|required!" => \ $check{r},
50 "h|help" => sub { pod2usage(-verbose => 2) },
51 "c|color!" => \ ( my $c = 1 ),
52 "i|install-command!" => \ my $apt,
53 "s|silent" => \ $check{s},
56 my %install_methods = (
57 apt => { key => 'debian', install => 'sudo apt-get install', system => "Debian, Ubuntu" },
58 yum => { key => 'fedora', install => 'sudo yum install', system => "RHEL, Fedora, CentOS" },
59 zypper => { key => 'suse', install => 'sudo zypper install', system => "SLES, openSUSE" },
60 cpan => { key => 'name', install => "sudo cpan", system => "CPAN" },
63 # if nothing is requested check "required"
65 if (!defined $check{a}
68 && !defined $check{d}) {
70 $default_run ='1'; # no parameter, therefore print a note after default run
74 $check{$_} //= 1 for qw(o d l r);
80 if (!SL::LxOfficeConf->read(undef, 'may fail')) {
81 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 configuration.')
83 SL::InstallationCheck::check_for_conditional_dependencies();
87 print_header('Checking Required Modules');
88 check_module($_, required => 1) for @SL::InstallationCheck::required_modules;
91 print_header('Checking Optional Modules');
92 check_module($_, optional => 1) for @SL::InstallationCheck::optional_modules;
95 print_header('Checking Developer Modules');
96 check_module($_, devel => 1) for @SL::InstallationCheck::developer_modules;
102 my $fail = @missing_modules;
103 print_header('Result');
104 print_line('All', $fail ? 'NOT ok' : 'OK', $fail ? 'red' : 'green');
106 if ($default_run && !$check{s}) {
107 if (@missing_modules) {
111 HEY! It seems there are modules MISSING! Look for the red lines with "NOT ok"
112 above. You'll want to fix those, I've enabled --install-command for you...
117 Standard check done, everything is OK and up to date. Have a look at the --help
118 section of this script to see some more advanced checks for developer and
119 optional dependancies, as well as LaTeX packages you might need.
124 if (@missing_modules && $apt && !$check{s}) {
125 print "\nHere are some sample installation lines, choose one appropriate for your system:\n\n";
126 local $Text::Wrap::separator = " \\\n";
128 for (keys %install_methods) {
129 my $method = $install_methods{$_};
130 if (my @install_candidates = grep $_, map { $_->{$method->{key}} } @missing_modules) {
131 print "$method->{system}:\n";
132 print wrap(" ", " ", $method->{install}, @install_candidates);
138 exit !!@missing_modules;
141 my ($res) = check_kpsewhich();
142 print_result("Looking for LaTeX kpsewhich", $res);
144 check_template_dir($_) for SL::InstallationCheck::template_dirs($master_templates);
148 sub check_template_dir {
150 my $path = $master_templates . $dir;
152 print_header("Checking LaTeX Dependencies for Master Templates '$dir'");
153 kpsewhich($path, 'cls', $_) for SL::InstallationCheck::classes_from_latex($path, '\documentclass');
154 kpsewhich($path, 'sty', $_) for SL::InstallationCheck::classes_from_latex($path, '\usepackage');
157 our $mastertemplate_path = './templates/print/';
159 sub check_kpsewhich {
160 return 1 if SL::InstallationCheck::check_kpsewhich();
162 print STDERR <<EOL if $v && !$check{s};
163 +------------------------------------------------------------------------------+
164 Can't find kpsewhich, is there a proper installed LaTeX?
165 On Debian you may run "aptitude install texlive-base-bin"
166 +------------------------------------------------------------------------------+
172 my ($dw, $type, $package) = @_;
173 $package =~ s/[^-_0-9A-Za-z]//g;
174 my $type_desc = $type eq 'cls' ? 'document class' : 'package';
176 eval { use String::ShellQuote; 1 } or warn "can't load String::ShellQuote" && return;
177 $dw = shell_quote $dw;
178 my $e_package = shell_quote $package;
179 my $e_type = shell_quote $type;
181 my $exit = system(qq|TEXINPUTS=".:$dw:" kpsewhich $e_package.$e_type > /dev/null|);
182 my $res = $exit > 0 ? 0 : 1;
184 print_result("Looking for LaTeX $type_desc $package", $res);
186 print STDERR <<EOL if $v && !$check{s};
187 +------------------------------------------------------------------------------+
188 LaTeX $type_desc $package could not be loaded.
190 On Debian you may find the needed *.deb package with:
191 apt-file search $package.$type
193 Maybe you need to install apt-file first by:
194 aptitude install apt-file && apt-file update
195 +------------------------------------------------------------------------------+
201 my ($module, %role) = @_;
203 my $line = "Looking for $module->{fullname}";
204 $line .= " (from $module->{dist_name})" if $module->{dist_name};
205 my ($res, $ver) = SL::InstallationCheck::module_available($module->{"name"}, $module->{version});
207 my $ver_string = ref $ver && $ver->can('numify') ? $ver->numify : $ver ? $ver : 'no version';
208 print_line($line, $ver_string, 'green');
210 print_result($line, $res);
216 push @missing_modules, $module;
219 $role{optional} ? 'It is OPTIONAL for kivitendo but RECOMMENDED for improved functionality.'
220 : $role{required} ? 'It is NEEDED by kivitendo and must be installed.'
221 : $role{devel} ? 'It is OPTIONAL for kivitendo and only useful for developers.'
222 : 'It is not listed as a dependancy yet. Please tell this the developers.';
224 my @source_texts = module_source_texts($module);
226 print STDERR <<EOL if $v && !$check{s};
227 +------------------------------------------------------------------------------+
228 $module->{fullname} could not be loaded.
230 This module is either too old or not available on your system.
233 Here are some ideas how to get it:
236 +------------------------------------------------------------------------------+
240 sub module_source_texts {
243 for my $key (keys %install_methods) {
244 my $method = $install_methods{$key};
245 push @texts, <<"EOL" if $module->{$method->{key}};
246 - Using $method->{system} you can install it with $key:
247 $method->{install} $module->{$method->{key}}
250 push @texts, <<EOL if $module->{url};
251 - You can download it from this URL and install it manually:
259 return $_[0] unless $c;
264 my ($test, $exit) = @_;
266 print_line($test, 'ok', 'green');
268 print_line($test, 'NOT ok', 'red');
273 my ($text, $res, $color) = @_;
275 print $text, " ", ('.' x (78 - length($text) - length($res))), " ", mycolor($res, $color), $/;
292 scripts/installation_check.pl - check kivitendo dependancies
296 scripts/installation_check.pl [OPTION]
300 Check dependencys. List all perl modules needed by kivitendo, probes for them,
301 and warns if one is not available. List all LaTeX document classes and
302 packages needed by kivitendo master templates, probes for them, and warns if
303 one is not available.
312 Probe for all perl modules and all LaTeX master templates.
316 Color output. Default on.
320 No color output. Helpful to avoid terminal escape problems.
324 Probe for perl developer dependancies. (Used for console and tags file)
328 Don't probe for perl developer dependancies. (Useful in combination with --all)
334 =item C<-o, --optional>
336 Probe for optional modules.
338 =item C<--no-optional>
340 Don't probe for optional perl modules. (Useful in combination with --all)
342 =item C<-r, --required>
344 Probe for required perl modules (default).
346 =item C<--no-required>
348 Don't probe for required perl modules. (Useful in combination with --all)
352 Probe for LaTeX documentclasses and packages in master templates.
356 Don't probe for LaTeX document classes and packages in master templates. (Useful in combination with --all)
358 =item C<-v. --verbose>
360 Print additional info for missing dependancies
362 =item C<-i, --install-command>
364 Tries to generate installation commands for the most common package managers.
365 Note that these lists can be slightly off, but it should still save you a lot
370 =head1 BUGS, CAVEATS and TODO
376 Fedora packages not listed yet.
380 Not possible yet to generate a combined cpan/apt-get string to install all needed.
384 Not able to handle devel cpan modules yet.
388 Version requirements not fully tested yet.
394 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
395 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
396 Wulf Coulmann E<lt>wulf@coulmann.deE<gt>