Skip to content
Snippets Groups Projects
Unverified Commit 0dcf7536 authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #4415 from MikeMcQuaid/tmp-cleanup

Cleanup HOMEBREW_TEMP handling
parents 517bf7ec f46e4596
No related branches found
No related tags found
No related merge requests found
......@@ -105,8 +105,7 @@ then
fi
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOME}/Library/Caches/Homebrew}"
HOMEBREW_TEMP="${HOMEBREW_TEMP:-/private/tmp}"
HOMEBREW_SYSTEM_TEMP="/private/tmp"
else
HOMEBREW_PROCESSOR="$(uname -m)"
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
......@@ -116,10 +115,11 @@ else
CACHE_HOME="${XDG_CACHE_HOME:-${HOME}/.cache}"
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${CACHE_HOME}/Homebrew}"
HOMEBREW_TEMP="${HOMEBREW_TEMP:-/tmp}"
HOMEBREW_SYSTEM_TEMP="/tmp"
fi
HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_SYSTEM_TEMP}}"
if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
-x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] &&
"$HOMEBREW_PREFIX/opt/curl/bin/curl" --version >/dev/null
......@@ -147,6 +147,7 @@ export HOMEBREW_BREW_FILE
export HOMEBREW_PREFIX
export HOMEBREW_REPOSITORY
export HOMEBREW_LIBRARY
export HOMEBREW_SYSTEM_TEMP
export HOMEBREW_TEMP
# Declared in brew.sh
......
......@@ -39,7 +39,11 @@ HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE/"Formula"
HOMEBREW_LOGS = Pathname.new(ENV["HOMEBREW_LOGS"] || "~/Library/Logs/Homebrew/").expand_path
# Must use /tmp instead of $TMPDIR because long paths break Unix domain sockets
HOMEBREW_TEMP = Pathname.new(ENV["HOMEBREW_TEMP"]).realpath
HOMEBREW_TEMP = begin
tmp = Pathname.new(ENV["HOMEBREW_TEMP"])
tmp.mkpath unless tmp.exist?
tmp.realpath
end
unless defined? HOMEBREW_LIBRARY_PATH
# Root of the Homebrew code base
......
......@@ -31,49 +31,50 @@ module Homebrew
ENV["HOMEBREW_UPDATE_TEST"] = "1"
if args.to_tag?
branch = if args.to_tag?
ENV["HOMEBREW_UPDATE_TO_TAG"] = "1"
branch = "stable"
"stable"
else
branch = "master"
"master"
end
cd HOMEBREW_REPOSITORY
start_commit = if commit = args.commit
commit
elsif date = args.before
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
elsif args.to_tag?
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
previous_tag = tags.lines[1]
previous_tag ||= begin
if (HOMEBREW_REPOSITORY/".git/shallow").exist?
safe_system "git", "fetch", "--tags", "--depth=1"
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
elsif OS.linux?
tags = Utils.popen_read("git tag --list | sort -rV")
start_commit, end_commit = nil
cd HOMEBREW_REPOSITORY do
start_commit = if commit = args.commit
commit
elsif date = args.before
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
elsif args.to_tag?
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
previous_tag = tags.lines[1]
previous_tag ||= begin
if (HOMEBREW_REPOSITORY/".git/shallow").exist?
safe_system "git", "fetch", "--tags", "--depth=1"
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
elsif OS.linux?
tags = Utils.popen_read("git tag --list | sort -rV")
end
tags.lines[1]
end
tags.lines[1]
previous_tag = previous_tag.to_s.chomp
odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty?
previous_tag
else
Utils.popen_read("git", "rev-parse", "origin/master").chomp
end
previous_tag = previous_tag.to_s.chomp
odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty?
previous_tag
else
Utils.popen_read("git", "rev-parse", "origin/master").chomp
end
odie "Could not find start commit!" if start_commit.empty?
odie "Could not find start commit!" if start_commit.empty?
start_commit = Utils.popen_read("git", "rev-parse", start_commit).chomp
odie "Could not find start commit!" if start_commit.empty?
start_commit = Utils.popen_read("git", "rev-parse", start_commit).chomp
odie "Could not find start commit!" if start_commit.empty?
end_commit = Utils.popen_read("git", "rev-parse", "HEAD").chomp
odie "Could not find end commit!" if end_commit.empty?
end_commit = Utils.popen_read("git", "rev-parse", "HEAD").chomp
odie "Could not find end commit!" if end_commit.empty?
end
puts "Start commit: #{start_commit}"
puts "End commit: #{end_commit}"
mktemp("update-test") do |staging|
staging.retain! if args.keep_tmp?
mkdir "update-test" do
curdir = Pathname.new(Dir.pwd)
oh1 "Setup test environment..."
......@@ -107,5 +108,7 @@ module Homebrew
EOS
end
end
ensure
FileUtils.rm_r "update-test" unless args.keep_tmp?
end
end
......@@ -116,6 +116,7 @@ class SystemConfig
HOMEBREW_CELLAR: "/usr/local/Cellar",
HOMEBREW_CACHE: "#{ENV["HOME"]}/Library/Caches/Homebrew",
HOMEBREW_RUBY_WARNINGS: "-W0",
HOMEBREW_TEMP: ENV["HOMEBREW_SYSTEM_TEMP"],
}.freeze
boring_keys = %w[
HOMEBREW_BROWSER
......@@ -134,6 +135,7 @@ class SystemConfig
HOMEBREW_MACOS_VERSION
HOMEBREW_RUBY_PATH
HOMEBREW_SYSTEM
HOMEBREW_SYSTEM_TEMP
HOMEBREW_OS_VERSION
HOMEBREW_PATH
HOMEBREW_PROCESSOR
......@@ -155,6 +157,9 @@ class SystemConfig
if defaults_hash[:HOMEBREW_RUBY_WARNINGS] != ENV["HOMEBREW_RUBY_WARNINGS"].to_s
f.puts "HOMEBREW_RUBY_WARNINGS: #{ENV["HOMEBREW_RUBY_WARNINGS"]}"
end
if defaults_hash[:HOMEBREW_TEMP] != HOMEBREW_TEMP.to_s
f.puts "HOMEBREW_TEMP: #{HOMEBREW_TEMP}"
end
unless ENV["HOMEBREW_ENV"]
ENV.sort.each do |key, value|
next unless key.start_with?("HOMEBREW_")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment