diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-09-19 01:24:06 +0200 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-09-19 01:24:06 +0200 |
commit | 46317c3190e95cca62cd5d932bd6bc4b45e75d23 (patch) | |
tree | cf8b01dfc39fb3cc8bd6c43349b97e58f5947052 /Bugzilla/Install/Util.pm | |
parent | 7df0160f6aaf3adcb3e6ddca0fc172c5ea89eb8c (diff) | |
download | bugzilla-46317c3190e95cca62cd5d932bd6bc4b45e75d23.tar.gz bugzilla-46317c3190e95cca62cd5d932bd6bc4b45e75d23.tar.xz |
Bug 586244: Make mod_headers and mod_expires optional
r=glob, a=mkanat
Diffstat (limited to 'Bugzilla/Install/Util.pm')
-rw-r--r-- | Bugzilla/Install/Util.pm | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm index d65d2f592..50cbfd2a8 100644 --- a/Bugzilla/Install/Util.pm +++ b/Bugzilla/Install/Util.pm @@ -29,7 +29,9 @@ use strict; use Bugzilla::Constants; use Encode; +use ExtUtils::MM (); use File::Basename; +use File::Spec; use POSIX qw(setlocale LC_CTYPE); use Safe; use Scalar::Util qw(tainted); @@ -54,18 +56,19 @@ our @EXPORT_OK = qw( ); sub bin_loc { - my ($bin) = @_; - return '' if ON_WINDOWS; - # Don't print any errors from "which" - open(my $saveerr, ">&STDERR"); - open(STDERR, '>/dev/null'); - my $loc = `which $bin`; - close(STDERR); - open(STDERR, ">&", $saveerr); - my $exit_code = $? >> 8; # See the perlvar manpage. - return '' if $exit_code > 0; - chomp($loc); - return $loc; + my ($bin, $path) = @_; + my @path = $path ? @$path : File::Spec->path; + + foreach my $dir (@path) { + next if !-d $dir; + my $full_path = File::Spec->catfile($dir, $bin); + # MM is an alias for ExtUtils::MM. maybe_command is nice + # because it checks .com, .bat, .exe (etc.) on Windows. + my $command = MM->maybe_command($full_path); + return $command if $command; + } + + return ''; } sub get_version_and_os { |