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   my ($res, $ver) = SL::InstallationCheck::module_available($module->{"name"}, $module->{version});
 
 160     my $ver_string = ref $ver && $ver->can('numify') ? $ver->numify : $ver ? $ver : 'no version';
 
 161     print_line($line, $ver_string, 'green');
 
 163     print_result($line, $res);
 
 170       $role{optional} ? 'It is OPTIONAL for Lx-Office but RECOMMENDED for improved functionality.'
 
 171     : $role{required} ? 'It is NEEDED by Lx-Office and must be installed.'
 
 172     : $role{devel}    ? 'It is OPTIONAL for Lx-Office and only useful for developers.'
 
 173     :                   'It is not listed as a dependancy yet. Please tell this the developers.';
 
 175   my @source_texts = module_source_texts($module);
 
 177   print STDERR <<EOL if $v;
 
 178 +------------------------------------------------------------------------------+
 
 179   $module->{fullname} could not be loaded.
 
 181   This module is either too old or not available on your system.
 
 184   Here are some ideas how to get it:
 
 187 +------------------------------------------------------------------------------+
 
 191 sub module_source_texts {
 
 195   - You can get it from CPAN:
 
 196       perl -MCPAN -e "install $module->{name}"
 
 198   push @texts, <<EOL if $module->{url};
 
 199   - You can download it from this URL and install it manually:
 
 202   push @texts, <<EOL if $module->{debian};
 
 203   - On Debian, Ubuntu and other distros you can install it with apt-get:
 
 204       sudo apt-get install $module->{debian}
 
 205     Note: These may be out of date as well if your system is old.
 
 207  # TODO: SuSE and Fedora packaging. Windows packaging.
 
 213   return $_[0] unless $c;
 
 218   my ($test, $exit) = @_;
 
 220     print_line($test, 'ok', 'green');
 
 222     print_line($test, 'NOT ok', 'red');
 
 227   my ($text, $res, $color) = @_;
 
 228   print $text, " ", ('.' x (78 - length($text) - length($res))), " ", mycolor($res, $color), $/;
 
 244 scripts/installation_check.pl - check Lx-Office dependancies
 
 248   scripts/installation_check.pl [OPTION]
 
 252 Check dependencys. List all perl modules needed by Lx-Office, probes for them,
 
 253 and warns if one is not available.  List all LaTeX document classes and
 
 254 packages needed by Lx-Office master templates, probes for them, and warns if
 
 255 one is not available.
 
 264 Probe for all perl modules and all LaTeX master templates.
 
 268 Color output. Default on.
 
 272 No color output. Helpful to avoid terminal escape problems.
 
 276 Probe for perl developer dependancies. (Used for console  and tags file)
 
 280 Don't probe for perl developer dependancies. (Useful in combination with --all)
 
 286 =item C<-o, --optional>
 
 288 Probe for optional modules.
 
 290 =item C<--no-optional>
 
 292 Don't probe for optional perl modules. (Useful in combination with --all)
 
 294 =item C<-r, --required>
 
 296 Probe for required perl modules (default).
 
 298 =item C<--no-required>
 
 300 Don't probe for required perl modules. (Useful in combination with --all)
 
 304 Probe for LaTeX documentclasses and packages in master templates.
 
 308 Don't probe for LaTeX document classes and packages in master templates. (Useful in combination with --all)
 
 310 =item C<-v. --verbose>
 
 312 Print additional info for missing dependancies
 
 316 =head1 BUGS, CAVEATS and TODO
 
 322 Fedora packages not listed yet.
 
 326 Not possible yet to generate a combined cpan/apt-get string to install all needed.
 
 330 Not able to handle devel cpan modules yet.
 
 334 Version requirements not fully tested yet.
 
 340   Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
 
 341   Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>
 
 342   Wulf Coulmann E<lt>wulf@coulmann.deE<gt>