From 9f7ba4e2a5a3b7a4a22e160343b7571058736199 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 14 Jul 2006 04:50:08 +0000 Subject: Bug 281494: Create Bugzilla::Install::Requirements for requirements-checking subroutines in checksetup.pl Patch By Max Kanat-Alexander r=colin, r=wicked, a=myk --- checksetup.pl | 161 ++-------------------------------------------------------- 1 file changed, 3 insertions(+), 158 deletions(-) (limited to 'checksetup.pl') diff --git a/checksetup.pl b/checksetup.pl index ba7e2e59a..9033666ee 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -208,170 +208,15 @@ printf "\n*** This is Bugzilla " . BUGZILLA_VERSION . " on perl %vd ***\n", $^V # Check required module ########################################################################### +use Bugzilla::Install::Requirements; + # # Here we check for --MODULES-- # print "\nChecking perl modules ...\n" unless $silent; -# vers_cmp is adapted from Sort::Versions 1.3 1996/07/11 13:37:00 kjahds, -# which is not included with Perl by default, hence the need to copy it here. -# Seems silly to require it when this is the only place we need it... -sub vers_cmp { - if (@_ < 2) { die "not enough parameters for vers_cmp" } - if (@_ > 2) { die "too many parameters for vers_cmp" } - my ($a, $b) = @_; - my (@A) = ($a =~ /(\.|\d+|[^\.\d]+)/g); - my (@B) = ($b =~ /(\.|\d+|[^\.\d]+)/g); - my ($A,$B); - while (@A and @B) { - $A = shift @A; - $B = shift @B; - if ($A eq "." and $B eq ".") { - next; - } elsif ( $A eq "." ) { - return -1; - } elsif ( $B eq "." ) { - return 1; - } elsif ($A =~ /^\d+$/ and $B =~ /^\d+$/) { - return $A <=> $B if $A <=> $B; - } else { - $A = uc $A; - $B = uc $B; - return $A cmp $B if $A cmp $B; - } - } - @A <=> @B; -} - -# This was originally clipped from the libnet Makefile.PL, adapted here to -# use the above vers_cmp routine for accurate version checking. -sub have_vers { - my ($pkg, $wanted) = @_; - my ($msg, $vnum, $vstr); - no strict 'refs'; - printf("Checking for %15s %-9s ", $pkg, !$wanted?'(any)':"(v$wanted)") unless $silent; - - # Modules may change $SIG{__DIE__} and $SIG{__WARN__}, so localise them here - # so that later errors display 'normally' - local $::SIG{__DIE__}; - local $::SIG{__WARN__}; - - eval "require $pkg;"; - - # do this twice to avoid a "used only once" error for these vars - $vnum = ${"${pkg}::VERSION"} || ${"${pkg}::Version"} || 0; - $vnum = ${"${pkg}::VERSION"} || ${"${pkg}::Version"} || 0; - $vnum = -1 if $@; - - # CGI's versioning scheme went 2.75, 2.751, 2.752, 2.753, 2.76 - # That breaks the standard version tests, so we need to manually correct - # the version - if ($pkg eq 'CGI' && $vnum =~ /(2\.7\d)(\d+)/) { - $vnum = $1 . "." . $2; - } - - if ($vnum eq "-1") { # string compare just in case it's non-numeric - $vstr = "not found"; - } - elsif (vers_cmp($vnum,"0") > -1) { - $vstr = "found v$vnum"; - } - else { - $vstr = "found unknown version"; - } - - my $vok = (vers_cmp($vnum,$wanted) > -1); - print ((($vok) ? "ok: " : " "), "$vstr\n") unless $silent; - return $vok; -} - -# Check versions of dependencies. 0 for version = any version acceptable -my $modules = [ - { - name => 'AppConfig', - version => '1.52' - }, - { - name => 'CGI', - version => '2.93' - }, - { - name => 'Data::Dumper', - version => '0' - }, - { - name => 'Date::Format', - version => '2.21' - }, - { - name => 'DBI', - version => '1.38' - }, - { - name => 'File::Spec', - version => '0.84' - }, - { - name => 'File::Temp', - version => '0' - }, - { - name => 'Template', - version => '2.08' - }, - { - name => 'Text::Wrap', - version => '2001.0131' - }, - { - name => 'Mail::Mailer', - version => '1.67' - }, - { - name => 'MIME::Base64', - version => '3.01' - }, - { - # MIME::Parser is packaged as MIME::Tools on ActiveState Perl - name => $^O =~ /MSWin32/i ? 'MIME::Tools' : 'MIME::Parser', - version => '5.406' - }, - { - name => 'Storable', - version => '0' - }, -]; - -my %ppm_modules = ( - 'AppConfig' => 'AppConfig', - 'Chart::Base' => 'Chart', - 'CGI' => 'CGI', - 'Data::Dumper' => 'Data-Dumper', - 'Date::Format' => 'TimeDate', - 'DBI' => 'DBI', - 'DBD::mysql' => 'DBD-mysql', - 'Template' => 'Template-Toolkit', - 'PatchReader' => 'PatchReader', - 'GD' => 'GD', - 'GD::Graph' => 'GDGraph', - 'GD::Text::Align' => 'GDTextUtil', - 'Mail::Mailer' => 'MailTools', - 'Mail::Base64' => 'MIME-Base64', - 'MIME::Tools' => 'MIME-Tools', - 'XML::Twig' => 'XML-Twig', - 'LWP::UserAgent' => 'LWP-UserAgent' -); - -sub install_command { - my $module = shift; - if ($^O =~ /MSWin32/i) { - return "ppm install " . $ppm_modules{$module} if exists $ppm_modules{$module}; - return "ppm install " . $module; - } else { - return "$^X -MCPAN -e 'install \"$module\"'"; - } -} +my $modules = REQUIRED_MODULES; $::root = ($^O =~ /MSWin32/i ? 'Administrator' : 'root'); -- cgit v1.2.3-24-g4f1b