check-perl-modules.pl: remove a few requirements
[girocco/readme.git] / toolbox / check-perl-modules.pl
blob5216ed049efc617329255d4fba324dee97df516f
1 #!/usr/bin/env perl
3 # check-perl-modules.pl -- check for modules used by Girocco
4 # Copyright (c) 2013,2019,2020,2021 Kyle J. McKay. All rights reserved.
5 # License GPLv2+: GNU GPL version 2 or later.
6 # www.gnu.org/licenses/gpl-2.0.html
7 # This is free software: you are free to change and redistribute it.
8 # There is NO WARRANTY, to the extent permitted by law.
10 # Attempt to require all the modules used by Perl anywhere in Girocco and
11 # report the failures. There is special handling for the SHA-1 functions
12 # and some other optional modules.
14 # These ones are not errors
16 eval {require Proc::ProcessTable; 1} or
17 print "Note: missing Perl module Proc::ProcessTable, deprecated ".
18 "toolbox/kill-stale-daemons.pl will not function\n";
20 eval {require HTML::Entities; 1} or
21 print "Warning: missing Perl module HTML::Entities, gitweb ".
22 "email obfuscation will be partially disabled\n";
24 eval {require HTML::TagCloud; 1} or
25 print "Warning: missing Perl module HTML::TagCloud, optional gitweb tag cloud ".
26 "display will be all one size\n";
28 eval {require HTTP::Date; 1} ||
29 eval {require Time::ParseDate; 1} or
30 print "Warning: missing Perl module HTTP::Date and Time::ParseDate, gitweb ".
31 "will always return true to if-modified-since feed requests\n";
33 # These ones are required
35 my $errors = 0;
37 # For SHA1, any of Digest::SHA, Digest::SHA1 or Digest::SHA::PurePerl will do
39 eval {require Digest::SHA; 1} ||
40 eval {require Digest::SHA1; 1} ||
41 eval {require Digest::SHA::PurePerl; 1} or
42 ++$errors,
43 print STDERR "One of the Perl modules Digest::SHA or Digest::SHA1 or "
44 . "Digest::SHA::PurePerl must be available\n";
46 # For XML, either of XML::Simple or XML::Parser will do
48 eval {require XML::Simple; 1} ||
49 eval {require XML::Parser; 1} or
50 ++$errors,
51 print STDERR "One of the Perl modules XML::Simple or "
52 . "XML::Parser must be available\n";
54 my @modules = qw(
55 CGI
56 CGI::Carp
57 CGI::Util
58 Compress::Zlib
59 Digest::MD5
60 Encode
61 Errno
62 Fcntl
63 File::Basename
64 File::Find
65 File::Spec
66 File::stat
67 Getopt::Long
68 IO::Handle
69 IO::Socket
70 IO::Socket::UNIX
71 IPC::Open2
72 LWP::UserAgent
73 MIME::Base64
74 Pod::Usage
75 POSIX
76 Socket
77 Storable
78 Time::HiRes
79 Time::Local
82 my %imports = (
83 Time::HiRes => [qw(gettimeofday tv_interval)],
86 foreach my $module (@modules) {
87 my $imports = '';
88 $imports = " qw(".join(' ', @{$imports{$module}}).")"
89 if $imports{$module};
90 eval "use $module$imports; 1" or
91 ++$errors, print STDERR "Missing required Perl module $module$imports\n";
94 eval {require LWP::UserAgent; 1} or
95 print STDERR "Note: Perl module LWP::UserAgent ".
96 "is required by the ref-change notification mechanism\n";
98 my $fcgi_ok = 1;
99 eval {require FCGI; 1} or $fcgi_ok = 0,
100 print STDERR "Note: missing Perl module FCGI used for efficient ".
101 "gitweb.cgi FastCGI implementation\n";
102 my $cgifast_ok = 1;
103 eval {require CGI::Fast; 1} or $cgifast_ok = 0,
104 print STDERR "Note: missing Perl module CGI::Fast used for efficient ".
105 "gitweb.cgi FastCGI implementation\n";
106 my $mods = "";
107 $mods .= "FCGI" unless $fcgi_ok;
108 $mods .= ($mods?" and ":"")."CGI::Fast" unless $cgifast_ok;
109 my $pl = "";
110 $pl = "s" unless $fcgi_ok || $cgifast_ok;
111 $mods eq "" or
112 print STDERR "Warning: gitweb.cgi running in FastCGI mode will use a pure Perl ".
113 "implementation of FastCGI\n".
114 "Warning: install Perl module$pl $mods for a more efficient gitweb.cgi ".
115 "FastCGI implementation\n";
116 eval {require FCGI::ProcManager; 1} or
117 print STDERR "Note: gitweb.cgi running in FastCGI mode requires ".
118 "missing FCGI::ProcManager to support the --nproc option\n";
120 !$errors or print STDERR "\nFatal: required perl modules are missing!\n\n";
122 exit($errors ? 1 : 0);