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 use SL::InstallationCheck;
 
  19 Getopt::Long::Configure ("bundling");
 
  21   "v|verbose"   => \ my $v,
 
  22   "a|all"       => \ $check{a},
 
  23   "o|optional!" => \ $check{o},
 
  24   "d|devel!"    => \ $check{d},
 
  25   "l|latex!"    => \ $check{l},
 
  26   "r|required!" => \ $check{r},
 
  27   "h|help"      => sub { pod2usage(-verbose => 2) },
 
  28   "c|color!"    => \ ( my $c = 1 ),
 
  31 # if nothing is requested check "required"
 
  33 if (!defined $check{a}
 
  36  && !defined $check{d}) {
 
  38   $default_run ='1';  # no parameter, therefore print a note after default run
 
  42   foreach my $check (keys %check) {
 
  43     $check{$check} = 1 unless defined $check{$check};
 
  51   print_header('Checking Required Modules');
 
  52   check_module($_, required => 1) for @SL::InstallationCheck::required_modules;
 
  53   print_header('Standard check for required modules done. See additional parameters for more checks (-- help)') if $default_run;
 
  56   print_header('Checking Optional Modules');
 
  57   check_module($_, optional => 1) for @SL::InstallationCheck::optional_modules;
 
  60   print_header('Checking Developer Modules');
 
  61   check_module($_, devel => 1) for @SL::InstallationCheck::developer_modules;
 
  68   my ($res) = check_kpsewhich();
 
  69   print_result("Looking for LaTeX kpsewhich", $res);
 
  71     check_template_dir($_) for SL::InstallationCheck::template_dirs($master_templates);
 
  75 sub check_template_dir {
 
  77   my $path  = $master_templates . $dir;
 
  79   print_header("Checking LaTeX Dependencies for Master Templates '$dir'");
 
  80   kpsewhich($path, 'cls', $_) for SL::InstallationCheck::classes_from_latex($path, '\documentclass');
 
  81   kpsewhich($path, 'sty', $_) for SL::InstallationCheck::classes_from_latex($path, '\usepackage');
 
  84 our $mastertemplate_path = './templates/print/';
 
  87   return 1 if SL::InstallationCheck::check_kpsewhich();
 
  89   print STDERR <<EOL if $v;
 
  90 +------------------------------------------------------------------------------+
 
  91   Can't find kpsewhich, is there a proper installed LaTeX?
 
  92   On Debian you may run "aptitude install texlive-base-bin"
 
  93 +------------------------------------------------------------------------------+
 
  99   my ($dw, $type, $package) = @_;
 
 100   $package =~ s/[^-_0-9A-Za-z]//g;
 
 101   my $type_desc = $type eq 'cls' ? 'document class' : 'package';
 
 103   eval { use String::ShellQuote; 1 } or warn "can't load String::ShellQuote" && return;
 
 104      $dw         = shell_quote $dw;
 
 105   my $e_package  = shell_quote $package;
 
 106   my $e_type     = shell_quote $type;
 
 108   my $exit = system(qq|TEXINPUTS=".:$dw:" kpsewhich $e_package.$e_type > /dev/null|);
 
 109   my $res  = $exit > 0 ? 0 : 1;
 
 111   print_result("Looking for LaTeX $type_desc $package", $res);
 
 113     print STDERR <<EOL if $v;
 
 114 +------------------------------------------------------------------------------+
 
 115   LaTeX $type_desc $package could not be loaded.
 
 117   On Debian you may find the needed *.deb package with:
 
 118     apt-file search $package.$type
 
 120   Maybe you need to install apt-file first by:
 
 121     aptitude install apt-file && apt-file update
 
 122 +------------------------------------------------------------------------------+
 
 128   my ($module, %role) = @_;
 
 130   my $line = "Looking for $module->{fullname}";
 
 131   my ($res, $ver) = SL::InstallationCheck::module_available($module->{"name"}, $module->{version});
 
 133     my $ver_string = ref $ver && $ver->can('numify') ? $ver->numify : $ver ? $ver : 'no version';
 
 134     print_line($line, $ver_string, 'green');
 
 136     print_result($line, $res);
 
 143       $role{optional} ? 'It is OPTIONAL for Lx-Office but RECOMMENDED for improved functionality.'
 
 144     : $role{required} ? 'It is NEEDED by Lx-Office and must be installed.'
 
 145     : $role{devel}    ? 'It is OPTIONAL for Lx-Office and only useful for developers.'
 
 146     :                   'It is not listed as a dependancy yet. Please tell this the developers.';
 
 148   my @source_texts = module_source_texts($module);
 
 150   print STDERR <<EOL if $v;
 
 151 +------------------------------------------------------------------------------+
 
 152   $module->{fullname} could not be loaded.
 
 154   This module is either too old or not available on your system.
 
 157   Here are some ideas how to get it:
 
 160 +------------------------------------------------------------------------------+
 
 164 sub module_source_texts {
 
 168   - You can get it from CPAN:
 
 169       perl -MCPAN -e "install $module->{name}"
 
 171   push @texts, <<EOL if $module->{url};
 
 172   - You can download it from this URL and install it manually:
 
 175   push @texts, <<EOL if $module->{debian};
 
 176   - On Debian, Ubuntu and other distros you can install it with apt-get:
 
 177       sudo apt-get install $module->{debian}
 
 178     Note: These may be out of date as well if your system is old.
 
 180  # TODO: SuSE and Fedora packaging. Windows packaging.
 
 186   return $_[0] unless $c;
 
 191   my ($test, $exit) = @_;
 
 193     print_line($test, 'ok', 'green');
 
 195     print_line($test, 'NOT ok', 'red');
 
 200   my ($text, $res, $color) = @_;
 
 201   print $text, " ", ('.' x (78 - length($text) - length($res))), " ", mycolor($res, $color), $/;
 
 217 scripts/installation_check.pl - check Lx-Office dependancies
 
 221   scripts/installation_check.pl [OPTION]
 
 225 Check dependencys. List all perl modules needed by Lx-Office, probes for them,
 
 226 and warns if one is not available.  List all LaTeX document classes and
 
 227 packages needed by Lx-Office master templates, probes for them, and warns if
 
 228 one is not available.
 
 237 Probe for all perl modules and all LaTeX master templates.
 
 241 Color output. Default on.
 
 245 No color output. Helpful to avoid terminal escape problems.
 
 249 Probe for perl developer dependancies. (Used for console  and tags file)
 
 253 Don't probe for perl developer dependancies. (Useful in combination with --all)
 
 259 =item C<-o, --optional>
 
 261 Probe for optional modules.
 
 263 =item C<--no-optional>
 
 265 Don't probe for optional perl modules. (Useful in combination with --all)
 
 267 =item C<-r, --required>
 
 269 Probe for required perl modules (default).
 
 271 =item C<--no-required>
 
 273 Don't probe for required perl modules. (Useful in combination with --all)
 
 277 Probe for LaTeX documentclasses and packages in master templates.
 
 281 Don't probe for LaTeX document classes and packages in master templates. (Useful in combination with --all)
 
 283 =item C<-v. --verbose>
 
 285 Print additional info for missing dependancies
 
 289 =head1 BUGS, CAVEATS and TODO
 
 295 Fedora packages not listed yet.
 
 299 Not possible yet to generate a combined cpan/apt-get string to install all needed.
 
 303 Not able to handle devel cpan modules yet.
 
 307 Version requirements not fully tested yet.
 
 313   Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
 
 314   Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
 
 315   Wulf Coulmann E<lt>wulf@coulmann.deE<gt>