Project.pm: do not unlink nonexistent file
[girocco.git] / toolbox / check-perl-modules.pl
blob2ab77f5396bc2495c54dba1ea2950bde3188ab27
1 #!/usr/bin/env perl
3 # check-perl-modules.pl -- check for modules used by Girocco
4 # Copyright (c) 2013 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 eval {require Compress::Zlib; 1} or
34 print "Warning: missing Perl module Compress::Zlib, 'git svn gc' will not ".
35 "fully gc\n";
37 # These ones are required
39 my $errors = 0;
41 # For SHA1, any of Digest::SHA, Digest::SHA1 or Digest::SHA::PurePerl will do
43 eval {require Digest::SHA; 1} ||
44 eval {require Digest::SHA1; 1} ||
45 eval {require Digest::SHA::PurePerl; 1} or
46 ++$errors,
47 print STDERR "One of the Perl modules Digest::SHA or Digest::SHA1 or "
48 . "Digest::SHA::PurePerl must be available\n";
50 my @modules = qw(
51 CGI
52 CGI::Carp
53 CGI::Util
54 Digest::MD5
55 Encode
56 Errno
57 Fcntl
58 File::Basename
59 File::Find
60 File::Spec
61 File::stat
62 Getopt::Long
63 IO::Handle
64 IO::Socket
65 IO::Socket::UNIX
66 IPC::Open2
67 JSON
68 LWP::UserAgent
69 MIME::Base64
70 Pod::Usage
71 POSIX
72 RPC::XML
73 RPC::XML::Client
74 Socket
75 Storable
76 Time::HiRes
77 Time::Local
80 my %imports = (
81 Time::HiRes => [qw(gettimeofday tv_interval)],
84 foreach my $module (@modules) {
85 my $imports = '';
86 $imports = " qw(".join(' ', @{$imports{$module}}).")"
87 if $imports{$module};
88 eval "use $module$imports; 1" or
89 ++$errors, print STDERR "Missing required Perl module $module$imports\n";
92 eval {require JSON; 1} &&
93 eval {require LWP::UserAgent; 1} &&
94 eval {require RPC::XML; 1} &&
95 eval {require RPC::XML::Client; 1} or
96 print STDERR "Note: Perl modules JSON, LWP::UserAgent, RPC::XML and RPC::".
97 "XML::Client are required by the ref-change notification mechanism\n";
99 my $fcgi_ok = 1;
100 eval {require FCGI; 1} or $fcgi_ok = 0,
101 print STDERR "Note: running gitweb.cgi in FastCGI mode requires ".
102 "the missing Perl module FCGI\n";
103 eval {require CGI::Fast; 1} or $fcgi_ok = 0,
104 print STDERR "Note: running gitweb.cgi in FastCGI mode requires ".
105 "the missing Perl module CGI::Fast\n";
106 !$fcgi_ok || eval {require FCGI::ProcManager; 1} or
107 print STDERR "Note: gitweb.cgi running in FastCGI mode requires ".
108 "missing FCGI::ProcManager to support the --nproc option\n";
110 exit($errors ? 1 : 0);