Commit 0d94f047 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 346270: Eliminate as many BEGIN blocks as possible from checksetup.pl

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=myk
parent be4ea608
...@@ -207,35 +207,24 @@ L<Bugzilla::Install::Requirements> ...@@ -207,35 +207,24 @@ L<Bugzilla::Install::Requirements>
=cut =cut
use strict; use strict;
use 5.008;
my ($silent, %switch); use File::Basename;
use File::Find;
BEGIN { use Getopt::Long qw(:config bundling);
if ($^O =~ /MSWin32/i) { BEGIN { chdir dirname($0); }
require 5.008001; # for CGI 2.93 or higher
}
require 5.008;
use File::Basename;
chdir dirname($0);
}
use lib "."; use lib ".";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Install::Requirements;
BEGIN { if ($^O =~ /MSWin32/i) {
use Getopt::Long qw(:config bundling); require 5.008001; # for CGI 2.93 or higher
GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t',
'verbose|v|no-silent');
} }
my ($silent, %switch);
our %answer; our %answer;
# The use of some Bugzilla modules brings in modules we need to test for GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t',
# Check first, via BEGIN 'verbose|v|no-silent');
BEGIN {
# However, don't run under -c (because of tests)
if (!$^C) {
########################################################################### ###########################################################################
# Check for help request. Display help page if --help/-h/-? was passed. # Check for help request. Display help page if --help/-h/-? was passed.
...@@ -275,9 +264,6 @@ use Bugzilla::Install::Requirements; ...@@ -275,9 +264,6 @@ use Bugzilla::Install::Requirements;
exit if !check_requirements(!$silent)->{pass}; exit if !check_requirements(!$silent)->{pass};
}
}
# Break out if checking the modules is all we have been asked to do. # Break out if checking the modules is all we have been asked to do.
exit if $switch{'check-modules'}; exit if $switch{'check-modules'};
...@@ -292,19 +278,13 @@ if ($^O =~ /MSWin/i) { ...@@ -292,19 +278,13 @@ if ($^O =~ /MSWin/i) {
# Global definitions # Global definitions
########################################################################### ###########################################################################
# These don't work as a "use," and they don't work as a "require" outside # We need $::ENV{'PATH'} to remain defined.
# of a BEGIN block. However, we're safe to them in a BEGIN block here since my $env = $::ENV{'PATH'};
# we've already checked all of the pre-requisites above in the previous require Bugzilla;
# BEGIN block. $::ENV{'PATH'} = $env;
BEGIN {
# We need $::ENV{'PATH'} to remain defined. require Bugzilla::Config;
my $env = $::ENV{'PATH'}; import Bugzilla::Config qw(:admin);
require Bugzilla;
$::ENV{'PATH'} = $env;
require Bugzilla::Config;
import Bugzilla::Config qw(:admin);
}
# 12/17/00 justdave@syndicomm.com - removed declarations of the localconfig # 12/17/00 justdave@syndicomm.com - removed declarations of the localconfig
# variables from this location. We don't want these declared here. They'll # variables from this location. We don't want these declared here. They'll
...@@ -1239,13 +1219,12 @@ unless ($switch{'no-templates'}) { ...@@ -1239,13 +1219,12 @@ unless ($switch{'no-templates'}) {
{ {
print "Precompiling templates ...\n" unless $silent; print "Precompiling templates ...\n" unless $silent;
use File::Find;
require Bugzilla::Template; require Bugzilla::Template;
# Don't hang on templates which use the CGI library # Don't hang on templates which use the CGI library
eval("use CGI qw(-no_debug)"); eval("use CGI qw(-no_debug)");
use File::Spec; require File::Spec;
opendir(DIR, $templatedir) || die "Can't open '$templatedir': $!"; opendir(DIR, $templatedir) || die "Can't open '$templatedir': $!";
my @files = grep { /^[a-z-]+$/i } readdir(DIR); my @files = grep { /^[a-z-]+$/i } readdir(DIR);
closedir DIR; closedir DIR;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment