summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Install/Requirements.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-10-17 15:05:14 +0200
committermkanat%bugzilla.org <>2006-10-17 15:05:14 +0200
commitfcd10254fead1576d691b3a0ba212c67239c0b3e (patch)
tree93aebd6d5e79a7e63d602121131bf021416e1936 /Bugzilla/Install/Requirements.pm
parent124ab7cdf76cf58d8f5d772f51a2a142bb59d5ed (diff)
downloadbugzilla-fcd10254fead1576d691b3a0ba212c67239c0b3e.tar.gz
bugzilla-fcd10254fead1576d691b3a0ba212c67239c0b3e.tar.xz
Bug 350220: Add hooks to checksetup for extensions.
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=ghendricks, a=myk
Diffstat (limited to 'Bugzilla/Install/Requirements.pm')
-rw-r--r--Bugzilla/Install/Requirements.pm51
1 files changed, 47 insertions, 4 deletions
diff --git a/Bugzilla/Install/Requirements.pm b/Bugzilla/Install/Requirements.pm
index f9bcc9711..14efd15f4 100644
--- a/Bugzilla/Install/Requirements.pm
+++ b/Bugzilla/Install/Requirements.pm
@@ -27,6 +27,7 @@ use strict;
use List::Util qw(max);
use POSIX ();
+use Safe;
use base qw(Exporter);
our @EXPORT = qw(
@@ -43,11 +44,15 @@ our @EXPORT = qw(
use Bugzilla::Constants;
+# The below two constants are subroutines so that they can implement
+# a hook. Other than that they are actually constants.
+
# "package" is the perl package we're checking for. "module" is the name
# of the actual module we load with "require" to see if the package is
# installed or not. "version" is the version we need, or 0 if we'll accept
# any version.
-use constant REQUIRED_MODULES => [
+sub REQUIRED_MODULES {
+ my @modules = (
{
package => 'CGI',
module => 'CGI',
@@ -89,9 +94,15 @@ use constant REQUIRED_MODULES => [
module => ON_WINDOWS ? 'MIME::Tools' : 'MIME::Parser',
version => '5.406'
},
-];
+ );
+
+ my $all_modules = _get_extension_requirements(
+ 'REQUIRED_MODULES', \@modules);
+ return $all_modules;
+};
-use constant OPTIONAL_MODULES => [
+sub OPTIONAL_MODULES {
+ my @modules = (
{
package => 'GD',
module => 'GD',
@@ -194,7 +205,39 @@ use constant OPTIONAL_MODULES => [
version => '0.96',
feature => 'mod_perl'
},
-];
+ );
+
+ my $all_modules = _get_extension_requirements(
+ 'OPTIONAL_MODULES', \@modules);
+ return $all_modules;
+};
+
+# This implements the install-requirements hook described in Bugzilla::Hook.
+sub _get_extension_requirements {
+ my ($function, $base_modules) = @_;
+ my @all_modules;
+ # get a list of all extensions
+ my @extensions = glob(bz_locations()->{'extensionsdir'} . "/*");
+ foreach my $extension (@extensions) {
+ my $file = "$extension/code/install-requirements.pl";
+ if (-e $file) {
+ my $safe = new Safe;
+ # This is a very liberal Safe.
+ $safe->permit(qw(:browse require entereval caller));
+ $safe->rdo($file);
+ if ($@) {
+ warn $@;
+ next;
+ }
+ my $modules = eval { &{$safe->varglob($function)}($base_modules) };
+ next unless $modules;
+ push(@all_modules, @$modules);
+ }
+ }
+
+ unshift(@all_modules, @$base_modules);
+ return \@all_modules;
+};
sub check_requirements {
my ($output) = @_;