From 91e598cf3f88591f2146218eaa2ecc2a3a261e31 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Mon, 29 Jun 2015 14:09:57 -0400 Subject: Install: add BuildToolsError and BuildFlagsError Add these new errors, and guards in formula installation and cmd/{,un,re}install to match, move can_build? to the MacOS module, flatten conditions, remove redundant can_build? check reinstate removed (doctor) check --- Library/Homebrew/cmd/install.rb | 18 ++++++++++++------ Library/Homebrew/cmd/reinstall.rb | 8 ++++++++ Library/Homebrew/cmd/upgrade.rb | 8 ++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 1ef1ca61a..ce9bf5291 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -38,6 +38,14 @@ module Homebrew end end + # if the user's flags will prevent bottle only-installations when no + # developer tools are available, we need to stop them early on + if !MacOS.can_build? + bf = ARGV.collect_build_flags + + raise BuildFlagsError.new(bf) if !bf.empty? + end + ARGV.formulae.each do |f| # head-only without --HEAD is an error if !ARGV.build_head? && f.stable.nil? && f.devel.nil? @@ -129,6 +137,9 @@ module Homebrew # when one is no longer required checks = Checks.new %w[ + check_for_unsupported_osx + check_for_bad_install_name_tool + check_for_installed_developer_tools check_xcode_license_approved check_for_osx_gcc_installer ].each do |check| @@ -157,12 +168,7 @@ module Homebrew def perform_preinstall_checks check_ppc check_writable_install_location - if MacOS::Xcode.installed? - check_xcode - else - opoo "You have not installed Xcode." - puts "Bottles may install correctly, but builds will fail!" - end + check_xcode if MacOS::Xcode.installed? check_cellar end diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index bf49282ae..98941698a 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -2,6 +2,14 @@ require "formula_installer" module Homebrew def reinstall + if !MacOS.can_build? + bf = ARGV.collect_build_flags + + if !bf.empty? + raise BuildFlagsError.new(bf) + end + end + ARGV.resolved_formulae.each { |f| reinstall_formula(f) } end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 8ae231002..e8fc9c0f8 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -3,6 +3,14 @@ require "cmd/outdated" module Homebrew def upgrade + if !MacOS.can_build? + bf = ARGV.collect_build_flags + + if !bf.empty? + raise BuildFlagsError.new(bf) + end + end + Homebrew.perform_preinstall_checks if ARGV.named.empty? -- cgit v1.2.3