1 package SL::InstallationCheck;
3 use English '-no_match_vars';
6 use vars qw(@required_modules @optional_modules @developer_modules);
11 # name: the name of the module if you install it with cpan
12 # version: the minimum version required to run. optional
13 # url: web path to the author page of the module
14 # debian: dpkg package name for debianoid distos
15 # note: (suse) (fedora) (redhat) entries welcome if you
16 # are willing to maintain them
17 # dist_name: name of the package in cpan if it differs from name (ex.: LWP != libwww-perl)
19 { name => "parent", url => "http://search.cpan.org/~corion/", debian => 'libparent-perl' },
20 { name => "Algorithm::CheckDigits", url => "http://search.cpan.org/~mamawe/", debian => 'libalgorithm-checkdigits-perl' },
21 { name => "Archive::Zip", version => '1.40', url => "http://search.cpan.org/~phred/", debian => 'libarchive-zip-perl' },
22 { name => "CAM::PDF", url => "https://metacpan.org/pod/CAM::PDF", debian => 'libcam-pdf-perl' },
23 { name => "CGI", version => '3.43', url => "http://search.cpan.org/~leejo/", debian => 'libcgi-pm-perl' }, # 4.09 is not core anymore (perl 5.20)
24 { name => "Clone", url => "http://search.cpan.org/~rdf/", debian => 'libclone-perl' },
25 { name => "Config::Std", url => "http://search.cpan.org/~dconway/", debian => 'libconfig-std-perl' },
26 { name => "Daemon::Generic", version => '0.71', url => "http://search.cpan.org/~muir/", debian => 'libdaemon-generic-perl'},
27 { name => "DateTime", url => "http://search.cpan.org/~drolsky/", debian => 'libdatetime-perl' },
28 { name => "DateTime::Event::Cron", version => '0.08', url => "http://search.cpan.org/~msisk/", debian => 'libdatetime-event-cron-perl' },
29 { name => "DateTime::Format::Strptime", url => "http://search.cpan.org/~drolsky/", debian => 'libdatetime-format-strptime-perl' },
30 { name => "DateTime::Set", version => '0.12', url => "http://search.cpan.org/~fglock/", debian => 'libdatetime-set-perl' },
31 { name => "DBI", version => '1.50', url => "http://search.cpan.org/~timb/", debian => 'libdbi-perl' },
32 { name => "DBD::Pg", version => '1.49', url => "http://search.cpan.org/~dbdpg/", debian => 'libdbd-pg-perl' },
33 { name => "Digest::SHA", url => "http://search.cpan.org/~mshelor/", debian => 'libdigest-sha-perl' },
34 { name => "Exception::Class", version => '1.44', url => "https://metacpan.org/pod/Exception::Class", debian => 'libexception-class-perl' },
35 { name => "Email::Address", version => '1.888', url => "http://search.cpan.org/~rjbs/", debian => 'libemail-address-perl' },
36 { name => "Email::MIME", url => "http://search.cpan.org/~rjbs/", debian => 'libemail-mime-perl' },
37 { name => "FCGI", version => '0.72', url => "http://search.cpan.org/~mstrout/", debian => 'libfcgi-perl' },
38 { name => "File::Copy::Recursive", url => "http://search.cpan.org/~dmuey/", debian => 'libfile-copy-recursive-perl' },
39 { name => "File::Flock", version => '2008.01', url => "http://search.cpan.org/~muir/", debian => 'libfile-flock-perl' },
40 { name => "File::MimeInfo", url => "http://search.cpan.org/~michielb/", debian => 'libfile-mimeinfo-perl' },
41 { name => "File::Slurp", url => "https://metacpan.org/author/CAPOEIRAB", debian => 'libfile-slurp-perl' },
42 { name => "GD", url => "http://search.cpan.org/~lds/", debian => 'libgd-gd2-perl', },
43 { name => 'HTML::Parser', url => 'http://search.cpan.org/~gaas/', debian => 'libhtml-parser-perl', },
44 { name => 'HTML::Restrict', url => 'http://search.cpan.org/~oalders/', debian => 'libhtml-restrict-perl'},
45 { name => "Image::Info", url => "http://search.cpan.org/~srezic/", debian => 'libimage-info-perl' },
46 { name => "JSON", url => "http://search.cpan.org/~makamaka", debian => 'libjson-perl' },
47 { name => "List::MoreUtils", version => '0.30', url => "http://search.cpan.org/~vparseval/", debian => 'liblist-moreutils-perl' },
48 { name => "List::UtilsBy", version => '0.09', url => "http://search.cpan.org/~pevans/", debian => 'liblist-utilsby-perl' },
49 { name => "LWP::Authen::Digest", url => "http://search.cpan.org/~gaas/", debian => 'libwww-perl', dist_name => 'libwww-perl' },
50 { name => "LWP::UserAgent", url => "http://search.cpan.org/~gaas/", debian => 'libwww-perl', dist_name => 'libwww-perl' },
51 { name => "Params::Validate", url => "http://search.cpan.org/~drolsky/", debian => 'libparams-validate-perl' },
52 { name => "PBKDF2::Tiny", version => '0.005', url => "http://search.cpan.org/~dagolden/", debian => 'libpbkdf2-tiny-perl' },
53 { name => "PDF::API2", version => '2.000', url => "http://search.cpan.org/~areibens/", debian => 'libpdf-api2-perl' },
54 { name => "Regexp::IPv6", version => '0.03', url => "http://search.cpan.org/~salva/", debian => 'libregexp-ipv6-perl' },
55 { name => "Rose::Object", url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-object-perl' },
56 { name => "Rose::DB", url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-db-perl' },
57 { name => "Rose::DB::Object", version => 0.788, url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-db-object-perl' },
58 { name => "Set::Infinite", version => '0.63', url => "http://search.cpan.org/~fglock/", debian => 'libset-infinite-perl' },
59 { name => "String::ShellQuote", version => 1.01, url => "http://search.cpan.org/~rosch/", debian => 'libstring-shellquote-perl' },
60 { name => "Sort::Naturally", url => "http://search.cpan.org/~sburke/", debian => 'libsort-naturally-perl' },
61 { name => "Template", version => '2.18', url => "http://search.cpan.org/~abw/", debian => 'libtemplate-perl' },
62 { name => "Text::CSV_XS", version => '0.23', url => "http://search.cpan.org/~hmbrand/", debian => 'libtext-csv-xs-perl' },
63 { name => "Text::Iconv", version => '1.2', url => "http://search.cpan.org/~mpiotr/", debian => 'libtext-iconv-perl' },
64 { name => "Text::Unidecode", url => "http://search.cpan.org/~sburke/", debian => 'libtext-unidecode-perl' },
65 { name => "URI", version => '1.35', url => "http://search.cpan.org/~gaas/", debian => 'liburi-perl' },
66 { name => "XML::LibXML", url => "https://metacpan.org/pod/XML::LibXML", debian => 'libxml-libxml-perl' },
67 { name => "XML::Writer", version => '0.602', url => "http://search.cpan.org/~josephw/", debian => 'libxml-writer-perl' },
68 { name => "YAML", version => '0.62', url => "http://search.cpan.org/~ingy/", debian => 'libyaml-perl' },
72 { name => "IO::Socket::SSL", url => "http://search.cpan.org/~sullr/", debian => 'libio-socket-ssl-perl' },
73 { name => "Net::LDAP", url => "http://search.cpan.org/~gbarr/", debian => 'libnet-ldap-perl' },
74 # Net::SMTP is core since 5.7.3
75 { name => "Net::SMTP::SSL", url => "http://search.cpan.org/~cwest/", debian => 'libnet-smtp-ssl-perl' },
76 { name => "Net::SSLGlue", url => "http://search.cpan.org/~sullr/", debian => 'libnet-sslglue-perl' },
77 { name => "YAML::XS", url => "https://metacpan.org/pod/distribution/YAML-LibYAML/lib/YAML/LibYAML.pod", debian => 'libyaml-libyaml-perl' },
80 @developer_modules = (
81 { name => "DBIx::Log4perl", url => "http://search.cpan.org/~mjevans/", },
82 { name => "Devel::REPL", url => "http://search.cpan.org/~doy/", debian => 'libdevel-repl-perl' },
83 { name => "Log::Log4perl", url => "http://search.cpan.org/~mschilli/", debian => 'liblog-log4perl-perl' },
84 { name => "LWP::Simple", url => "http://search.cpan.org/~gaas/", debian => 'libwww-perl', dist_name => 'libwww-perl' },
85 { name => "Moose::Role", url => "http://search.cpan.org/~doy/", debian => 'libmoose-perl' },
86 { name => "Sys::CPU", url => "http://search.cpan.org/~mkoderer/", debian => 'libsys-cpu-perl' },
87 { name => "Test::Deep", url => "http://search.cpan.org/~rjbs/", debian => 'libtest-deep-perl' },
88 { name => "Test::Exception", url => "http://search.cpan.org/~adie/", debian => 'libtest-exception-perl' },
89 { name => "Test::Output", url => "http://search.cpan.org/~bdfoy/", debian => 'libtest-output-perl' },
90 { name => "Thread::Pool::Simple", url => "http://search.cpan.org/~jwu/", debian => 'libthread-pool-simple-perl' },
91 { name => "URI::Find", url => "http://search.cpan.org/~mschwern/", debian => 'liburi-find-perl' },
92 { name => "GD", version => '2.00', url => "http://search.cpan.org/~lds/", debian => 'libgd-perl' },
93 { name => "Rose::DB::Object", version => 0.809, url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-db-object-perl' },
96 $_->{fullname} = join ' ', grep $_, @$_{qw(name version)}
97 for @required_modules, @optional_modules, @developer_modules;
101 sub module_available {
103 my $version = $_[1] || '' ;
105 my $got = eval "use $module $version (); 1";
108 return ($got, $module->VERSION);
114 sub check_kpsewhich {
115 my $exit = system("which kpsewhich > /dev/null");
117 return $exit > 0 ? 0 : 1;
122 opendir my $dh, $path || die "can't open $path";
123 my @templates = sort grep { !/^\.\.?$/ } readdir $dh;
129 sub classes_from_latex {
130 my ($path, $class) = @_;
131 eval { require String::ShellQuote; 1 } or warn "can't load String::ShellQuote" && return;
132 $path = String::ShellQuote::shell_quote $path;
133 $class = String::ShellQuote::shell_quote $class;
135 open my $pipe, q#egrep -rs '^[\ \t]*# . "$class' $path". q# | sed 's/ //g' | awk -F '{' '{print $2}' | awk -F '}' '{print $1}' |#;
139 # can't use uniq here
140 my %class_hash = map { $_ => 1 } map { s/\n//; $_ } split ',', join ',', @cls;
141 return sort keys %class_hash;
144 my %conditional_dependencies;
146 sub check_for_conditional_dependencies {
147 return if $conditional_dependencies{net_ldap}++;
149 push @required_modules, grep { $_->{name} eq 'Net::LDAP' } @optional_modules
150 if $::lx_office_conf{authentication} && ($::lx_office_conf{authentication}->{module} eq 'LDAP');
153 sub test_all_modules {
154 return grep { !module_available($_->{name}) } @required_modules;