⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 requirements.pm

📁 bugzilla
💻 PM
📖 第 1 页 / 共 2 页
字号:
$repo_up_cmd***********************************************************************EOT        }    }    # Required Modules    if (my %missing = %{$check_results->{missing}}) {        print <<EOT;************************************************************************ REQUIRED MODULES                                                    ************************************************************************* Bugzilla requires you to install some Perl modules which are either ** missing from your system, or the version on your system is too old. **                                                                     ** The latest versions of each module can be installed by running the  ** commands below.                                                     ************************************************************************EOT        print "COMMANDS:\n\n";        foreach my $package (keys %missing) {            my $command = install_command($missing{$package});            print "    $command\n";        }        print "\n";    }    if (!$check_results->{one_dbd}) {        print <<EOT;************************************************************************ DATABASE ACCESS                                                     ************************************************************************* In order to access your database, Bugzilla requires that the        ** correct "DBD" module be installed for the database that you are     ** running.                                                            **                                                                     ** Pick and run the correct command below for the database that you    ** plan to use with Bugzilla.                                          ************************************************************************COMMANDS:EOT        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 ' ' x 12 . "Minimum version required: "                  . $db_modules{$db}->{dbd}->{version} . "\n";        }        print "\n";    }    return unless $output;    if (my %missing = %{$check_results->{optional}}) {        print <<EOT;*********************************************************************** OPTIONAL MODULES                                                   ************************************************************************ Certain Perl modules are not required by Bugzilla, but by          ** installing the latest version you gain access to additional        ** features.                                                          **                                                                    ** The optional modules you do not have installed are listed below,   ** with the name of the feature they enable. If you want to install   ** one of these modules, just run the appropriate command in the      ** "COMMANDS TO INSTALL" section.                                     ***********************************************************************EOT        # We want to sort them so that they are ordered by feature.        my @missing_names = sort {$missing{$a}->{feature}                                   cmp $missing{$b}->{feature}} (keys %missing);        # Now we have to determine how large the table cols will be.        my $longest_name = max(map(length($_), @missing_names));        # The first column header is at least 11 characters long.        $longest_name = 11 if $longest_name < 11;        # The table is 71 characters long. There are seven mandatory        # characters (* and space) in the string. So, we have a total        # of 64 characters to work with.        my $remaining_space = 64 - $longest_name;        print '*' x 71 . "\n";        printf "* \%${longest_name}s * %-${remaining_space}s *\n",               'MODULE NAME', 'ENABLES FEATURE(S)';        print '*' x 71 . "\n";        foreach my $name (@missing_names) {            printf "* \%${longest_name}s * %-${remaining_space}s *\n",                   $name, $missing{$name}->{feature};        }        print '*' x 71 . "\n";        print "COMMANDS TO INSTALL:\n\n";        foreach my $module (@missing_names) {            my $command = install_command($missing{$module});            printf "%15s: $command\n", $module;        }    }}sub check_graphviz {    my ($output) = @_;    return 1 if (Bugzilla->params->{'webdotbase'} =~ /^https?:/);    printf("Checking for %15s %-9s ", "GraphViz", "(any)") if $output;    my $return = 0;    if(-x Bugzilla->params->{'webdotbase'}) {        print "ok: found\n" if $output;        $return = 1;    } else {        print "not a valid executable: " . Bugzilla->params->{'webdotbase'} . "\n";    }    my $webdotdir = bz_locations()->{'webdotdir'};    # Check .htaccess allows access to generated images    if (-e "$webdotdir/.htaccess") {        my $htaccess = new IO::File("$webdotdir/.htaccess", 'r')             || die "$webdotdir/.htaccess: " . $!;        if (!grep(/png/, $htaccess->getlines)) {            print "Dependency graph images are not accessible.\n";            print "delete $webdotdir/.htaccess and re-run checksetup.pl to fix.\n";        }        $htaccess->close;    }    return $return;}sub display_version_and_os {    # Display version information    printf "\n* This is Bugzilla " . BUGZILLA_VERSION . " on perl %vd\n",           $^V;    my @os_details = POSIX::uname;    # 0 is the name of the OS, 2 is the major version,    my $os_name = $os_details[0] . ' ' . $os_details[2];    if (ON_WINDOWS) {        require Win32;        $os_name = Win32::GetOSName();    }    # 3 is the minor version.    print "* Running on $os_name $os_details[3]\n"}# This was originally clipped from the libnet Makefile.PL, adapted here to# use the below vers_cmp routine 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};    my ($msg, $vnum, $vstr);    no strict 'refs';    printf("Checking for %15s %-9s ", $package, !$wanted?'(any)':"(v$wanted)")         if $output;    eval "require $module;";    # VERSION is provided by UNIVERSAL::    $vnum = eval { $module->VERSION } || -1;    # 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 ($module 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);    my $blacklisted;    if ($vok && $params->{blacklist}) {        $blacklisted = grep($vnum =~ /$_/, @{$params->{blacklist}});        $vok = 0 if $blacklisted;    }    my $ok = $vok ? "ok:" : "";    my $black_string = $blacklisted ? "(blacklisted)" : "";    print "$ok $vstr $black_string\n" if $output;    return $vok ? 1 : 0;}# This is taken straight from Sort::Versions 1.5, which is not included# with perl by default.sub vers_cmp {    my ($a, $b) = @_;    # Remove leading zeroes - Bug 344661    $a =~ s/^0*(\d.+)/$1/;    $b =~ s/^0*(\d.+)/$1/;    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 eq '.' and $B eq '.') {            next;        } elsif ( $A eq '.' ) {            return -1;        } elsif ( $B eq '.' ) {            return 1;        } elsif ($A =~ /^\d+$/ and $B =~ /^\d+$/) {            if ($A =~ /^0/ || $B =~ /^0/) {                return $A cmp $B if $A cmp $B;            } else {                return $A <=> $B if $A <=> $B;            }        } else {            $A = uc $A;            $B = uc $B;            return $A cmp $B if $A cmp $B;        }    }    @A <=> @B;}sub install_command {    my $module = shift;    my ($command, $package);    if (ON_WINDOWS) {        $command = 'ppm install %s';        $package = $module->{package};    }    else {        $command = "$^X -MCPAN -e 'install \"\%s\"'";        # Non-Windows installations need to use module names, because        # CPAN doesn't understand package names.        $package = $module->{module};    }    return sprintf $command, $package;}1;__END__=head1 NAMEBugzilla::Install::Requirements - Functions and variables dealing  with Bugzilla's perl-module requirements.=head1 DESCRIPTIONThis module is used primarily by C<checksetup.pl> to determine whetheror not all of Bugzilla's prerequisites are installed. (That is, all theperl modules it requires.)=head1 CONSTANTS=over 4=item C<REQUIRED_MODULES>An arrayref of hashrefs that describes the perl modules required by Bugzilla. The hashes have two keys, C<name> and C<version>, whichrepresent the name of the module and the version that we require.=back=head1 SUBROUTINES=over 4=item C<check_requirements($output)> Description: This checks what optional or required perl modules              are installed, like C<checksetup.pl> does. Params:      C<$output> - C<true> if you want the function to print                           out information about what it's doing,                           and the versions of everything installed.                           If you don't pass the minimum requirements,                           the will always print out something,                            regardless of this parameter. Returns:    A hashref containing three values:             C<pass> - Whether or not we have all the mandatory                        requirements.             C<missing> - A hash showing which mandatory requirements                          are missing. The key is the module name,                          and the value is the version we require.             C<optional> - Which optional modules are installed and                           up-to-date enough for Bugzilla.=item C<check_graphviz($output)>Description: Checks if the graphviz binary specified in the   C<webdotbase> parameter is a valid binary, or a valid URL.Params:      C<$output> - C<$true> if you want the function to                 print out information about what it's doing.Returns:     C<1> if the check was successful, C<0> otherwise.=item C<vers_cmp($a, $b)> Description: This is a comparison function, like you would use in              C<sort>, except that it compares two version numbers.              It's actually identical to versioncmp from               L<Sort::Versions>. Params:      c<$a> and C<$b> are versions you want to compare. Returns:     -1 if $a is less than $b, 0 if they are equal, and              1 if $a is greater than $b.=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=back

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -