diff --git a/Library/Homebrew/cmd/config.rb b/Library/Homebrew/cmd/config.rb index 7627d6e970..74b4f436e2 100644 --- a/Library/Homebrew/cmd/config.rb +++ b/Library/Homebrew/cmd/config.rb @@ -7,23 +7,23 @@ module Homebrew end def llvm - @llvm ||= MacOS.llvm_build_version + @llvm ||= MacOS.llvm_build_version if MacOS.has_apple_developer_tools? end def gcc_42 - @gcc_42 ||= MacOS.gcc_42_build_version + @gcc_42 ||= MacOS.gcc_42_build_version if MacOS.has_apple_developer_tools? end def gcc_40 - @gcc_40 ||= MacOS.gcc_40_build_version + @gcc_40 ||= MacOS.gcc_40_build_version if MacOS.has_apple_developer_tools? end def clang - @clang ||= MacOS.clang_version + @clang ||= MacOS.clang_version if MacOS.has_apple_developer_tools? end def clang_build - @clang_build ||= MacOS.clang_build_version + @clang_build ||= MacOS.clang_build_version if MacOS.has_apple_developer_tools? end def xcode diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index f41450be1e..41628b4352 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -40,7 +40,7 @@ module Homebrew # if the user's flags will prevent bottle only-installations when no # 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| # head-only without --HEAD is an error @@ -126,11 +126,6 @@ module Homebrew end 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 %w[ check_for_unsupported_osx diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 4de1ad9c2d..3c6f9ac20f 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -2,7 +2,7 @@ require "formula_installer" module Homebrew 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) } end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 9bb5d46ada..fb122a6595 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -3,7 +3,7 @@ require "cmd/outdated" module Homebrew def upgrade - FormulaInstaller.prevent_build_flags unless MacOS.can_build? + FormulaInstaller.prevent_build_flags unless MacOS.has_apple_developer_tools? Homebrew.perform_preinstall_checks diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 6798e6cd33..d05ccf1a38 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -29,7 +29,7 @@ module Stdenv self["PKG_CONFIG_LIBDIR"] = determine_pkg_config_libdir # 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}" diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 9116029194..bcfcd2f0f8 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -23,6 +23,8 @@ module Superenv end 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.realpath unless bin.nil? end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 87746eada7..915db64bbf 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -720,7 +720,11 @@ class Formula end 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 diff = Utils.popen_read("git", "diff", "origin/master", "--", "#{path}") !diff.empty? && $?.exitstatus == 0 diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index cb2b4923b6..99d6c786a5 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -154,7 +154,7 @@ class FormulaInstaller check_conflicts - if !pour_bottle? && !MacOS.can_build? + if !pour_bottle? && !MacOS.has_apple_developer_tools? raise BuildToolsError.new([formula]) end @@ -182,7 +182,7 @@ class FormulaInstaller if pour_bottle?(:warn => true) begin - install_relocation_tools if formula.bottle.needs_relocation? + install_relocation_tools unless formula.bottle.skip_relocation? pour rescue => e raise if ARGV.homebrew_developer? @@ -243,7 +243,7 @@ class FormulaInstaller def check_dependencies_bottled(deps) unbottled = deps.select do |dep, _| formula = dep.to_formula - !formula.pour_bottle? && !MacOS.can_build? + !formula.pour_bottle? && !MacOS.has_apple_developer_tools? end raise BuildToolsError.new(unbottled) unless unbottled.empty? @@ -434,9 +434,7 @@ class FormulaInstaller keg = Keg.new(formula.prefix) link(keg) - # this needs to be changed to a test against build_bottle? and - # formula.bottle.needs_relocation? - fix_install_names(keg) unless formula.name == 'cctools' + fix_install_names(keg) unless @poured_bottle && formula.bottle.skip_relocation? if build_bottle? && formula.post_install_defined? ohai "Not running post_install as we're building a bottle" @@ -668,8 +666,10 @@ class FormulaInstaller end keg = Keg.new(formula.prefix) - keg.relocate_install_names Keg::PREFIX_PLACEHOLDER, HOMEBREW_PREFIX.to_s, - Keg::CELLAR_PLACEHOLDER, HOMEBREW_CELLAR.to_s, :keg_only => formula.keg_only? + unless formula.bottle.skip_relocation? + keg.relocate_install_names Keg::PREFIX_PLACEHOLDER, HOMEBREW_PREFIX.to_s, + Keg::CELLAR_PLACEHOLDER, HOMEBREW_CELLAR.to_s, :keg_only => formula.keg_only? + end Pathname.glob("#{formula.bottle_prefix}/{etc,var}/**/*") do |path| path.extend(InstallRenamed) diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 59ff1c9d7c..05d19db4d6 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -99,7 +99,7 @@ class Keg def install_name_tool(*args) tool = MacOS.install_name_tool - system(tool, *args) || raise ErrorDuringExecution.new(tool, args) + system(tool, *args) or raise ErrorDuringExecution.new(tool, args) end # If file is a dylib or bundle itself, look for the dylib named by diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index 4e69a60356..814ef70a2c 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -52,7 +52,7 @@ module OS end end - def can_build? + def has_apple_developer_tools? Xcode.installed? || CLT.installed? end diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 83ba84ff8c..40446a8ad5 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -76,6 +76,8 @@ module OS 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| if File.file? path Utils.popen_read(path, "-version") =~ /Xcode (\d(\.\d)*)/ diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 8f1e14c09f..edc5f7645c 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -245,8 +245,8 @@ class Bottle @spec.compatible_cellar? end - def needs_relocation? - @spec.needs_relocation? + def skip_relocation? + @spec.skip_relocation? end def stage @@ -274,7 +274,6 @@ class BottleSpecification @prefix = DEFAULT_PREFIX @cellar = DEFAULT_CELLAR @collector = BottleCollector.new - @does_not_need_relocation = false end def root_url(var = nil) @@ -286,15 +285,11 @@ class BottleSpecification end def compatible_cellar? - cellar == :any || cellar == HOMEBREW_CELLAR.to_s + cellar == :any || cellar == :any_skip_relocation || cellar == HOMEBREW_CELLAR.to_s end - def does_not_need_relocation - @does_not_need_relocation = true - end - - def needs_relocation? - !@does_not_need_relocation + def skip_relocation? + cellar == :any_skip_relocation end def tag?(tag)