diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/API/1_0/Server.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Constants.pm | 40 | ||||
-rw-r--r-- | Bugzilla/DB.pm | 25 | ||||
-rw-r--r-- | Bugzilla/Install/CPAN.pm | 339 | ||||
-rw-r--r-- | Bugzilla/Install/Filesystem.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Install/Requirements.pm | 794 | ||||
-rw-r--r-- | Bugzilla/Markdown.pm | 6 |
7 files changed, 12 insertions, 1196 deletions
diff --git a/Bugzilla/API/1_0/Server.pm b/Bugzilla/API/1_0/Server.pm index 627da1e58..af66a4f66 100644 --- a/Bugzilla/API/1_0/Server.pm +++ b/Bugzilla/API/1_0/Server.pm @@ -20,7 +20,7 @@ use Bugzilla::Hook; use Bugzilla::Util qw(datetime_from trick_taint); use File::Basename qw(basename); -use File::Glob qw(:bsd_glob); +use File::Glob qw(:glob); use List::MoreUtils qw(none uniq); use MIME::Base64 qw(decode_base64 encode_base64); use Moo; diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index b269a80bf..6a469b376 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -516,41 +516,11 @@ use constant INSTALLATION_MODE_NON_INTERACTIVE => 1; # Data about what we require for different databases. use constant DB_MODULE => { # MySQL 5.0.15 was the first production 5.0.x release. - 'mysql' => {db => 'Bugzilla::DB::Mysql', db_version => '5.0.15', - dbd => { - package => 'DBD-mysql', - module => 'DBD::mysql', - # Disallow development versions - blacklist => ['_'], - # For UTF-8 support. 4.001 makes sure that blobs aren't - # marked as UTF-8. - version => '4.001', - }, - name => 'MySQL'}, - 'pg' => {db => 'Bugzilla::DB::Pg', db_version => '9.00.0000', - dbd => { - package => 'DBD-Pg', - module => 'DBD::Pg', - # Pg 9.2 requires 2.19.3 as spclocation no longer exists. - version => '2.19.3', - }, - name => 'PostgreSQL'}, - 'oracle'=> {db => 'Bugzilla::DB::Oracle', db_version => '10.02.0', - dbd => { - package => 'DBD-Oracle', - module => 'DBD::Oracle', - version => '1.19', - }, - name => 'Oracle'}, - # SQLite 3.6.22 fixes a WHERE clause problem that may affect us. - sqlite => {db => 'Bugzilla::DB::Sqlite', db_version => '3.6.22', - dbd => { - package => 'DBD-SQLite', - module => 'DBD::SQLite', - # 1.29 is the version that contains 3.6.22. - version => '1.29', - }, - name => 'SQLite'}, + mysql => { db => 'Bugzilla::DB::Mysql', db_version => '5.0.15', name => 'MySQL'}, + pg => { db => 'Bugzilla::DB::Pg', db_version => '9.00.0000', name => 'PostgreSQL'}, + oracle => { db => 'Bugzilla::DB::Oracle', db_version => '10.02.0', name => 'Oracle'}, + # SQLite 3.6.22 fixes a WHERE clause problem that may affect us. + sqlite => { db => 'Bugzilla::DB::Sqlite', db_version => '3.6.22', name => 'SQLite'}, }; # True if we're on Win32. diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 999b6ae10..96a68af03 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -165,10 +165,6 @@ sub bz_check_requirements { . bz_locations()->{'localconfig'}; } - # Check the existence and version of the DBD that we need. - my $dbd = $db->{dbd}; - _bz_check_dbd($db, $output); - # We don't try to connect to the actual database if $db_check is # disabled. unless ($lc->{db_check}) { @@ -183,27 +179,6 @@ sub bz_check_requirements { print "\n" if $output; } -sub _bz_check_dbd { - my ($db, $output) = @_; - - my $dbd = $db->{dbd}; - unless (have_vers($dbd, $output)) { - my $sql_server = $db->{name}; - my $command = install_command($dbd); - my $root = ROOT_USER; - my $dbd_mod = $dbd->{module}; - my $dbd_ver = $dbd->{version}; - die <<EOT; - -For $sql_server, Bugzilla requires that perl's $dbd_mod $dbd_ver or later be -installed. To install this module, run the following command (as $root): - - $command - -EOT - } -} - sub bz_check_server_version { my ($self, $db, $output) = @_; diff --git a/Bugzilla/Install/CPAN.pm b/Bugzilla/Install/CPAN.pm deleted file mode 100644 index 094784e1a..000000000 --- a/Bugzilla/Install/CPAN.pm +++ /dev/null @@ -1,339 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Install::CPAN; - -use 5.10.1; -use strict; -use warnings; - -use parent qw(Exporter); -our @EXPORT = qw( - BZ_LIB - - check_cpan_requirements - set_cpan_config - install_module -); - -use Bugzilla::Constants; -use Bugzilla::Install::Requirements qw(have_vers); -use Bugzilla::Install::Util qw(bin_loc install_string); - -use Config; -use CPAN; -use Cwd qw(abs_path); -use File::Path qw(rmtree); - -# These are required for install-module.pl to be able to install -# all modules properly. -use constant REQUIREMENTS => ( - { - module => 'CPAN', - package => 'CPAN', - version => '1.81', - }, - { - # When Module::Build isn't installed, the YAML module allows - # CPAN to read META.yml to determine that Module::Build first - # needs to be installed to compile a module. - module => 'YAML', - package => 'YAML', - version => 0, - }, - { - # Many modules on CPAN are now built with Dist::Zilla, which - # unfortunately means they require this version of EU::MM to install. - module => 'ExtUtils::MakeMaker', - package => 'ExtUtils-MakeMaker', - version => '6.31', - }, -); - -# We need the absolute path of ext_libpath, because CPAN chdirs around -# and so we can't use a relative directory. -# -# We need it often enough (and at compile time, in install-module.pl) so -# we make it a constant. -use constant BZ_LIB => abs_path(bz_locations()->{ext_libpath}); - -# CPAN requires nearly all of its parameters to be set, or it will start -# asking questions to the user. We want to avoid that, so we have -# defaults here for most of the required parameters we know about, in case -# any of them aren't set. The rest are handled by set_cpan_defaults(). -use constant CPAN_DEFAULTS => { - auto_commit => 0, - # We always force builds, so there's no reason to cache them. - build_cache => 0, - build_requires_install_policy => 'yes', - cache_metadata => 1, - colorize_output => 1, - colorize_print => 'bold', - index_expire => 1, - scan_cache => 'atstart', - - inhibit_startup_message => 1, - - bzip2 => bin_loc('bzip2'), - curl => bin_loc('curl'), - gzip => bin_loc('gzip'), - links => bin_loc('links'), - lynx => bin_loc('lynx'), - make => bin_loc('make'), - pager => bin_loc('less'), - tar => bin_loc('tar'), - unzip => bin_loc('unzip'), - wget => bin_loc('wget'), - - urllist => ['http://www.cpan.org/'], -}; - -sub check_cpan_requirements { - my ($original_dir, $original_args) = @_; - - _require_compiler(); - - my @install; - foreach my $module (REQUIREMENTS) { - my $installed = have_vers($module, 1); - push(@install, $module) if !$installed; - } - - return if !@install; - - my $restart_required; - foreach my $module (@install) { - $restart_required = 1 if $module->{module} eq 'CPAN'; - install_module($module->{module}, 1); - } - - if ($restart_required) { - chdir $original_dir; - exec($^X, $0, @$original_args); - } -} - -sub _require_compiler { - my @errors; - - my $cc_name = $Config{cc}; - my $cc_exists = bin_loc($cc_name); - - if (!$cc_exists) { - push(@errors, install_string('install_no_compiler')); - } - - my $make_name = $CPAN::Config->{make}; - my $make_exists = bin_loc($make_name); - - if (!$make_exists) { - push(@errors, install_string('install_no_make')); - } - - die @errors if @errors; -} - -sub install_module { - my ($name, $test) = @_; - my $bzlib = BZ_LIB; - - # Make Module::AutoInstall install all dependencies and never prompt. - local $ENV{PERL_AUTOINSTALL} = '--alldeps'; - # This makes Net::SSLeay not prompt the user, if it gets installed. - # It also makes any other MakeMaker prompts accept their defaults. - local $ENV{PERL_MM_USE_DEFAULT} = 1; - - # Certain modules require special stuff in order to not prompt us. - my $original_makepl = $CPAN::Config->{makepl_arg}; - # This one's a regex in case we're doing Template::Plugin::GD and it - # pulls in Template-Toolkit as a dependency. - if ($name =~ /^Template/) { - $CPAN::Config->{makepl_arg} .= " TT_ACCEPT=y TT_EXTRAS=n"; - } - elsif ($name eq 'XML::Twig') { - $CPAN::Config->{makepl_arg} = "-n $original_makepl"; - } - elsif ($name eq 'SOAP::Lite') { - $CPAN::Config->{makepl_arg} .= " --noprompt"; - } - - my $module = CPAN::Shell->expand('Module', $name); - if (!$module) { - die install_string('no_such_module', { module => $name }) . "\n"; - } - - print install_string('install_module', - { module => $name, version => $module->cpan_version }) . "\n"; - - if ($test) { - CPAN::Shell->force('install', $name); - } - else { - CPAN::Shell->notest('install', $name); - } - - # If it installed any binaries in the Bugzilla directory, delete them. - if (-d "$bzlib/bin") { - File::Path::rmtree("$bzlib/bin"); - } - - $CPAN::Config->{makepl_arg} = $original_makepl; -} - -sub set_cpan_config { - my $do_global = shift; - my $bzlib = BZ_LIB; - - # We set defaults before we do anything, otherwise CPAN will - # start asking us questions as soon as we load its configuration. - eval { require CPAN::Config; }; - _set_cpan_defaults(); - - # Calling a senseless autoload that does nothing makes us - # automatically load any existing configuration. - # We want to avoid the "invalid command" message. - open(my $saveout, ">&", "STDOUT"); - open(STDOUT, '>', '/dev/null'); - eval { CPAN->ignore_this_error_message_from_bugzilla; }; - undef $@; - close(STDOUT); - open(STDOUT, '>&', $saveout); - - my $dir = $CPAN::Config->{cpan_home}; - if (!defined $dir || !-w $dir) { - # If we can't use the standard CPAN build dir, we try to make one. - $dir = "$ENV{HOME}/.cpan"; - mkdir $dir; - - # If we can't make one, we finally try to use the Bugzilla directory. - if (!-w $dir) { - print STDERR install_string('cpan_bugzilla_home'), "\n"; - $dir = "$bzlib/.cpan"; - } - } - $CPAN::Config->{cpan_home} = $dir; - $CPAN::Config->{build_dir} = "$dir/build"; - # We always force builds, so there's no reason to cache them. - $CPAN::Config->{keep_source_where} = "$dir/source"; - # This is set both here and in defaults so that it's always true. - $CPAN::Config->{inhibit_startup_message} = 1; - # Automatically install dependencies. - $CPAN::Config->{prerequisites_policy} = 'follow'; - - # Unless specified, we install the modules into the Bugzilla directory. - if (!$do_global) { - require Config; - - $CPAN::Config->{makepl_arg} .= " LIB=\"$bzlib\"" - . " INSTALLMAN1DIR=\"$bzlib/man/man1\"" - . " INSTALLMAN3DIR=\"$bzlib/man/man3\"" - # The bindirs are here because otherwise we'll try to write to - # the system binary dirs, and that will cause CPAN to die. - . " INSTALLBIN=\"$bzlib/bin\"" - . " INSTALLSCRIPT=\"$bzlib/bin\"" - # INSTALLDIRS=perl is set because that makes sure that MakeMaker - # always uses the directories we've specified here. - . " INSTALLDIRS=perl"; - $CPAN::Config->{mbuild_arg} = " --install_base \"$bzlib\"" - . " --install_path lib=\"$bzlib\"" - . " --install_path arch=\"$bzlib/$Config::Config{archname}\""; - $CPAN::Config->{mbuild_install_arg} = $CPAN::Config->{mbuild_arg}; - - # When we're not root, sometimes newer versions of CPAN will - # try to read/modify things that belong to root, unless we set - # certain config variables. - $CPAN::Config->{histfile} = "$dir/histfile"; - $CPAN::Config->{use_sqlite} = 0; - $CPAN::Config->{prefs_dir} = "$dir/prefs"; - - # Unless we actually set PERL5LIB, some modules can't install - # themselves, like DBD::mysql, DBD::Pg, and XML::Twig. - my $current_lib = $ENV{PERL5LIB} ? $ENV{PERL5LIB} . ':' : ''; - $ENV{PERL5LIB} = $current_lib . $bzlib; - } -} - -sub _set_cpan_defaults { - # If CPAN hasn't been configured, we try to use some reasonable defaults. - foreach my $key (keys %{CPAN_DEFAULTS()}) { - $CPAN::Config->{$key} = CPAN_DEFAULTS->{$key} - if !defined $CPAN::Config->{$key}; - } - - my @missing; - # In newer CPANs, this is in HandleConfig. In older CPANs, it's in - # Config. - if (eval { require CPAN::HandleConfig }) { - @missing = CPAN::HandleConfig->missing_config_data; - } - else { - @missing = CPAN::Config->missing_config_data; - } - - foreach my $key (@missing) { - $CPAN::Config->{$key} = ''; - } -} - -1; - -__END__ - -=head1 NAME - -Bugzilla::Install::CPAN - Routines to install Perl modules from CPAN. - -=head1 SYNOPSIS - - use Bugzilla::Install::CPAN; - - set_cpan_config(); - install_module('Module::Name'); - -=head1 DESCRIPTION - -This is primarily used by L<install-module> to do the "hard work" of -installing CPAN modules. - -=head1 SUBROUTINES - -=over - -=item C<set_cpan_config> - -Sets up the configuration of CPAN for this session. Must be called -before L</install_module>. Takes one boolean parameter. If true, -L</install_module> will install modules globally instead of to the -local F<lib/> directory. On most systems, you have to be root to do that. - -=item C<install_module> - -Installs a module from CPAN. Takes two arguments: - -=over - -=item C<$name> - The name of the module, just like you'd pass to the -C<install> command in the CPAN shell. - -=item C<$test> - If true, we run tests on this module before installing, -but we still force the install if the tests fail. This is only used -when we internally install a newer CPAN module. - -=back - -Note that calling this function prints a B<lot> of information to -STDOUT and STDERR. - -=back - -=head1 B<Methods in need of POD> - -=over - -=item check_cpan_requirements - -=back diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm index e17285b2f..af7de928d 100644 --- a/Bugzilla/Install/Filesystem.pm +++ b/Bugzilla/Install/Filesystem.pm @@ -161,10 +161,8 @@ sub FILESYSTEM { 'email_in.pl' => { perms => WS_EXECUTE }, 'sanitycheck.pl' => { perms => WS_EXECUTE }, 'checksetup.pl' => { perms => OWNER_EXECUTE }, - 'runtests.pl' => { perms => OWNER_EXECUTE }, 'jobqueue.pl' => { perms => OWNER_EXECUTE }, 'migrate.pl' => { perms => OWNER_EXECUTE }, - 'install-module.pl' => { perms => OWNER_EXECUTE }, 'clean-bug-user-last-visit.pl' => { perms => WS_EXECUTE }, 'app.psgi' => { perms => CGI_READ }, diff --git a/Bugzilla/Install/Requirements.pm b/Bugzilla/Install/Requirements.pm index ccd3a649a..924686f0a 100644 --- a/Bugzilla/Install/Requirements.pm +++ b/Bugzilla/Install/Requirements.pm @@ -27,16 +27,11 @@ use parent qw(Exporter); use autodie; our @EXPORT = qw( - REQUIRED_MODULES - OPTIONAL_MODULES FEATURE_FILES check_requirements check_webdotbase check_font_file - export_cpanfile - have_vers - install_command map_files_to_features ); @@ -74,425 +69,13 @@ use constant APACHE_PATH => [qw( /usr/local/libexec )]; -# 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. -# -# "blacklist" is an arrayref of regular expressions that describe versions that -# are 'blacklisted'--that is, even if the version is high enough, Bugzilla -# will refuse to say that it's OK to run with that version. -sub REQUIRED_MODULES { - my @modules = ( - { - package => 'CGI.pm', - module => 'CGI', - # 3.51 fixes a security problem that affects Bugzilla. - # (bug 591165) - version => '3.51', - }, - { - package => 'Digest-SHA', - module => 'Digest::SHA', - version => 0 - }, - # 0.23 fixes incorrect handling of 1/2 & 3/4 timezones. - { - package => 'TimeDate', - module => 'Date::Format', - version => '2.23' - }, - # 0.75 fixes a warning thrown with Perl 5.17 and newer. - { - package => 'DateTime', - module => 'DateTime', - version => '0.75' - }, - # 1.64 fixes a taint issue preventing the local timezone from - # being determined on some systems. - { - package => 'DateTime-TimeZone', - module => 'DateTime::TimeZone', - version => '1.64' - }, - # 1.54 is required for Perl 5.10+. It also makes DBD::Oracle happy. - { - package => 'DBI', - module => 'DBI', - version => ($^V >= v5.13.3) ? '1.614' : '1.54' - }, - # 2.24 contains several useful text virtual methods. - { - package => 'Template-Toolkit', - module => 'Template', - version => '2.24' - }, - # 1.300011 has a debug mode for SMTP and automatically pass -i to sendmail. - { - package => 'Email-Sender', - module => 'Email::Sender', - version => '1.300011', - }, - { - package => 'Email-MIME', - module => 'Email::MIME', - # This fixes a memory leak in walk_parts that affected jobqueue.pl. - version => '1.904' - }, - { - package => 'URI', - module => 'URI', - # Follows RFC 3986 to escape characters in URI::Escape. - version => '1.55', - }, - # 0.32 fixes several memory leaks in the XS version of some functions. - { - package => 'List-MoreUtils', - module => 'List::MoreUtils', - version => 0.32, - }, - { - package => 'Math-Random-ISAAC', - module => 'Math::Random::ISAAC', - version => '1.0.1', - }, - { - package => 'File-Slurp', - module => 'File::Slurp', - version => '9999.13', - }, - { - package => 'JSON-XS', - module => 'JSON::XS', - # 2.0 is the first version that will work with JSON::RPC. - version => '2.01', - }, - ); - - if (ON_WINDOWS) { - push(@modules, - { - package => 'Win32', - module => 'Win32', - # 0.35 fixes a memory leak in GetOSVersion, which we use. - version => 0.35, - }, - { - package => 'Win32-API', - module => 'Win32::API', - # 0.55 fixes a bug with char* that might affect Bugzilla::RNG. - version => '0.55', - }, - { - package => 'DateTime-TimeZone-Local-Win32', - module => 'DateTime::TimeZone::Local::Win32', - # We require DateTime::TimeZone 1.64, so this version must match. - version => '1.64', - } - ); - } - - my $extra_modules = _get_extension_requirements('REQUIRED_MODULES'); - push(@modules, @$extra_modules); - return \@modules; -}; - -sub OPTIONAL_MODULES { - my @modules = ( - { - package => 'GD', - module => 'GD', - version => '1.20', - feature => [qw(graphical_reports new_charts old_charts)], - }, - { - package => 'Chart', - module => 'Chart::Lines', - # Versions below 2.4.10 throw deprecation warnings, and will crash in - # Perl 2.21 and above. - version => '2.4.10', - feature => [qw(new_charts old_charts)], - }, - { - package => 'Template-GD', - # This module tells us whether or not Template-GD is installed - # on Template-Toolkits after 2.14, and still works with 2.14 and lower. - module => 'Template::Plugin::GD::Image', - version => 0, - feature => ['graphical_reports'], - }, - { - package => 'GDTextUtil', - module => 'GD::Text', - version => 0, - feature => ['graphical_reports'], - }, - { - package => 'GDGraph', - module => 'GD::Graph', - version => 0, - feature => ['graphical_reports'], - }, - { - package => 'MIME-tools', - # MIME::Parser is packaged as MIME::Tools on ActiveState Perl - module => ON_WINDOWS ? 'MIME::Tools' : 'MIME::Parser', - version => '5.406', - feature => ['moving'], - }, - { - package => 'libwww-perl', - module => 'LWP::UserAgent', - version => 0, - feature => ['updates'], - }, - { - package => 'XML-Twig', - module => 'XML::Twig', - version => 0, - feature => ['moving', 'updates'], - }, - { - package => 'PatchReader', - module => 'PatchReader', - # 0.9.6 fixes two notable bugs and significantly improves the UX. - version => '0.9.6', - feature => ['patch_viewer'], - }, - { - package => 'perl-ldap', - module => 'Net::LDAP', - version => 0, - feature => ['auth_ldap'], - }, - { - package => 'Authen-SASL', - module => 'Authen::SASL', - version => 0, - feature => ['smtp_auth'], - }, - { - package => 'Net-SMTP-SSL', - module => 'Net::SMTP::SSL', - version => 1.01, - feature => ['smtp_ssl'], - }, - { - package => 'RadiusPerl', - module => 'Authen::Radius', - version => 0, - feature => ['auth_radius'], - }, - # XXX - Once we require XMLRPC::Lite 0.717 or higher, we can - # remove SOAP::Lite from the list. - { - package => 'SOAP-Lite', - module => 'SOAP::Lite', - # Fixes various bugs, including 542931 and 552353 + stops - # throwing warnings with Perl 5.12. - version => '0.712', - # SOAP::Transport::HTTP 1.12 is bogus. - blacklist => ['^1\.12$'], - feature => ['xmlrpc'], - }, - # Since SOAP::Lite 1.0, XMLRPC::Lite is no longer included - # and so it must be checked separately. - { - package => 'XMLRPC-Lite', - module => 'XMLRPC::Lite', - version => '0.712', - feature => ['xmlrpc'], - }, - { - package => 'JSON-RPC', - module => 'JSON::RPC', - version => 0, - feature => ['jsonrpc'], - }, - { - package => 'Plack', - module => 'Plack', - # 1.0031 contains a security fix which would affect us. - # It also fixes warnings thrown in Perl 5.20 and newer. - version => 1.0031, - feature => ['psgi'], - }, - { - package => 'CGI-Compile', - module => 'CGI::Compile', - version => 0, - feature => ['psgi'], - }, - { - package => 'CGI-Emulate-PSGI', - module => 'CGI::Emulate::PSGI', - version => 0, - feature => ['psgi'], - }, - { - package => 'Test-Taint', - module => 'Test::Taint', - # 1.06 no longer throws warnings with Perl 5.10+. - version => 1.06, - feature => ['jsonrpc', 'xmlrpc', 'rest'], - }, - { - package => 'Moo', - module => 'Moo', - version => 2, - feature => ['rest'] - }, - { - package => 'Module-Runtime', - module => 'Module::Runtime', - version => 0, - feature => ['rest'] - }, - { - package => 'HTTP-Request', - module => 'HTTP::Request', - version => 0, - feature => ['rest'] - }, - { - package => 'HTTP-Response', - module => 'HTTP::Response', - version => 0, - feature => ['rest'] - }, - { - # We need the 'utf8_mode' method of HTML::Parser, for HTML::Scrubber. - package => 'HTML-Parser', - module => 'HTML::Parser', - version => ($^V >= v5.13.3) ? '3.67' : '3.40', - feature => ['html_desc'], - }, - { - package => 'HTML-Scrubber', - module => 'HTML::Scrubber', - version => 0, - feature => ['html_desc'], - }, - { - # we need version 2.21 of Encode for mime_name - package => 'Encode', - module => 'Encode', - version => 2.21, - feature => ['detect_charset'], - }, - { - package => 'Encode-Detect', - module => 'Encode::Detect', - version => 0, - feature => ['detect_charset'], - }, - - # Inbound Email - { - package => 'Email-Reply', - module => 'Email::Reply', - version => 0, - feature => ['inbound_email'], - }, - { - package => 'HTML-FormatText-WithLinks', - module => 'HTML::FormatText::WithLinks', - # We need 0.13 to set the "bold" marker to "*". - version => '0.13', - feature => ['inbound_email'], - }, - - # Mail Queueing - { - package => 'TheSchwartz', - module => 'TheSchwartz', - # 1.10 supports declining of jobs. - version => 1.10, - feature => ['jobqueue'], - }, - { - package => 'Daemon-Generic', - module => 'Daemon::Generic', - version => 0, - feature => ['jobqueue'], - }, - - # mod_perl - { - package => 'mod_perl', - module => 'mod_perl2', - version => '1.999022', - feature => ['mod_perl'], - }, - { - package => 'Apache-SizeLimit', - module => 'Apache2::SizeLimit', - # 0.96 properly determines process size on Linux. - version => '0.96', - feature => ['mod_perl'], - }, - - # typesniffer - { - package => 'File-MimeInfo', - module => 'File::MimeInfo::Magic', - version => '0', - feature => ['typesniffer'], - }, - { - package => 'IO-stringy', - module => 'IO::Scalar', - version => '0', - feature => ['typesniffer'], - }, - - # memcached - { - package => 'Cache-Memcached-Fast', - module => 'Cache::Memcached::Fast', - version => '0.17', - feature => ['memcached'], - }, - - # Markdown - { - package => 'Text-MultiMarkdown', - module => 'Text::MultiMarkdown', - # 1.0.34 supports definition lists. - version => '1.000034', - feature => ['markdown'], - }, - - # Documentation - { - package => 'File-Copy-Recursive', - module => 'File::Copy::Recursive', - version => 0, - feature => ['documentation'], - }, - { - package => 'File-Which', - module => 'File::Which', - version => 0, - feature => ['documentation'], - }, - ); - - my $extra_modules = _get_extension_requirements('OPTIONAL_MODULES'); - push(@modules, @$extra_modules); - return \@modules; -}; - # This maps features to the files that require that feature in order # to compile. It is used by t/001compile.t and mod_perl.pl. use constant FEATURE_FILES => ( jsonrpc => ['Bugzilla/WebService/Server/JSONRPC.pm', 'jsonrpc.cgi'], xmlrpc => ['Bugzilla/WebService/Server/XMLRPC.pm', 'xmlrpc.cgi', 'Bugzilla/WebService.pm', 'Bugzilla/WebService/*.pm'], - rest => ['Bugzilla/API/Server.pm', 'rest.cgi', + rest => ['Bugzilla/API/Server.pm', 'rest.cgi', 'Bugzilla/API/*/*.pm', 'Bugzilla/API/*/Server.pm', 'Bugzilla/API/*/Resource/*.pm'], psgi => ['app.psgi'], moving => ['importxml.pl'], @@ -506,71 +89,19 @@ use constant FEATURE_FILES => ( updates => ['Bugzilla/Update.pm'], markdown => ['Bugzilla/Markdown.pm'], memcached => ['Bugzilla/Memcache.pm'], + auth_delegation => ['auth.cgi'], ); -# This implements the REQUIRED_MODULES and OPTIONAL_MODULES stuff -# described in in Bugzilla::Extension. -sub _get_extension_requirements { - my ($function) = @_; - - my $packages = extension_requirement_packages(); - my @modules; - foreach my $package (@$packages) { - if ($package->can($function)) { - my $extra_modules = $package->$function; - push(@modules, @$extra_modules); - } - } - return \@modules; -}; - sub check_requirements { my ($output) = @_; - print "\n", install_string('checking_modules'), "\n" if $output; - my $root = ROOT_USER; - my $missing = _check_missing(REQUIRED_MODULES, $output); - - print "\n", install_string('checking_dbd'), "\n" if $output; - my $have_one_dbd = 0; - my $db_modules = DB_MODULE; - foreach my $db (keys %$db_modules) { - my $dbd = $db_modules->{$db}->{dbd}; - $have_one_dbd = 1 if have_vers($dbd, $output); - } - - print "\n", install_string('checking_optional'), "\n" if $output; - my $missing_optional = _check_missing(OPTIONAL_MODULES, $output); - my $missing_apache = _missing_apache_modules(APACHE_MODULES, $output); # If we're running on Windows, reset the input line terminator so that # console input works properly - loading CGI tends to mess it up $/ = "\015\012" if ON_WINDOWS; - my $pass = !scalar(@$missing) && $have_one_dbd; - return { - pass => $pass, - one_dbd => $have_one_dbd, - missing => $missing, - optional => $missing_optional, - apache => $missing_apache, - any_missing => !$pass || scalar(@$missing_optional), - }; -} - -# A helper for check_requirements -sub _check_missing { - my ($modules, $output) = @_; - - my @missing; - foreach my $module (@$modules) { - unless (have_vers($module, $output)) { - push(@missing, $module); - } - } - - return \@missing; + return { apache => $missing_apache }; } sub _missing_apache_modules { @@ -621,109 +152,6 @@ sub _check_apache_module { return $ok; } -sub print_module_instructions { - my ($check_results, $output) = @_; - - # First we print the long explanatory messages. - - if (scalar @{$check_results->{missing}}) { - print install_string('modules_message_required'); - } - - if (!$check_results->{one_dbd}) { - print install_string('modules_message_db'); - } - - if (my @missing = @{$check_results->{optional}} and $output) { - print install_string('modules_message_optional'); - # Now we have to determine how large the table cols will be. - my $longest_name = max(map(length($_->{package}), @missing)); - - # The first column header is at least 11 characters long. - $longest_name = 11 if $longest_name < 11; - - # The table is TABLE_WIDTH characters long. There are seven mandatory - # characters (* and space) in the string. So, we have a total - # of TABLE_WIDTH - 7 characters to work with. - my $remaining_space = (TABLE_WIDTH - 7) - $longest_name; - print '*' x TABLE_WIDTH . "\n"; - printf "* \%${longest_name}s * %-${remaining_space}s *\n", - 'MODULE NAME', 'ENABLES FEATURE(S)'; - print '*' x TABLE_WIDTH . "\n"; - foreach my $package (@missing) { - printf "* \%${longest_name}s * %-${remaining_space}s *\n", - $package->{package}, - _translate_feature($package->{feature}); - } - } - - if (my @missing = @{ $check_results->{apache} }) { - print install_string('modules_message_apache'); - my $missing_string = join(', ', @missing); - my $size = TABLE_WIDTH - 7; - printf "* \%-${size}s *\n", $missing_string; - my $spaces = TABLE_WIDTH - 2; - print "*", (' ' x $spaces), "*\n"; - } - - my $need_module_instructions = - ( (!$output and @{$check_results->{missing}}) - or ($output and $check_results->{any_missing}) ) ? 1 : 0; - - if ($need_module_instructions or @{ $check_results->{apache} }) { - # If any output was required, we want to close the "table" - print "*" x TABLE_WIDTH . "\n"; - } - - # And now we print the actual installation commands. - - if (my @missing = @{$check_results->{optional}} and $output) { - print install_string('commands_optional') . "\n\n"; - foreach my $module (@missing) { - my $command = install_command($module); - printf "%15s: $command\n", $module->{package}; - } - print "\n"; - } - - if (!$check_results->{one_dbd}) { - print install_string('commands_dbd') . "\n"; - my %db_modules = %{DB_MODULE()}; - foreach my $db (keys %db_modules) { - my $command = install_command($db_modules{$db}->{dbd}); - printf "%10s: \%s\n", $db_modules{$db}->{name}, $command; - } - print "\n"; - } - - if (my @missing = @{$check_results->{missing}}) { - print colored(install_string('commands_required'), COLOR_ERROR), "\n"; - foreach my $package (@missing) { - my $command = install_command($package); - print " $command\n"; - } - } - - if ($output && $check_results->{any_missing} && !ON_ACTIVESTATE - && !$check_results->{hide_all}) - { - print install_string('install_all', { perl => $^X }); - } - if (!$check_results->{pass}) { - print colored(install_string('installation_failed'), COLOR_ERROR), - "\n\n"; - } -} - -sub _translate_feature { - my $features = shift; - my @strings; - foreach my $feature (@$features) { - push(@strings, install_string("feature_$feature")); - } - return join(', ', @strings); -} - sub check_webdotbase { my ($output) = @_; @@ -781,59 +209,6 @@ sub check_font_file { return $readable && $ttf; } -# This was originally clipped from the libnet Makefile.PL, adapted here for -# accurate version checking. -sub have_vers { - my ($params, $output) = @_; - my $module = $params->{module}; - my $package = $params->{package}; - if (!$package) { - $package = $module; - $package =~ s/::/-/g; - } - my $wanted = $params->{version}; - - eval "require $module;"; - # Don't let loading a module change the output-encoding of STDOUT - # or STDERR. (CGI.pm tries to set "binmode" on these file handles when - # it's loaded, and other modules may do the same in the future.) - Bugzilla::Install::Util::set_output_encoding(); - - # VERSION is provided by UNIVERSAL::, and can be called even if - # the module isn't loaded. We eval'uate ->VERSION because it can die - # when the version is not valid (yes, this happens from time to time). - # In that case, we use an uglier method to get the version. - my $vnum = eval { $module->VERSION }; - if ($@) { - no strict 'refs'; - $vnum = ${"${module}::VERSION"}; - - # If we come here, then the version is not a valid one. - # We try to sanitize it. - if ($vnum =~ /^((\d+)(\.\d+)*)/) { - $vnum = $1; - } - } - $vnum ||= -1; - - # Must do a string comparison as $vnum may be of the form 5.10.1. - my $vok = ($vnum ne '-1' && version->new($vnum) >= version->new($wanted)) ? 1 : 0; - my $blacklisted; - if ($vok && $params->{blacklist}) { - $blacklisted = grep($vnum =~ /$_/, @{$params->{blacklist}}); - $vok = 0 if $blacklisted; - } - - if ($output) { - _checking_for({ - package => $package, ok => $vok, wanted => $wanted, - found => $vnum, blacklisted => $blacklisted - }); - } - - return $vok ? 1 : 0; -} - sub _checking_for { my ($params) = @_; my ($package, $ok, $wanted, $blacklisted, $found) = @@ -872,23 +247,6 @@ sub _checking_for { print $ok ? $str : colored($str, COLOR_ERROR); } -sub install_command { - my $module = shift; - my ($command, $package); - - if (ON_ACTIVESTATE) { - $command = 'ppm install %s'; - $package = $module->{package}; - } - else { - $command = "$^X install-module.pl \%s"; - # Non-Windows installations need to use module names, because - # CPAN doesn't understand package names. - $package = $module->{module}; - } - return sprintf $command, $package; -} - # This does a reverse mapping for FEATURE_FILES. sub map_files_to_features { my %features = FEATURE_FILES; @@ -904,68 +262,6 @@ sub map_files_to_features { return \%files; } -sub export_cpanfile { - my $cpanfile; - # Required modules - foreach my $module (@{ REQUIRED_MODULES() }) { - my $requires = "requires '" . $module->{module} . "'"; - $requires .= ", '" . $module->{version} . "'" if $module->{version}; - $requires .= ";\n"; - $cpanfile .= $requires; - } - # Recommended modules - $cpanfile .= "\n# Optional\n"; - my %features; - foreach my $module (@{ OPTIONAL_MODULES() }) { - next if $module->{package} eq 'mod_perl'; # Skip mod_perl since this would be installed by distro - if (exists $module->{feature}) { - foreach my $feature (@{ $module->{feature} }) { - # cpanm requires that each feature only be defined in the cpanfile - # once, so we use an intermediate hash to consolidate/de-dupe the - # modules associated with each feature. - $features{$feature}{$module->{module}} = $module->{version}; - } - } - else { - my $recommends = ""; - $recommends .= "recommends '" . $module->{module} . "'"; - $recommends .= ", '" . $module->{version} . "'" if $module->{version}; - $recommends .= ";\n"; - $cpanfile .= $recommends; - } - } - foreach my $feature (sort keys %features) { - my $recommends = ""; - $recommends .= "feature '" . $feature . "' => sub {\n"; - foreach my $module (sort keys %{ $features{$feature} }) { - my $version = $features{$feature}{$module}; - $recommends .= " recommends '" . $module . "'"; - $recommends .= ", '$version'" if $version; - $recommends .= ";\n"; - } - $recommends .= "};\n"; - $cpanfile .= $recommends; - } - # Database modules - $cpanfile .= "\n# Database support\n"; - foreach my $db (keys %{ DB_MODULE() }) { - next if !exists DB_MODULE->{$db}->{dbd}; - my $dbd = DB_MODULE->{$db}->{dbd}; - my $recommends .= "feature '$db' => sub {\n"; - $recommends .= " recommends '" . $dbd->{module} . "'"; - $recommends .= ", '" . $dbd->{version} . "'" if $dbd->{version}; - $recommends .= ";\n};\n"; - $cpanfile .= $recommends; - } - - # Write out the cpanfile to the document root - my $file = bz_locations()->{'libpath'} . '/cpanfile'; - open(my $fh, '>', $file); - print $fh $cpanfile; - close $fh; - success(install_string('cpanfile_created', { file => $file })); -} - 1; __END__ @@ -985,31 +281,6 @@ perl modules it requires.) =over -=item C<REQUIRED_MODULES> - -An arrayref of hashrefs that describes the perl modules required by -Bugzilla. The hashes have three keys: - -=over - -=item C<package> - The name of the Perl package that you'd find on -CPAN for this requirement. - -=item C<module> - The name of a module that can be passed to the -C<install> command in C<CPAN.pm> to install this module. - -=item C<version> - The version of this module that we require, or C<0> -if any version is acceptable. - -=back - -=item C<OPTIONAL_MODULES> - -An arrayref of hashrefs that describes the perl modules that add -additional features to Bugzilla if installed. Its hashes have all -the fields of L</REQUIRED_MODULES>, plus a C<feature> item--an arrayref -of strings that describe what features require this module. - =item C<FEATURE_FILES> A hashref that describes what files should only be compiled if a certain @@ -1047,21 +318,8 @@ A hashref containing these values: =over -=item C<pass> - Whether or not we have all the mandatory requirements. - -=item C<missing> - An arrayref containing any required modules that -are not installed or that are not up-to-date. Each item in the array is -a hashref in the format of items from L</REQUIRED_MODULES>. - -=item C<optional> - The same as C<missing>, but for optional modules. - =item C<apache> - The name of each optional Apache module that is missing. -=item C<have_one_dbd> - True if at least one C<DBD::> module is installed. - -=item C<any_missing> - True if there are any missing Perl modules, even -optional modules. - =back =back @@ -1086,45 +344,6 @@ Params: C<$output> - C<$true> if you want the function to Returns: C<1> if the check was successful, C<0> otherwise. -=item C<export_cpanfile> - - Description: Based on C<REQUIRED_MODULES> and C<OPTIONAL_MODULES>, - the function outputs text useful for writing to a - C<cpanfile>. C<cpanfile> can be used by utilities - such as C<cpanm> for installing the Perl dependencies - needed by an application. - - Params: None - - Returns: Text output for writing to a C<cpanfile>. - -=item C<have_vers($module, $output)> - - Description: Tells you whether or not you have the appropriate - version of the module requested. It also prints - out a message to the user explaining the check - and the result. - - Params: C<$module> - A hashref, in the format of an item from - L</REQUIRED_MODULES>. - C<$output> - Set to true if you want this function to - print information to STDOUT about what it's - doing. - - Returns: C<1> if you have the module installed and you have the - appropriate version. C<0> otherwise. - -=item C<install_command($module)> - - Description: Prints out the appropriate command to install the - module specified, depending on whether you're - on Windows or Linux. - - Params: C<$module> - A hashref, in the format of an item from - L</REQUIRED_MODULES>. - - Returns: nothing - =item C<map_files_to_features> Returns a hashref where file names are the keys and the value is the feature @@ -1132,10 +351,3 @@ that must be enabled in order to compile that file. =back -=head1 B<Methods in need of POD> - -=over - -=item print_module_instructions - -=back diff --git a/Bugzilla/Markdown.pm b/Bugzilla/Markdown.pm index 5ca37df28..f73e25014 100644 --- a/Bugzilla/Markdown.pm +++ b/Bugzilla/Markdown.pm @@ -506,9 +506,9 @@ sub _UnescapeSpecialChars { # are bound together with underscores, the string has the desired form. sub _has_multiple_underscores { my $string = shift; - return 0 unless defined($string) && length($string); - return 0 if $string =~ /[\t\s]+/; - return 1 if scalar (split /_/, $string) > 1; + return 0 unless $string; + return 0 if $string =~ /\s/; + return 1 if $string =~ /_/; return 0; } |