aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/download_strategy.rb6
-rw-r--r--Library/Homebrew/extend/fileutils.rb2
-rw-r--r--Library/Homebrew/utils.rb8
3 files changed, 12 insertions, 4 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index f814f5d5b..008fcc1bc 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -88,12 +88,12 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
case @tarball_path.compression_type
when :zip
- quiet_safe_system '/usr/bin/unzip', {:quiet_flag => '-qq'}, @tarball_path
+ with_system_path { quiet_safe_system 'unzip', {:quiet_flag => '-qq'}, @tarball_path }
chdir
when :gzip, :bzip2, :compress, :tar
# Assume these are also tarred
# TODO check if it's really a tar archive
- safe_system '/usr/bin/tar', 'xf', @tarball_path
+ with_system_path { safe_system 'tar', 'xf', @tarball_path }
chdir
when :xz
raise "You must install XZutils: brew install xz" unless which "xz"
@@ -178,7 +178,7 @@ end
class GzipOnlyDownloadStrategy < CurlDownloadStrategy
def stage
FileUtils.mv @tarball_path, File.basename(@url)
- safe_system '/usr/bin/gunzip', '-f', File.basename(@url)
+ with_system_path { safe_system 'gunzip', '-f', File.basename(@url) }
end
end
diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb
index 231d3b769..30ab584c3 100644
--- a/Library/Homebrew/extend/fileutils.rb
+++ b/Library/Homebrew/extend/fileutils.rb
@@ -14,7 +14,7 @@ module FileUtils extend self
# /tmp volume to the other volume. So we let the user override the tmp
# prefix if they need to.
tmp = ENV['HOMEBREW_TEMP'].chuzzle || '/tmp'
- tempd = `/usr/bin/mktemp -d #{tmp}/#{name}-XXXX`.chuzzle
+ tempd = with_system_path { `mktemp -d #{tmp}/#{name}-XXXX` }.chuzzle
raise "Failed to create sandbox" if tempd.nil?
prevd = pwd
cd tempd
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 955c1e8f2..a6b093acc 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -99,6 +99,14 @@ module Homebrew
end
end
+def with_system_path
+ old_path = ENV['PATH']
+ ENV['PATH'] = '/usr/bin:/bin'
+ yield
+ensure
+ ENV['PATH'] = old_path
+end
+
# Kernel.system but with exceptions
def safe_system cmd, *args
unless Homebrew.system cmd, *args