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 => "Archive::Zip", version => '1.16', url => "http://search.cpan.org/~phred/", debian => 'libarchive-zip-perl' },
21 { name => "CGI", version => '3.43', url => "http://search.cpan.org/~leejo/", debian => 'libcgi-perl' }, # 3.43 is core 5.10.1
22 { name => "Clone", url => "http://search.cpan.org/~rdf/", debian => 'libclone-perl' },
23 { name => "Config::Std", url => "http://search.cpan.org/~dconway/", debian => 'libconfig-std-perl' },
24 { name => "DateTime", url => "http://search.cpan.org/~drolsky/", debian => 'libdatetime-perl' },
25 { name => "DateTime::Format::Strptime", url => "http://search.cpan.org/~drolsky/", debian => 'libdatetime-format-strptime-perl' },
26 { name => "DBI", version => '1.50', url => "http://search.cpan.org/~timb/", debian => 'libdbi-perl' },
27 { name => "DBD::Pg", version => '1.49', url => "http://search.cpan.org/~dbdpg/", debian => 'libdbd-pg-perl' },
28 { name => "Email::Address", url => "http://search.cpan.org/~rjbs/", debian => 'libemail-address-perl' },
29 { name => "Email::MIME", url => "http://search.cpan.org/~rjbs/", debian => 'libemail-mime-perl' },
30 { name => "FCGI", version => '0.72', url => "http://search.cpan.org/~mstrout/", debian => 'libfcgi-perl' },
31 { name => "File::Copy::Recursive", url => "http://search.cpan.org/~dmuey/", debian => 'libfile-copy-recursive-perl' },
32 { name => "GD", url => "http://search.cpan.org/~lds/", debian => 'libgd-gd2-perl', },
33 { name => 'HTML::Parser', url => 'http://search.cpan.org/~gaas/', debian => 'libhtml-parser-perl', },
34 { name => 'HTML::Restrict', url => 'http://search.cpan.org/~oalders/', },
35 { name => "Image::Info", url => "http://search.cpan.org/~srezic/", debian => 'libimage-info-perl' },
36 { name => "JSON", url => "http://search.cpan.org/~makamaka", debian => 'libjson-perl' },
37 { name => "List::MoreUtils", version => '0.21', url => "http://search.cpan.org/~vparseval/", debian => 'liblist-moreutils-perl' },
38 { name => "List::UtilsBy", url => "http://search.cpan.org/~pevans/", debian => 'liblist-utilsby-perl' },
39 { name => "Params::Validate", url => "http://search.cpan.org/~drolsky/", debian => 'libparams-validate-perl' },
40 { name => "PDF::API2", version => '2.000', url => "http://search.cpan.org/~areibens/", debian => 'libpdf-api2-perl' },
41 { name => "Rose::Object", url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-object-perl' },
42 { name => "Rose::DB", url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-db-perl' },
43 { name => "Rose::DB::Object", version => 0.788, url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-db-object-perl' },
44 { name => "String::ShellQuote", version => 1.01, url => "http://search.cpan.org/~rosch/", debian => 'libstring-shellquote-perl' },
45 { name => "Sort::Naturally", url => "http://search.cpan.org/~sburke/", debian => 'libsort-naturally-perl' },
46 # Test::Harness is core, so no Debian packages. Test::Harness 3.00 was first packaged in 5.10.1
47 { name => "Test::Harness", version => '3.00', url => "http://search.cpan.org/~petdance/", },
48 { name => "Template", version => '2.18', url => "http://search.cpan.org/~abw/", debian => 'libtemplate-perl' },
49 { name => "Text::CSV_XS", version => '0.23', url => "http://search.cpan.org/~hmbrand/", debian => 'libtext-csv-xs-perl' },
50 { name => "Text::Iconv", version => '1.2', url => "http://search.cpan.org/~mpiotr/", debian => 'libtext-iconv-perl' },
51 { name => "URI", version => '1.35', url => "http://search.cpan.org/~gaas/", debian => 'liburi-perl' },
52 { name => "XML::Writer", version => '0.602', url => "http://search.cpan.org/~josephw/", debian => 'libxml-writer-perl' },
53 { name => "YAML", version => '0.62', url => "http://search.cpan.org/~ingy/", debian => 'libyaml-perl' },
57 { name => "Digest::SHA", url => "http://search.cpan.org/~mshelor/", debian => 'libdigest-sha-perl' },
58 { name => "IO::Socket::SSL", url => "http://search.cpan.org/~sullr/", debian => 'libio-socket-ssl-perl' },
59 { name => "Net::LDAP", url => "http://search.cpan.org/~gbarr/", debian => 'libnet-ldap-perl' },
60 # Net::SMTP is core since 5.7.3
61 { name => "Net::SMTP::SSL", url => "http://search.cpan.org/~cwest/", debian => 'libnet-smtp-ssl-perl' },
62 { name => "Net::SSLGlue", url => "http://search.cpan.org/~sullr/", debian => 'libnet-sslglue-perl' },
65 @developer_modules = (
66 { name => "DBIx::Log4perl", url => "http://search.cpan.org/~mjevans/", },
67 { name => "Devel::REPL", url => "http://search.cpan.org/~doy/", debian => 'libdevel-repl-perl' },
68 { name => "Log::Log4perl", url => "http://search.cpan.org/~mschilli/", debian => 'liblog-log4perl-perl' },
69 { name => "LWP::Simple", url => "http://search.cpan.org/~gaas/", debian => 'libwww-perl', dist_name => 'libwww-perl' },
70 { name => "Moose::Role", url => "http://search.cpan.org/~doy/", debian => 'libmoose-perl' },
71 { name => "Perl::Tags", url => "http://search.cpan.org/~osfameron/", debian => 'libperl-tags-perl' },
72 { name => "Test::Deep", url => "http://search.cpan.org/~rjbs/", debian => 'libtest-deep-perl' },
73 { name => "Test::Exception", url => "http://search.cpan.org/~adie/", debian => 'libtest-exception-perl' },
74 { name => "Test::Output", url => "http://search.cpan.org/~bdfoy/", debian => 'libtest-output-perl' },
75 { name => "URI::Find", url => "http://search.cpan.org/~mschwern/", debian => 'liburi-find-perl' },
76 { name => "GD", version => '2.00', url => "http://search.cpan.org/~lds/", debian => 'libgd-perl' },
77 { name => "Rose::DB::Object", version => 0.809, url => "http://search.cpan.org/~jsiracusa/", debian => 'librose-db-object-perl' },
80 $_->{fullname} = join ' ', grep $_, @$_{qw(name version)}
81 for @required_modules, @optional_modules, @developer_modules;
85 sub module_available {
87 my $version = $_[1] || '' ;
89 my $got = eval "use $module $version (); 1";
92 return ($got, $module->VERSION);
99 my $exit = system("which kpsewhich > /dev/null");
101 return $exit > 0 ? 0 : 1;
106 opendir my $dh, $path || die "can't open $path";
107 my @templates = sort grep { !/^\.\.?$/ } readdir $dh;
113 sub classes_from_latex {
114 my ($path, $class) = @_;
115 eval { use String::ShellQuote; 1 } or warn "can't load String::ShellQuote" && return;
116 $path = shell_quote $path;
117 $class = shell_quote $class;
119 open my $pipe, q#egrep -rs '^[\ \t]*# . "$class' $path". q# | sed 's/ //g' | awk -F '{' '{print $2}' | awk -F '}' '{print $1}' |#;
123 # can't use uniq here
124 my %class_hash = map { $_ => 1 } map { s/\n//; $_ } split ',', join ',', @cls;
125 return sort keys %class_hash;
128 my %conditional_dependencies;
130 sub check_for_conditional_dependencies {
131 return if $conditional_dependencies{net_ldap}++;
133 push @required_modules, grep { $_->{name} eq 'Net::LDAP' } @optional_modules
134 if $::lx_office_conf{authentication} && ($::lx_office_conf{authentication}->{module} eq 'LDAP');
137 sub test_all_modules {
138 return grep { !module_available($_->{name}) } @required_modules;