Restrict TMPDIR etc. changes to install, post_install and test
See discussion in Homebrew/brew#800.
This commit is contained in:
parent
c39f0baa21
commit
e82347b233
@ -103,6 +103,11 @@ class Build
|
||||
end
|
||||
end
|
||||
|
||||
old_tmpdir = ENV["TMPDIR"]
|
||||
old_temp = ENV["TEMP"]
|
||||
old_tmp = ENV["TMP"]
|
||||
ENV["TMPDIR"] = ENV["TEMP"] = ENV["TMP"] = HOMEBREW_TEMP
|
||||
|
||||
formula.extend(Debrew::Formula) if ARGV.debug?
|
||||
|
||||
formula.brew do |_formula, staging|
|
||||
@ -139,6 +144,10 @@ class Build
|
||||
formula.prefix.install_metafiles formula.libexec if formula.libexec.exist?
|
||||
end
|
||||
end
|
||||
ensure
|
||||
ENV["TMPDIR"] = old_tmpdir
|
||||
ENV["TEMP"] = old_temp
|
||||
ENV["TMP"] = old_tmp
|
||||
end
|
||||
|
||||
def detect_stdlibs(compiler)
|
||||
|
||||
@ -35,11 +35,6 @@ HOMEBREW_LOGS = Pathname.new(ENV["HOMEBREW_LOGS"] || "~/Library/Logs/Homebrew/")
|
||||
# Must use /tmp instead of $TMPDIR because long paths break Unix domain sockets
|
||||
HOMEBREW_TEMP = Pathname.new(ENV.fetch("HOMEBREW_TEMP", "/tmp"))
|
||||
|
||||
# Set common tmpdir environment variables to HOMEBREW_TEMP
|
||||
ENV["TMPDIR"] = HOMEBREW_TEMP
|
||||
ENV["TEMP"] = HOMEBREW_TEMP
|
||||
ENV["TMP"] = HOMEBREW_TEMP
|
||||
|
||||
unless defined? HOMEBREW_LIBRARY_PATH
|
||||
# Root of the Homebrew code base
|
||||
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
||||
|
||||
@ -888,11 +888,18 @@ class Formula
|
||||
def run_post_install
|
||||
build = self.build
|
||||
self.build = Tab.for_formula(self)
|
||||
old_tmpdir = ENV["TMPDIR"]
|
||||
old_temp = ENV["TEMP"]
|
||||
old_tmp = ENV["TMP"]
|
||||
ENV["TMPDIR"] = ENV["TEMP"] = ENV["TMP"] = HOMEBREW_TEMP
|
||||
with_logging("post_install") do
|
||||
post_install
|
||||
end
|
||||
ensure
|
||||
self.build = build
|
||||
ENV["TMPDIR"] = old_tmpdir
|
||||
ENV["TEMP"] = old_temp
|
||||
ENV["TMP"] = old_tmp
|
||||
end
|
||||
|
||||
# Tell the user about any caveats regarding this package.
|
||||
@ -1411,7 +1418,11 @@ class Formula
|
||||
def run_test
|
||||
old_home = ENV["HOME"]
|
||||
old_curl_home = ENV["CURL_HOME"]
|
||||
old_tmpdir = ENV["TMPDIR"]
|
||||
old_temp = ENV["TEMP"]
|
||||
old_tmp = ENV["TMP"]
|
||||
ENV["CURL_HOME"] = old_curl_home || old_home
|
||||
ENV["TMPDIR"] = ENV["TEMP"] = ENV["TMP"] = HOMEBREW_TEMP
|
||||
mktemp("#{name}-test") do |staging|
|
||||
staging.retain! if ARGV.keep_tmp?
|
||||
@testpath = staging.tmpdir
|
||||
@ -1430,6 +1441,9 @@ class Formula
|
||||
@testpath = nil
|
||||
ENV["HOME"] = old_home
|
||||
ENV["CURL_HOME"] = old_curl_home
|
||||
ENV["TMPDIR"] = old_tmpdir
|
||||
ENV["TEMP"] = old_temp
|
||||
ENV["TMP"] = old_tmp
|
||||
end
|
||||
|
||||
# @private
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user