+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;
+}
+if ($check{o}) {
+ print_header('Checking Optional Modules');
+ check_module($_, optional => 1) for @SL::InstallationCheck::optional_modules;
+}
+if ($check{d}) {
+ print_header('Checking Developer Modules');
+ check_module($_, devel => 1) for @SL::InstallationCheck::developer_modules;
+}
+if ($check{l}) {
+ check_latex();
+}
+
+sub check_latex {
+ my ($res) = check_kpsewhich();
+ print_result("Looking for LaTeX kpsewhich", $res);
+ if ($res) {
+ check_template_dir($_) for SL::InstallationCheck::template_dirs($master_templates);
+ }
+}
+
+sub check_template_dir {
+ my ($dir) = @_;
+ my $path = $master_templates . $dir;
+
+ print_header("Checking LaTeX Dependencies for Master Templates '$dir'");
+ kpsewhich($path, 'cls', $_) for SL::InstallationCheck::classes_from_latex($path, '\documentclass');
+ kpsewhich($path, 'sty', $_) for SL::InstallationCheck::classes_from_latex($path, '\usepackage');
+}
+
+our $mastertemplate_path = './templates/print/';
+
+sub check_kpsewhich {
+ return 1 if SL::InstallationCheck::check_kpsewhich();
+
+ print STDERR <<EOL if $v;
++------------------------------------------------------------------------------+
+ Can't find kpsewhich, is there a proper installed LaTeX?
+ On Debian you may run "aptitude install texlive-base-bin"
++------------------------------------------------------------------------------+
+EOL
+ return 0;
+}
+
+sub kpsewhich {
+ my ($dw, $type, $package) = @_;
+ $package =~ s/[^-_0-9A-Za-z]//g;
+ my $type_desc = $type eq 'cls' ? 'document class' : 'package';
+
+ eval { use String::ShellQuote; 1 } or warn "can't load String::ShellQuote" && return;
+ $dw = shell_quote $dw;
+ my $e_package = shell_quote $package;
+ my $e_type = shell_quote $type;
+
+ my $exit = system(qq|TEXINPUTS=".:$dw:" kpsewhich $e_package.$e_type > /dev/null|);
+ my $res = $exit > 0 ? 0 : 1;
+
+ print_result("Looking for LaTeX $type_desc $package", $res);
+ if (!$res) {
+ print STDERR <<EOL if $v;
++------------------------------------------------------------------------------+
+ LaTeX $type_desc $package could not be loaded.
+
+ On Debian you may find the needed *.deb package with:
+ apt-file search $package.$type
+
+ Maybe you need to install apt-file first by:
+ aptitude install apt-file && apt-file update
++------------------------------------------------------------------------------+
+EOL
+ }
+}
+
+sub check_module {
+ my ($module, %role) = @_;
+
+ my $line = "Looking for $module->{fullname}";
+ my ($res, $ver) = SL::InstallationCheck::module_available($module->{"name"}, $module->{version});
+ if ($res) {
+ my $ver_string = ref $ver && $ver->can('numify') ? $ver->numify : $ver ? $ver : 'no version';
+ print_line($line, $ver_string, 'green');