From cabe538139ecdbc82ab2eb1e06fcf6f95f1dac5f Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Sun, 24 Apr 2011 17:11:03 -0700 Subject: Bug 648178: Make install-module.pl check if a compiler is available and fail with a clear error if not. r=glob, a=mkanat --- Bugzilla/Install/CPAN.pm | 23 +++++++++++++++++++++++ Bugzilla/Install/Util.pm | 8 +++++++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'Bugzilla/Install') diff --git a/Bugzilla/Install/CPAN.pm b/Bugzilla/Install/CPAN.pm index 20cdb5bbd..48dcf6fc0 100644 --- a/Bugzilla/Install/CPAN.pm +++ b/Bugzilla/Install/CPAN.pm @@ -33,6 +33,7 @@ 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); @@ -102,6 +103,8 @@ use constant CPAN_DEFAULTS => { sub check_cpan_requirements { my ($original_dir, $original_args) = @_; + _require_compiler(); + my @install; foreach my $module (REQUIREMENTS) { my $installed = have_vers($module, 1); @@ -122,6 +125,26 @@ sub check_cpan_requirements { } } +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; diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm index a2371a0be..bd8942507 100644 --- a/Bugzilla/Install/Util.pm +++ b/Bugzilla/Install/Util.pm @@ -58,8 +58,14 @@ our @EXPORT_OK = qw( sub bin_loc { my ($bin, $path) = @_; + + # If the binary is a full path... + if ($bin =~ m{[/\\]}) { + return MM->maybe_command($bin) || ''; + } + + # Otherwise we look for it in the path in a cross-platform way. my @path = $path ? @$path : File::Spec->path; - foreach my $dir (@path) { next if !-d $dir; my $full_path = File::Spec->catfile($dir, $bin); -- cgit v1.2.3-24-g4f1b