Commit c64d5c48 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 507493: checksetup.pl's output should use colors for missing and too old…

Bug 507493: checksetup.pl's output should use colors for missing and too old Perl modules - Patch by Fré©ric Buclin <LpSolit@gmail.com> r/a=mkanat
parent 835dbdbd
...@@ -29,6 +29,7 @@ use Bugzilla::Constants; ...@@ -29,6 +29,7 @@ use Bugzilla::Constants;
use Bugzilla::Install::Util qw(vers_cmp install_string); use Bugzilla::Install::Util qw(vers_cmp install_string);
use List::Util qw(max); use List::Util qw(max);
use Safe; use Safe;
use Term::ANSIColor;
use base qw(Exporter); use base qw(Exporter);
our @EXPORT = qw( our @EXPORT = qw(
...@@ -429,8 +430,8 @@ sub print_module_instructions { ...@@ -429,8 +430,8 @@ sub print_module_instructions {
if (vers_cmp($perl_ver, '5.10') > -1) { if (vers_cmp($perl_ver, '5.10') > -1) {
$url_to_theory58S = 'http://cpan.uwinnipeg.ca/PPMPackages/10xx/'; $url_to_theory58S = 'http://cpan.uwinnipeg.ca/PPMPackages/10xx/';
} }
print install_string('ppm_repo_add', print colored(install_string('ppm_repo_add',
{ theory_url => $url_to_theory58S }); { theory_url => $url_to_theory58S }), 'red');
# ActivePerls older than revision 819 require an additional command. # ActivePerls older than revision 819 require an additional command.
if (_get_activestate_build_id() < 819) { if (_get_activestate_build_id() < 819) {
print install_string('ppm_repo_up'); print install_string('ppm_repo_up');
...@@ -463,7 +464,7 @@ sub print_module_instructions { ...@@ -463,7 +464,7 @@ sub print_module_instructions {
} }
if (my @missing = @{$check_results->{missing}}) { if (my @missing = @{$check_results->{missing}}) {
print install_string('commands_required') . "\n"; print colored(install_string('commands_required'), 'red') . "\n";
foreach my $package (@missing) { foreach my $package (@missing) {
my $command = install_command($package); my $command = install_command($package);
print " $command\n"; print " $command\n";
...@@ -473,6 +474,9 @@ sub print_module_instructions { ...@@ -473,6 +474,9 @@ sub print_module_instructions {
if ($output && $check_results->{any_missing} && !ON_WINDOWS) { if ($output && $check_results->{any_missing} && !ON_WINDOWS) {
print install_string('install_all', { perl => $^X }); print install_string('install_all', { perl => $^X });
} }
if (!$check_results->{pass}) {
print colored(install_string('installation_failed'), 'red') . "\n\n";
}
} }
sub _translate_feature { sub _translate_feature {
...@@ -562,8 +566,9 @@ sub have_vers { ...@@ -562,8 +566,9 @@ sub have_vers {
my $want_string = $wanted ? "v$wanted" : install_string('any'); my $want_string = $wanted ? "v$wanted" : install_string('any');
$ok = "$ok:" if $ok; $ok = "$ok:" if $ok;
printf "%s %19s %-9s $ok $vstr $black_string\n", my $str = sprintf "%s %19s %-9s $ok $vstr $black_string\n",
install_string('checking_for'), $package, "($want_string)"; install_string('checking_for'), $package, "($want_string)";
print $vok ? $str : colored($str, 'red');
} }
return $vok ? 1 : 0; return $vok ? 1 : 0;
......
...@@ -43,6 +43,7 @@ our @EXPORT_OK = qw( ...@@ -43,6 +43,7 @@ our @EXPORT_OK = qw(
template_include_path template_include_path
vers_cmp vers_cmp
get_console_locale get_console_locale
init_console
); );
sub bin_loc { sub bin_loc {
...@@ -332,6 +333,11 @@ sub get_console_locale { ...@@ -332,6 +333,11 @@ sub get_console_locale {
return $locale; return $locale;
} }
sub init_console {
eval { ON_WINDOWS && require Win32::Console::ANSI; };
$ENV{'ANSI_COLORS_DISABLED'} = 1 if ($@ || !-t *STDOUT);
$ENV{'HTTP_ACCEPT_LANGUAGE'} ||= get_console_locale();
}
# This is like request_cache, but it's used only by installation code # This is like request_cache, but it's used only by installation code
# for setup.cgi and things like that. # for setup.cgi and things like that.
...@@ -395,6 +401,10 @@ running, what perl version we're using, and what OS we're running on. ...@@ -395,6 +401,10 @@ running, what perl version we're using, and what OS we're running on.
Returns the language to use based on the LC_CTYPE value returned by the OS. Returns the language to use based on the LC_CTYPE value returned by the OS.
If LC_CTYPE is of the form fr-CH, then fr is appended to the list. If LC_CTYPE is of the form fr-CH, then fr is appended to the list.
=item C<init_console>
Sets the C<ANSI_COLORS_DISABLED> and C<HTTP_ACCEPT_LANGUAGE> environment variables.
=item C<indicate_progress> =item C<indicate_progress>
=over =over
......
...@@ -53,7 +53,7 @@ BEGIN { chdir dirname($0); } ...@@ -53,7 +53,7 @@ BEGIN { chdir dirname($0); }
use lib qw(. lib); use lib qw(. lib);
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Install::Requirements; use Bugzilla::Install::Requirements;
use Bugzilla::Install::Util qw(install_string get_version_and_os get_console_locale); use Bugzilla::Install::Util qw(install_string get_version_and_os init_console);
###################################################################### ######################################################################
# Live Code # Live Code
...@@ -61,7 +61,7 @@ use Bugzilla::Install::Util qw(install_string get_version_and_os get_console_loc ...@@ -61,7 +61,7 @@ use Bugzilla::Install::Util qw(install_string get_version_and_os get_console_loc
# When we're running at the command line, we need to pick the right # When we're running at the command line, we need to pick the right
# language before ever displaying any string. # language before ever displaying any string.
$ENV{'HTTP_ACCEPT_LANGUAGE'} ||= get_console_locale(); init_console();
my %switch; my %switch;
GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t', GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t',
......
...@@ -79,6 +79,7 @@ then the value of the ##column## column that needs to be fixed: ...@@ -79,6 +79,7 @@ then the value of the ##column## column that needs to be fixed:
EOT EOT
install_module => 'Installing ##module## version ##version##...', install_module => 'Installing ##module## version ##version##...',
installation_failed => '*** Installation aborted. Read the messages above. ***',
max_allowed_packet => <<EOT, max_allowed_packet => <<EOT,
WARNING: You need to set the max_allowed_packet parameter in your MySQL WARNING: You need to set the max_allowed_packet parameter in your MySQL
configuration to at least ##needed##. Currently it is set to ##current##. configuration to at least ##needed##. Currently it is set to ##current##.
......
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