Cleanup HOMEBREW_TEMP handling
- Ensure that `HOMEBREW_TEMP` is only displayed in `brew config` when it's non-default. - Attempt to create a missing `HOMEBREW_TEMP` directory rather than failing to `realpath`. Note this will still fail on permissions errors which is to be expected.
This commit is contained in:
parent
09ee556833
commit
f46e4596c0
@ -105,8 +105,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOME}/Library/Caches/Homebrew}"
|
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOME}/Library/Caches/Homebrew}"
|
||||||
|
HOMEBREW_SYSTEM_TEMP="/private/tmp"
|
||||||
HOMEBREW_TEMP="${HOMEBREW_TEMP:-/private/tmp}"
|
|
||||||
else
|
else
|
||||||
HOMEBREW_PROCESSOR="$(uname -m)"
|
HOMEBREW_PROCESSOR="$(uname -m)"
|
||||||
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
|
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
|
||||||
@ -116,10 +115,11 @@ else
|
|||||||
|
|
||||||
CACHE_HOME="${XDG_CACHE_HOME:-${HOME}/.cache}"
|
CACHE_HOME="${XDG_CACHE_HOME:-${HOME}/.cache}"
|
||||||
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${CACHE_HOME}/Homebrew}"
|
HOMEBREW_CACHE="${HOMEBREW_CACHE:-${CACHE_HOME}/Homebrew}"
|
||||||
|
HOMEBREW_SYSTEM_TEMP="/tmp"
|
||||||
HOMEBREW_TEMP="${HOMEBREW_TEMP:-/tmp}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_SYSTEM_TEMP}}"
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
|
if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
|
||||||
-x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] &&
|
-x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] &&
|
||||||
"$HOMEBREW_PREFIX/opt/curl/bin/curl" --version >/dev/null
|
"$HOMEBREW_PREFIX/opt/curl/bin/curl" --version >/dev/null
|
||||||
@ -147,6 +147,7 @@ export HOMEBREW_BREW_FILE
|
|||||||
export HOMEBREW_PREFIX
|
export HOMEBREW_PREFIX
|
||||||
export HOMEBREW_REPOSITORY
|
export HOMEBREW_REPOSITORY
|
||||||
export HOMEBREW_LIBRARY
|
export HOMEBREW_LIBRARY
|
||||||
|
export HOMEBREW_SYSTEM_TEMP
|
||||||
export HOMEBREW_TEMP
|
export HOMEBREW_TEMP
|
||||||
|
|
||||||
# Declared in brew.sh
|
# 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
|
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
|
# 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
|
unless defined? HOMEBREW_LIBRARY_PATH
|
||||||
# Root of the Homebrew code base
|
# Root of the Homebrew code base
|
||||||
|
@ -31,49 +31,50 @@ module Homebrew
|
|||||||
|
|
||||||
ENV["HOMEBREW_UPDATE_TEST"] = "1"
|
ENV["HOMEBREW_UPDATE_TEST"] = "1"
|
||||||
|
|
||||||
if args.to_tag?
|
branch = if args.to_tag?
|
||||||
ENV["HOMEBREW_UPDATE_TO_TAG"] = "1"
|
ENV["HOMEBREW_UPDATE_TO_TAG"] = "1"
|
||||||
branch = "stable"
|
"stable"
|
||||||
else
|
else
|
||||||
branch = "master"
|
"master"
|
||||||
end
|
end
|
||||||
|
|
||||||
cd HOMEBREW_REPOSITORY
|
start_commit, end_commit = nil
|
||||||
start_commit = if commit = args.commit
|
cd HOMEBREW_REPOSITORY do
|
||||||
commit
|
start_commit = if commit = args.commit
|
||||||
elsif date = args.before
|
commit
|
||||||
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
|
elsif date = args.before
|
||||||
elsif args.to_tag?
|
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
|
||||||
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
elsif args.to_tag?
|
||||||
previous_tag = tags.lines[1]
|
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||||
previous_tag ||= begin
|
previous_tag = tags.lines[1]
|
||||||
if (HOMEBREW_REPOSITORY/".git/shallow").exist?
|
previous_tag ||= begin
|
||||||
safe_system "git", "fetch", "--tags", "--depth=1"
|
if (HOMEBREW_REPOSITORY/".git/shallow").exist?
|
||||||
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
safe_system "git", "fetch", "--tags", "--depth=1"
|
||||||
elsif OS.linux?
|
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
|
||||||
tags = Utils.popen_read("git tag --list | sort -rV")
|
elsif OS.linux?
|
||||||
|
tags = Utils.popen_read("git tag --list | sort -rV")
|
||||||
|
end
|
||||||
|
tags.lines[1]
|
||||||
end
|
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
|
end
|
||||||
previous_tag = previous_tag.to_s.chomp
|
odie "Could not find start commit!" if start_commit.empty?
|
||||||
odie "Could not find previous tag in:\n#{tags}" if previous_tag.empty?
|
|
||||||
previous_tag
|
start_commit = Utils.popen_read("git", "rev-parse", start_commit).chomp
|
||||||
else
|
odie "Could not find start commit!" if start_commit.empty?
|
||||||
Utils.popen_read("git", "rev-parse", "origin/master").chomp
|
|
||||||
|
end_commit = Utils.popen_read("git", "rev-parse", "HEAD").chomp
|
||||||
|
odie "Could not find end commit!" if end_commit.empty?
|
||||||
end
|
end
|
||||||
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?
|
|
||||||
|
|
||||||
puts "Start commit: #{start_commit}"
|
puts "Start commit: #{start_commit}"
|
||||||
puts "End commit: #{end_commit}"
|
puts "End commit: #{end_commit}"
|
||||||
|
|
||||||
mktemp("update-test") do |staging|
|
mkdir "update-test" do
|
||||||
staging.retain! if args.keep_tmp?
|
|
||||||
curdir = Pathname.new(Dir.pwd)
|
curdir = Pathname.new(Dir.pwd)
|
||||||
|
|
||||||
oh1 "Setup test environment..."
|
oh1 "Setup test environment..."
|
||||||
@ -107,5 +108,7 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
FileUtils.rm_r "update-test" unless args.keep_tmp?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -116,6 +116,7 @@ class SystemConfig
|
|||||||
HOMEBREW_CELLAR: "/usr/local/Cellar",
|
HOMEBREW_CELLAR: "/usr/local/Cellar",
|
||||||
HOMEBREW_CACHE: "#{ENV["HOME"]}/Library/Caches/Homebrew",
|
HOMEBREW_CACHE: "#{ENV["HOME"]}/Library/Caches/Homebrew",
|
||||||
HOMEBREW_RUBY_WARNINGS: "-W0",
|
HOMEBREW_RUBY_WARNINGS: "-W0",
|
||||||
|
HOMEBREW_TEMP: ENV["HOMEBREW_SYSTEM_TEMP"],
|
||||||
}.freeze
|
}.freeze
|
||||||
boring_keys = %w[
|
boring_keys = %w[
|
||||||
HOMEBREW_BROWSER
|
HOMEBREW_BROWSER
|
||||||
@ -134,6 +135,7 @@ class SystemConfig
|
|||||||
HOMEBREW_MACOS_VERSION
|
HOMEBREW_MACOS_VERSION
|
||||||
HOMEBREW_RUBY_PATH
|
HOMEBREW_RUBY_PATH
|
||||||
HOMEBREW_SYSTEM
|
HOMEBREW_SYSTEM
|
||||||
|
HOMEBREW_SYSTEM_TEMP
|
||||||
HOMEBREW_OS_VERSION
|
HOMEBREW_OS_VERSION
|
||||||
HOMEBREW_PATH
|
HOMEBREW_PATH
|
||||||
HOMEBREW_PROCESSOR
|
HOMEBREW_PROCESSOR
|
||||||
@ -155,6 +157,9 @@ class SystemConfig
|
|||||||
if defaults_hash[:HOMEBREW_RUBY_WARNINGS] != ENV["HOMEBREW_RUBY_WARNINGS"].to_s
|
if defaults_hash[:HOMEBREW_RUBY_WARNINGS] != ENV["HOMEBREW_RUBY_WARNINGS"].to_s
|
||||||
f.puts "HOMEBREW_RUBY_WARNINGS: #{ENV["HOMEBREW_RUBY_WARNINGS"]}"
|
f.puts "HOMEBREW_RUBY_WARNINGS: #{ENV["HOMEBREW_RUBY_WARNINGS"]}"
|
||||||
end
|
end
|
||||||
|
if defaults_hash[:HOMEBREW_TEMP] != HOMEBREW_TEMP.to_s
|
||||||
|
f.puts "HOMEBREW_TEMP: #{HOMEBREW_TEMP}"
|
||||||
|
end
|
||||||
unless ENV["HOMEBREW_ENV"]
|
unless ENV["HOMEBREW_ENV"]
|
||||||
ENV.sort.each do |key, value|
|
ENV.sort.each do |key, value|
|
||||||
next unless key.start_with?("HOMEBREW_")
|
next unless key.start_with?("HOMEBREW_")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user