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!" => \ my $apt,
55 my %install_methods = (
56 apt => { key => 'debian', install => 'sudo apt-get install', system => "Debian, Ubuntu" },
57 yum => { key => 'fedora', install => 'sudo yum install', system => "RHEL, Fedora, CentOS" },
58 zypper => { key => 'suse', install => 'sudo zypper install', system => "SLES, openSUSE" },
59 cpan => { key => 'name', install => "sudo cpan", system => "CPAN" },
62 # if nothing is requested check "required"
64 if (!defined $check{a}
67 && !defined $check{d}) {
69 $default_run ='1'; # no parameter, therefore print a note after default run
73 foreach my $check (keys %check) {
74 $check{$check} = 1 unless defined $check{$check};
81 if (!SL::LxOfficeConf->read(undef, 'may fail')) {
82 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.')
84 SL::InstallationCheck::check_for_conditional_dependencies();
88 print_header('Checking Required Modules');
89 check_module($_, required => 1) for @SL::InstallationCheck::required_modules;
90 print_header('Standard check for required modules done. See additional parameters for more checks (--help)') if $default_run;
93 print_header('Checking Optional Modules');
94 check_module($_, optional => 1) for @SL::InstallationCheck::optional_modules;
97 print_header('Checking Developer Modules');
98 check_module($_, devel => 1) for @SL::InstallationCheck::developer_modules;
104 if (@missing_modules && $apt) {
105 print "\nHere are some sample installation lines, choose one apporpriate for your system:\n\n";
106 local $Text::Wrap::separator = " \\\n";
108 for (keys %install_methods) {
109 my $method = $install_methods{$_};
110 if (my @install_candidates = grep $_, map { $_->{$method->{key}} } @missing_modules) {
111 print "$method->{system}:\n";
112 print wrap(" ", " ", $method->{install}, @install_candidates);
119 my ($res) = check_kpsewhich();
120 print_result("Looking for LaTeX kpsewhich", $res);
122 check_template_dir($_) for SL::InstallationCheck::template_dirs($master_templates);
126 sub check_template_dir {
128 my $path = $master_templates . $dir;
130 print_header("Checking LaTeX Dependencies for Master Templates '$dir'");
131 kpsewhich($path, 'cls', $_) for SL::InstallationCheck::classes_from_latex($path, '\documentclass');
132 kpsewhich($path, 'sty', $_) for SL::InstallationCheck::classes_from_latex($path, '\usepackage');
135 our $mastertemplate_path = './templates/print/';
137 sub check_kpsewhich {
138 return 1 if SL::InstallationCheck::check_kpsewhich();
140 print STDERR <<EOL if $v;
141 +------------------------------------------------------------------------------+
142 Can't find kpsewhich, is there a proper installed LaTeX?
143 On Debian you may run "aptitude install texlive-base-bin"
144 +------------------------------------------------------------------------------+
150 my ($dw, $type, $package) = @_;
151 $package =~ s/[^-_0-9A-Za-z]//g;
152 my $type_desc = $type eq 'cls' ? 'document class' : 'package';
154 eval { use String::ShellQuote; 1 } or warn "can't load String::ShellQuote" && return;
155 $dw = shell_quote $dw;
156 my $e_package = shell_quote $package;
157 my $e_type = shell_quote $type;
159 my $exit = system(qq|TEXINPUTS=".:$dw:" kpsewhich $e_package.$e_type > /dev/null|);
160 my $res = $exit > 0 ? 0 : 1;
162 print_result("Looking for LaTeX $type_desc $package", $res);
164 print STDERR <<EOL if $v;
165 +------------------------------------------------------------------------------+
166 LaTeX $type_desc $package could not be loaded.
168 On Debian you may find the needed *.deb package with:
169 apt-file search $package.$type
171 Maybe you need to install apt-file first by:
172 aptitude install apt-file && apt-file update
173 +------------------------------------------------------------------------------+
179 my ($module, %role) = @_;
181 my $line = "Looking for $module->{fullname}";
182 $line .= " (from $module->{dist_name})" if $module->{dist_name};
183 my ($res, $ver) = SL::InstallationCheck::module_available($module->{"name"}, $module->{version});
185 my $ver_string = ref $ver && $ver->can('numify') ? $ver->numify : $ver ? $ver : 'no version';
186 print_line($line, $ver_string, 'green');
188 print_result($line, $res);
194 push @missing_modules, $module;
197 $role{optional} ? 'It is OPTIONAL for kivitendo but RECOMMENDED for improved functionality.'
198 : $role{required} ? 'It is NEEDED by kivitendo and must be installed.'
199 : $role{devel} ? 'It is OPTIONAL for kivitendo and only useful for developers.'
200 : 'It is not listed as a dependancy yet. Please tell this the developers.';
202 my @source_texts = module_source_texts($module);
204 print STDERR <<EOL if $v;
205 +------------------------------------------------------------------------------+
206 $module->{fullname} could not be loaded.
208 This module is either too old or not available on your system.
211 Here are some ideas how to get it:
214 +------------------------------------------------------------------------------+
218 sub module_source_texts {
222 - You can get it from CPAN:
223 perl -MCPAN -e "install $module->{name}"
225 push @texts, <<EOL if $module->{url};
226 - You can download it from this URL and install it manually:
229 push @texts, <<EOL if $module->{debian};
230 - On Debian, Ubuntu and other distros you can install it with apt-get:
231 sudo apt-get install $module->{debian}
232 Note: These may be out of date as well if your system is old.
234 # TODO: SuSE and Fedora packaging. Windows packaging.
240 return $_[0] unless $c;
245 my ($test, $exit) = @_;
247 print_line($test, 'ok', 'green');
249 print_line($test, 'NOT ok', 'red');
254 my ($text, $res, $color) = @_;
255 print $text, " ", ('.' x (78 - length($text) - length($res))), " ", mycolor($res, $color), $/;
271 scripts/installation_check.pl - check kivitendo dependancies
275 scripts/installation_check.pl [OPTION]
279 Check dependencys. List all perl modules needed by kivitendo, probes for them,
280 and warns if one is not available. List all LaTeX document classes and
281 packages needed by kivitendo master templates, probes for them, and warns if
282 one is not available.
291 Probe for all perl modules and all LaTeX master templates.
295 Color output. Default on.
299 No color output. Helpful to avoid terminal escape problems.
303 Probe for perl developer dependancies. (Used for console and tags file)
307 Don't probe for perl developer dependancies. (Useful in combination with --all)
313 =item C<-o, --optional>
315 Probe for optional modules.
317 =item C<--no-optional>
319 Don't probe for optional perl modules. (Useful in combination with --all)
321 =item C<-r, --required>
323 Probe for required perl modules (default).
325 =item C<--no-required>
327 Don't probe for required perl modules. (Useful in combination with --all)
331 Probe for LaTeX documentclasses and packages in master templates.
335 Don't probe for LaTeX document classes and packages in master templates. (Useful in combination with --all)
337 =item C<-v. --verbose>
339 Print additional info for missing dependancies
341 =item C<-i, --install>
343 Tries to generate installation commands for the most common package managers.
344 Note that these lists can be slightly off, but it should still save you a lot
349 =head1 BUGS, CAVEATS and TODO
355 Fedora packages not listed yet.
359 Not possible yet to generate a combined cpan/apt-get string to install all needed.
363 Not able to handle devel cpan modules yet.
367 Version requirements not fully tested yet.
373 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
374 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
375 Wulf Coulmann E<lt>wulf@coulmann.deE<gt>