diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-04-20 01:21:58 +0200 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-04-20 01:21:58 +0200 |
commit | 049ae4ae5d0367485910064f62b1baf38fdaad04 (patch) | |
tree | 1be645e4d0d5fdf6b1bb81aea55f07cabea0e361 /Bugzilla/Install | |
parent | 3944a53b67f20592b960f03c65d9ff2b490f58fb (diff) | |
download | bugzilla-049ae4ae5d0367485910064f62b1baf38fdaad04.tar.gz bugzilla-049ae4ae5d0367485910064f62b1baf38fdaad04.tar.xz |
Bug 560284: Make all errors that checksetup.pl throws be red
r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r-- | Bugzilla/Install/DB.pm | 14 | ||||
-rw-r--r-- | Bugzilla/Install/Requirements.pm | 14 | ||||
-rw-r--r-- | Bugzilla/Install/Util.pm | 17 |
3 files changed, 33 insertions, 12 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 81372da71..aa71c7d0a 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -3080,11 +3080,11 @@ sub _check_content_length { WHERE CHAR_LENGTH($field_name) > ?", {Columns=>[1,2]}, $max_length) }; if (scalar keys %contents) { - print install_string('install_data_too_long', - { column => $field_name, - id_column => $id_field, - table => $table_name, - max_length => $max_length }); + my $error = install_string('install_data_too_long', + { column => $field_name, + id_column => $id_field, + table => $table_name, + max_length => $max_length }); foreach my $id (keys %contents) { my $string = $contents{$id}; # Don't dump the whole string--it could be 16MB. @@ -3092,9 +3092,9 @@ sub _check_content_length { $string = substr($string, 0, 30) . "..." . substr($string, -30) . "\n"; } - print "$id: $string\n"; + $error .= "$id: $string\n"; } - exit 3; + die $error; } } diff --git a/Bugzilla/Install/Requirements.pm b/Bugzilla/Install/Requirements.pm index 34e93b675..b80d7fa8b 100644 --- a/Bugzilla/Install/Requirements.pm +++ b/Bugzilla/Install/Requirements.pm @@ -425,8 +425,11 @@ sub print_module_instructions { if (vers_cmp($perl_ver, '5.10') > -1) { $url_to_theory58S = 'http://cpan.uwinnipeg.ca/PPMPackages/10xx/'; } - print colored(install_string('ppm_repo_add', - { theory_url => $url_to_theory58S }), 'red'); + print colored( + install_string('ppm_repo_add', + { theory_url => $url_to_theory58S }), + COLOR_ERROR); + # ActivePerls older than revision 819 require an additional command. if (ON_ACTIVESTATE < 819) { print install_string('ppm_repo_up'); @@ -459,7 +462,7 @@ sub print_module_instructions { } if (my @missing = @{$check_results->{missing}}) { - print colored(install_string('commands_required'), 'red') . "\n"; + print colored(install_string('commands_required'), COLOR_ERROR), "\n"; foreach my $package (@missing) { my $command = install_command($package); print " $command\n"; @@ -472,7 +475,8 @@ sub print_module_instructions { print install_string('install_all', { perl => $^X }); } if (!$check_results->{pass}) { - print colored(install_string('installation_failed'), 'red') . "\n\n"; + print colored(install_string('installation_failed'), COLOR_ERROR), + "\n\n"; } } @@ -565,7 +569,7 @@ sub have_vers { $ok = "$ok:" if $ok; my $str = sprintf "%s %19s %-9s $ok $vstr $black_string\n", install_string('checking_for'), $package, "($want_string)"; - print $vok ? $str : colored($str, 'red'); + print $vok ? $str : colored($str, COLOR_ERROR); } return $vok ? 1 : 0; diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm index 6621a7a41..7bafa9330 100644 --- a/Bugzilla/Install/Util.pm +++ b/Bugzilla/Install/Util.pm @@ -32,6 +32,7 @@ use File::Basename; use POSIX qw(setlocale LC_CTYPE); use Safe; use Scalar::Util qw(tainted); +use Term::ANSIColor qw(colored); use base qw(Exporter); our @EXPORT_OK = qw( @@ -559,9 +560,25 @@ sub get_console_locale { sub init_console { eval { ON_WINDOWS && require Win32::Console::ANSI; }; $ENV{'ANSI_COLORS_DISABLED'} = 1 if ($@ || !-t *STDOUT); + $SIG{__DIE__} = \&_console_die; prevent_windows_dialog_boxes(); } +sub _console_die { + my ($message) = @_; + # $^S means "we are in an eval" + if ($^S) { + die $message; + } + # Remove newlines from the message before we color it, and then + # add them back in on display. Otherwise the ANSI escape code + # for resetting the color comes after the newline, and Perl thinks + # that it should put "at Bugzilla/Install.pm line 1234" after the + # message. + $message =~ s/\n+$//; + die colored($message, COLOR_ERROR) . "\n"; +} + sub prevent_windows_dialog_boxes { # This code comes from http://bugs.activestate.com/show_bug.cgi?id=82183 # and prevents Perl modules from popping up dialog boxes, particularly |