9 unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
10 push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
12 # this is a default dir. may be wrong in your installation, change it then
13 $master_templates = './templates/print/';
16 unless (eval { require Config::Std; 1 }){
18 +------------------------------------------------------------------------------+
19 Perl Modul Config::Std could not be loaded.
21 Debian: you may install the needed *.deb package with:
22 apt-get install libconfig-std-perl
24 RPM: There is a rpm package "perl-Config-Std"
26 Suse: you may install the needed *.rpm package with:
27 zypper install perl-Config-Std
29 +------------------------------------------------------------------------------+
35 use SL::InstallationCheck;
40 Getopt::Long::Configure ("bundling");
42 "v|verbose" => \ my $v,
43 "a|all" => \ $check{a},
44 "o|optional!" => \ $check{o},
45 "d|devel!" => \ $check{d},
46 "l|latex!" => \ $check{l},
47 "r|required!" => \ $check{r},
48 "h|help" => sub { pod2usage(-verbose => 2) },
49 "c|color!" => \ ( my $c = 1 ),
52 # if nothing is requested check "required"
54 if (!defined $check{a}
57 && !defined $check{d}) {
59 $default_run ='1'; # no parameter, therefore print a note after default run
63 foreach my $check (keys %check) {
64 $check{$check} = 1 unless defined $check{$check};
71 if (!SL::LxOfficeConf->read(undef, 'may fail')) {
72 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.')
74 SL::InstallationCheck::check_for_conditional_dependencies();
78 print_header('Checking Required Modules');
79 check_module($_, required => 1) for @SL::InstallationCheck::required_modules;
80 print_header('Standard check for required modules done. See additional parameters for more checks (--help)') if $default_run;
83 print_header('Checking Optional Modules');
84 check_module($_, optional => 1) for @SL::InstallationCheck::optional_modules;
87 print_header('Checking Developer Modules');
88 check_module($_, devel => 1) for @SL::InstallationCheck::developer_modules;
95 my ($res) = check_kpsewhich();
96 print_result("Looking for LaTeX kpsewhich", $res);
98 check_template_dir($_) for SL::InstallationCheck::template_dirs($master_templates);
102 sub check_template_dir {
104 my $path = $master_templates . $dir;
106 print_header("Checking LaTeX Dependencies for Master Templates '$dir'");
107 kpsewhich($path, 'cls', $_) for SL::InstallationCheck::classes_from_latex($path, '\documentclass');
108 kpsewhich($path, 'sty', $_) for SL::InstallationCheck::classes_from_latex($path, '\usepackage');
111 our $mastertemplate_path = './templates/print/';
113 sub check_kpsewhich {
114 return 1 if SL::InstallationCheck::check_kpsewhich();
116 print STDERR <<EOL if $v;
117 +------------------------------------------------------------------------------+
118 Can't find kpsewhich, is there a proper installed LaTeX?
119 On Debian you may run "aptitude install texlive-base-bin"
120 +------------------------------------------------------------------------------+
126 my ($dw, $type, $package) = @_;
127 $package =~ s/[^-_0-9A-Za-z]//g;
128 my $type_desc = $type eq 'cls' ? 'document class' : 'package';
130 eval { use String::ShellQuote; 1 } or warn "can't load String::ShellQuote" && return;
131 $dw = shell_quote $dw;
132 my $e_package = shell_quote $package;
133 my $e_type = shell_quote $type;
135 my $exit = system(qq|TEXINPUTS=".:$dw:" kpsewhich $e_package.$e_type > /dev/null|);
136 my $res = $exit > 0 ? 0 : 1;
138 print_result("Looking for LaTeX $type_desc $package", $res);
140 print STDERR <<EOL if $v;
141 +------------------------------------------------------------------------------+
142 LaTeX $type_desc $package could not be loaded.
144 On Debian you may find the needed *.deb package with:
145 apt-file search $package.$type
147 Maybe you need to install apt-file first by:
148 aptitude install apt-file && apt-file update
149 +------------------------------------------------------------------------------+
155 my ($module, %role) = @_;
157 my $line = "Looking for $module->{fullname}";
158 $line .= " (from $module->{dist_name})" if $module->{dist_name};
159 my ($res, $ver) = SL::InstallationCheck::module_available($module->{"name"}, $module->{version});
161 my $ver_string = ref $ver && $ver->can('numify') ? $ver->numify : $ver ? $ver : 'no version';
162 print_line($line, $ver_string, 'green');
164 print_result($line, $res);
171 $role{optional} ? 'It is OPTIONAL for kivitendo but RECOMMENDED for improved functionality.'
172 : $role{required} ? 'It is NEEDED by kivitendo and must be installed.'
173 : $role{devel} ? 'It is OPTIONAL for kivitendo and only useful for developers.'
174 : 'It is not listed as a dependancy yet. Please tell this the developers.';
176 my @source_texts = module_source_texts($module);
178 print STDERR <<EOL if $v;
179 +------------------------------------------------------------------------------+
180 $module->{fullname} could not be loaded.
182 This module is either too old or not available on your system.
185 Here are some ideas how to get it:
188 +------------------------------------------------------------------------------+
192 sub module_source_texts {
196 - You can get it from CPAN:
197 perl -MCPAN -e "install $module->{name}"
199 push @texts, <<EOL if $module->{url};
200 - You can download it from this URL and install it manually:
203 push @texts, <<EOL if $module->{debian};
204 - On Debian, Ubuntu and other distros you can install it with apt-get:
205 sudo apt-get install $module->{debian}
206 Note: These may be out of date as well if your system is old.
208 # TODO: SuSE and Fedora packaging. Windows packaging.
214 return $_[0] unless $c;
219 my ($test, $exit) = @_;
221 print_line($test, 'ok', 'green');
223 print_line($test, 'NOT ok', 'red');
228 my ($text, $res, $color) = @_;
229 print $text, " ", ('.' x (78 - length($text) - length($res))), " ", mycolor($res, $color), $/;
245 scripts/installation_check.pl - check kivitendo dependancies
249 scripts/installation_check.pl [OPTION]
253 Check dependencys. List all perl modules needed by kivitendo, probes for them,
254 and warns if one is not available. List all LaTeX document classes and
255 packages needed by kivitendo master templates, probes for them, and warns if
256 one is not available.
265 Probe for all perl modules and all LaTeX master templates.
269 Color output. Default on.
273 No color output. Helpful to avoid terminal escape problems.
277 Probe for perl developer dependancies. (Used for console and tags file)
281 Don't probe for perl developer dependancies. (Useful in combination with --all)
287 =item C<-o, --optional>
289 Probe for optional modules.
291 =item C<--no-optional>
293 Don't probe for optional perl modules. (Useful in combination with --all)
295 =item C<-r, --required>
297 Probe for required perl modules (default).
299 =item C<--no-required>
301 Don't probe for required perl modules. (Useful in combination with --all)
305 Probe for LaTeX documentclasses and packages in master templates.
309 Don't probe for LaTeX document classes and packages in master templates. (Useful in combination with --all)
311 =item C<-v. --verbose>
313 Print additional info for missing dependancies
317 =head1 BUGS, CAVEATS and TODO
323 Fedora packages not listed yet.
327 Not possible yet to generate a combined cpan/apt-get string to install all needed.
331 Not able to handle devel cpan modules yet.
335 Version requirements not fully tested yet.
341 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
342 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
343 Wulf Coulmann E<lt>wulf@coulmann.deE<gt>