Add guards to calls that would trigger Xcode install requests
add guard in Formula#file_modified? to prevent git popup add guard in Superenv.bin before calling MacOS::Xcode.version add guard against missing Xcode/CLT in Xcode.uncached_version return nil instread of 0 in uncached_version when Xcode/CLT are not present, to distinguish from linuxbrew behavior checks against pour_bottle? and needs_relocation?, add guard around keg.relocate_install_names to check pour_bottle?/needs_relocation? as well needs_relocation? becomes skip_relocation?, use cellar attr to indicate relocation instead of does_not_need_relocation MacOS.can_build? becomes MacOS.has_apple_developer_tools?
This commit is contained in:
parent
f58506ea6f
commit
1face808f5
@ -7,23 +7,23 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def llvm
|
def llvm
|
||||||
@llvm ||= MacOS.llvm_build_version
|
@llvm ||= MacOS.llvm_build_version if MacOS.has_apple_developer_tools?
|
||||||
end
|
end
|
||||||
|
|
||||||
def gcc_42
|
def gcc_42
|
||||||
@gcc_42 ||= MacOS.gcc_42_build_version
|
@gcc_42 ||= MacOS.gcc_42_build_version if MacOS.has_apple_developer_tools?
|
||||||
end
|
end
|
||||||
|
|
||||||
def gcc_40
|
def gcc_40
|
||||||
@gcc_40 ||= MacOS.gcc_40_build_version
|
@gcc_40 ||= MacOS.gcc_40_build_version if MacOS.has_apple_developer_tools?
|
||||||
end
|
end
|
||||||
|
|
||||||
def clang
|
def clang
|
||||||
@clang ||= MacOS.clang_version
|
@clang ||= MacOS.clang_version if MacOS.has_apple_developer_tools?
|
||||||
end
|
end
|
||||||
|
|
||||||
def clang_build
|
def clang_build
|
||||||
@clang_build ||= MacOS.clang_build_version
|
@clang_build ||= MacOS.clang_build_version if MacOS.has_apple_developer_tools?
|
||||||
end
|
end
|
||||||
|
|
||||||
def xcode
|
def xcode
|
||||||
|
@ -40,7 +40,7 @@ module Homebrew
|
|||||||
|
|
||||||
# if the user's flags will prevent bottle only-installations when no
|
# if the user's flags will prevent bottle only-installations when no
|
||||||
# developer tools are available, we need to stop them early on
|
# developer tools are available, we need to stop them early on
|
||||||
FormulaInstaller.prevent_build_flags unless MacOS.can_build?
|
FormulaInstaller.prevent_build_flags unless MacOS.has_apple_developer_tools?
|
||||||
|
|
||||||
ARGV.formulae.each do |f|
|
ARGV.formulae.each do |f|
|
||||||
# head-only without --HEAD is an error
|
# head-only without --HEAD is an error
|
||||||
@ -126,11 +126,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_xcode
|
def check_xcode
|
||||||
# TODO: reinstate check_for_bad_install_name_tool and check_for_installed_developer_tools
|
|
||||||
# currently check_for_bad_install_name_tool fails because it tries to call
|
|
||||||
# the /usr/bin/otool stub program on systems without XCode/CLT
|
|
||||||
# check_for_installed_developer_tools doesn't fail, but produces a warning
|
|
||||||
# when one is no longer required
|
|
||||||
checks = Checks.new
|
checks = Checks.new
|
||||||
%w[
|
%w[
|
||||||
check_for_unsupported_osx
|
check_for_unsupported_osx
|
||||||
|
@ -2,7 +2,7 @@ require "formula_installer"
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def reinstall
|
def reinstall
|
||||||
FormulaInstaller.prevent_build_flags unless MacOS.can_build?
|
FormulaInstaller.prevent_build_flags unless MacOS.has_apple_developer_tools?
|
||||||
|
|
||||||
ARGV.resolved_formulae.each { |f| reinstall_formula(f) }
|
ARGV.resolved_formulae.each { |f| reinstall_formula(f) }
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@ require "cmd/outdated"
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def upgrade
|
def upgrade
|
||||||
FormulaInstaller.prevent_build_flags unless MacOS.can_build?
|
FormulaInstaller.prevent_build_flags unless MacOS.has_apple_developer_tools?
|
||||||
|
|
||||||
Homebrew.perform_preinstall_checks
|
Homebrew.perform_preinstall_checks
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ module Stdenv
|
|||||||
self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir
|
self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir
|
||||||
|
|
||||||
# make any aclocal stuff installed in Homebrew available
|
# make any aclocal stuff installed in Homebrew available
|
||||||
self["ACLOCAL_PATH"] = "#{HOMEBREW_PREFIX}/share/aclocal" if MacOS::Xcode.provides_autotools?
|
self["ACLOCAL_PATH"] = "#{HOMEBREW_PREFIX}/share/aclocal" if MacOS.has_apple_developer_tools? && MacOS::Xcode.provides_autotools?
|
||||||
|
|
||||||
self["MAKEFLAGS"] = "-j#{make_jobs}"
|
self["MAKEFLAGS"] = "-j#{make_jobs}"
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ module Superenv
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.bin
|
def self.bin
|
||||||
|
return unless MacOS.has_apple_developer_tools?
|
||||||
|
|
||||||
bin = (HOMEBREW_REPOSITORY/"Library/ENV").subdirs.reject { |d| d.basename.to_s > MacOS::Xcode.version }.max
|
bin = (HOMEBREW_REPOSITORY/"Library/ENV").subdirs.reject { |d| d.basename.to_s > MacOS::Xcode.version }.max
|
||||||
bin.realpath unless bin.nil?
|
bin.realpath unless bin.nil?
|
||||||
end
|
end
|
||||||
|
@ -720,7 +720,11 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
def file_modified?
|
def file_modified?
|
||||||
return false unless which("git")
|
git_dir = MacOS.locate("git").dirname.to_s
|
||||||
|
|
||||||
|
# /usr/bin/git is a popup stub when Xcode/CLT aren't installed, so bail out
|
||||||
|
return false if git_dir == "/usr/bin" && !MacOS.has_apple_developer_tools?
|
||||||
|
|
||||||
path.parent.cd do
|
path.parent.cd do
|
||||||
diff = Utils.popen_read("git", "diff", "origin/master", "--", "#{path}")
|
diff = Utils.popen_read("git", "diff", "origin/master", "--", "#{path}")
|
||||||
!diff.empty? && $?.exitstatus == 0
|
!diff.empty? && $?.exitstatus == 0
|
||||||
|
@ -154,7 +154,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
check_conflicts
|
check_conflicts
|
||||||
|
|
||||||
if !pour_bottle? && !MacOS.can_build?
|
if !pour_bottle? && !MacOS.has_apple_developer_tools?
|
||||||
raise BuildToolsError.new([formula])
|
raise BuildToolsError.new([formula])
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
if pour_bottle?(:warn => true)
|
if pour_bottle?(:warn => true)
|
||||||
begin
|
begin
|
||||||
install_relocation_tools if formula.bottle.needs_relocation?
|
install_relocation_tools unless formula.bottle.skip_relocation?
|
||||||
pour
|
pour
|
||||||
rescue => e
|
rescue => e
|
||||||
raise if ARGV.homebrew_developer?
|
raise if ARGV.homebrew_developer?
|
||||||
@ -243,7 +243,7 @@ class FormulaInstaller
|
|||||||
def check_dependencies_bottled(deps)
|
def check_dependencies_bottled(deps)
|
||||||
unbottled = deps.select do |dep, _|
|
unbottled = deps.select do |dep, _|
|
||||||
formula = dep.to_formula
|
formula = dep.to_formula
|
||||||
!formula.pour_bottle? && !MacOS.can_build?
|
!formula.pour_bottle? && !MacOS.has_apple_developer_tools?
|
||||||
end
|
end
|
||||||
|
|
||||||
raise BuildToolsError.new(unbottled) unless unbottled.empty?
|
raise BuildToolsError.new(unbottled) unless unbottled.empty?
|
||||||
@ -434,9 +434,7 @@ class FormulaInstaller
|
|||||||
keg = Keg.new(formula.prefix)
|
keg = Keg.new(formula.prefix)
|
||||||
link(keg)
|
link(keg)
|
||||||
|
|
||||||
# this needs to be changed to a test against build_bottle? and
|
fix_install_names(keg) unless @poured_bottle && formula.bottle.skip_relocation?
|
||||||
# formula.bottle.needs_relocation?
|
|
||||||
fix_install_names(keg) unless formula.name == 'cctools'
|
|
||||||
|
|
||||||
if build_bottle? && formula.post_install_defined?
|
if build_bottle? && formula.post_install_defined?
|
||||||
ohai "Not running post_install as we're building a bottle"
|
ohai "Not running post_install as we're building a bottle"
|
||||||
@ -668,8 +666,10 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
keg = Keg.new(formula.prefix)
|
keg = Keg.new(formula.prefix)
|
||||||
|
unless formula.bottle.skip_relocation?
|
||||||
keg.relocate_install_names Keg::PREFIX_PLACEHOLDER, HOMEBREW_PREFIX.to_s,
|
keg.relocate_install_names Keg::PREFIX_PLACEHOLDER, HOMEBREW_PREFIX.to_s,
|
||||||
Keg::CELLAR_PLACEHOLDER, HOMEBREW_CELLAR.to_s, :keg_only => formula.keg_only?
|
Keg::CELLAR_PLACEHOLDER, HOMEBREW_CELLAR.to_s, :keg_only => formula.keg_only?
|
||||||
|
end
|
||||||
|
|
||||||
Pathname.glob("#{formula.bottle_prefix}/{etc,var}/**/*") do |path|
|
Pathname.glob("#{formula.bottle_prefix}/{etc,var}/**/*") do |path|
|
||||||
path.extend(InstallRenamed)
|
path.extend(InstallRenamed)
|
||||||
|
@ -99,7 +99,7 @@ class Keg
|
|||||||
|
|
||||||
def install_name_tool(*args)
|
def install_name_tool(*args)
|
||||||
tool = MacOS.install_name_tool
|
tool = MacOS.install_name_tool
|
||||||
system(tool, *args) || raise ErrorDuringExecution.new(tool, args)
|
system(tool, *args) or raise ErrorDuringExecution.new(tool, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
# If file is a dylib or bundle itself, look for the dylib named by
|
# If file is a dylib or bundle itself, look for the dylib named by
|
||||||
|
@ -52,7 +52,7 @@ module OS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_build?
|
def has_apple_developer_tools?
|
||||||
Xcode.installed? || CLT.installed?
|
Xcode.installed? || CLT.installed?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,6 +76,8 @@ module OS
|
|||||||
|
|
||||||
return "0" unless OS.mac?
|
return "0" unless OS.mac?
|
||||||
|
|
||||||
|
return nil if !MacOS::Xcode.installed? && !MacOS::CLT.installed?
|
||||||
|
|
||||||
%W[#{prefix}/usr/bin/xcodebuild #{which("xcodebuild")}].uniq.each do |path|
|
%W[#{prefix}/usr/bin/xcodebuild #{which("xcodebuild")}].uniq.each do |path|
|
||||||
if File.file? path
|
if File.file? path
|
||||||
Utils.popen_read(path, "-version") =~ /Xcode (\d(\.\d)*)/
|
Utils.popen_read(path, "-version") =~ /Xcode (\d(\.\d)*)/
|
||||||
|
@ -245,8 +245,8 @@ class Bottle
|
|||||||
@spec.compatible_cellar?
|
@spec.compatible_cellar?
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs_relocation?
|
def skip_relocation?
|
||||||
@spec.needs_relocation?
|
@spec.skip_relocation?
|
||||||
end
|
end
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
@ -274,7 +274,6 @@ class BottleSpecification
|
|||||||
@prefix = DEFAULT_PREFIX
|
@prefix = DEFAULT_PREFIX
|
||||||
@cellar = DEFAULT_CELLAR
|
@cellar = DEFAULT_CELLAR
|
||||||
@collector = BottleCollector.new
|
@collector = BottleCollector.new
|
||||||
@does_not_need_relocation = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def root_url(var = nil)
|
def root_url(var = nil)
|
||||||
@ -286,15 +285,11 @@ class BottleSpecification
|
|||||||
end
|
end
|
||||||
|
|
||||||
def compatible_cellar?
|
def compatible_cellar?
|
||||||
cellar == :any || cellar == HOMEBREW_CELLAR.to_s
|
cellar == :any || cellar == :any_skip_relocation || cellar == HOMEBREW_CELLAR.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def does_not_need_relocation
|
def skip_relocation?
|
||||||
@does_not_need_relocation = true
|
cellar == :any_skip_relocation
|
||||||
end
|
|
||||||
|
|
||||||
def needs_relocation?
|
|
||||||
!@does_not_need_relocation
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag?(tag)
|
def tag?(tag)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user