make HOMEBREW_BREW_FILE a Pathname object
Currently HOMEBREW_BREW_FILE is a String, while other of HOMEBREW_* variables are all Pathname. This commit unifies them all as Pathname, so it will not cause any confusion. Closes Homebrew/homebrew#48872. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
ca77025f8b
commit
12a452557d
@ -26,8 +26,9 @@ undef cache
|
|||||||
# Where brews installed via URL are cached
|
# Where brews installed via URL are cached
|
||||||
HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE+"Formula"
|
HOMEBREW_CACHE_FORMULA = HOMEBREW_CACHE+"Formula"
|
||||||
|
|
||||||
HOMEBREW_BREW_FILE = ENV["HOMEBREW_BREW_FILE"]
|
if ENV["HOMEBREW_BREW_FILE"]
|
||||||
unless HOMEBREW_BREW_FILE
|
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"])
|
||||||
|
else
|
||||||
odie "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
|
odie "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ module FileUtils
|
|||||||
# Reference from `man 2 open`
|
# Reference from `man 2 open`
|
||||||
# > When a new file is created, it is given the group of the directory which
|
# > When a new file is created, it is given the group of the directory which
|
||||||
# contains it.
|
# contains it.
|
||||||
group_id = if File.grpowned? HOMEBREW_BREW_FILE
|
group_id = if HOMEBREW_BREW_FILE.grpowned?
|
||||||
File.stat(HOMEBREW_BREW_FILE).gid
|
HOMEBREW_BREW_FILE.stat.gid
|
||||||
else
|
else
|
||||||
Process.gid
|
Process.gid
|
||||||
end
|
end
|
||||||
|
@ -871,7 +871,7 @@ class Formula
|
|||||||
# @private
|
# @private
|
||||||
def link_overwrite?(path)
|
def link_overwrite?(path)
|
||||||
# Don't overwrite files not created by Homebrew.
|
# Don't overwrite files not created by Homebrew.
|
||||||
return false unless path.stat.uid == File.stat(HOMEBREW_BREW_FILE).uid
|
return false unless path.stat.uid == HOMEBREW_BREW_FILE.stat.uid
|
||||||
# Don't overwrite files belong to other keg except when that
|
# Don't overwrite files belong to other keg except when that
|
||||||
# keg's formula is deleted.
|
# keg's formula is deleted.
|
||||||
begin
|
begin
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require "tmpdir"
|
require "tmpdir"
|
||||||
require "pathname"
|
require "pathname"
|
||||||
|
|
||||||
HOMEBREW_BREW_FILE = ENV["HOMEBREW_BREW_FILE"]
|
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"])
|
||||||
HOMEBREW_TEMP = Pathname.new(ENV["HOMEBREW_TEMP"] || Dir.tmpdir)
|
HOMEBREW_TEMP = Pathname.new(ENV["HOMEBREW_TEMP"] || Dir.tmpdir)
|
||||||
|
|
||||||
TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") { |k|
|
TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") { |k|
|
||||||
|
@ -104,7 +104,7 @@ begin
|
|||||||
end
|
end
|
||||||
|
|
||||||
if possible_tap && !possible_tap.installed?
|
if possible_tap && !possible_tap.installed?
|
||||||
brew_uid = File.stat(HOMEBREW_BREW_FILE).uid
|
brew_uid = HOMEBREW_BREW_FILE.stat.uid
|
||||||
tap_commands = []
|
tap_commands = []
|
||||||
if Process.uid.zero? && !brew_uid.zero?
|
if Process.uid.zero? && !brew_uid.zero?
|
||||||
tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}]
|
tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user