From 4a39070c268b6dba063b938d8663c70f60311230 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:30:41 +0000 Subject: [PATCH 1/3] xquartz: use default location when possible. Xcode can be installed anywhere but for most people it's in `/Applications/Xcode.app` so just look there by default before looking at Spotlight which can return weird results on e.g. backup disks. --- Library/Homebrew/os/mac/xquartz.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/os/mac/xquartz.rb b/Library/Homebrew/os/mac/xquartz.rb index 674e50c503..b82772faf7 100644 --- a/Library/Homebrew/os/mac/xquartz.rb +++ b/Library/Homebrew/os/mac/xquartz.rb @@ -5,6 +5,8 @@ module OS module XQuartz module_function + # TODO: confirm this path when you have internet + DEFAULT_BUNDLE_PATH = Pathname.new("Applications/Utilities/XQuartz.app").freeze FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11".freeze APPLE_BUNDLE_ID = "org.x.X11".freeze FORGE_PKG_ID = "org.macosforge.xquartz.pkg".freeze @@ -56,6 +58,11 @@ module OS end def bundle_path + # Use the default location if it exists. + return DEFAULT_BUNDLE_PATH if DEFAULT_BUNDLE_PATH.exist? + + # Ask Spotlight where XQuartz is. If the user didn't install XQuartz + # in the conventional place, this is our only option. MacOS.app_with_bundle_id(FORGE_BUNDLE_ID, APPLE_BUNDLE_ID) end From 2c6915a48fb1456b8075d95735dc2032e23ef210 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:30:20 +0000 Subject: [PATCH 2/3] xcode: general cleanup. --- Library/Homebrew/os/mac/xcode.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 8e51fc6b6d..d13c98b882 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -3,8 +3,8 @@ module OS module Xcode module_function - V4_BUNDLE_ID = "com.apple.dt.Xcode".freeze - V3_BUNDLE_ID = "com.apple.Xcode".freeze + BUNDLE_ID = "com.apple.dt.Xcode".freeze + OLD_BUNDLE_ID = "com.apple.Xcode".freeze def latest_version case MacOS.version @@ -51,9 +51,9 @@ module OS begin dir = MacOS.active_developer_dir - if dir.empty? || dir == CLT::MAVERICKS_PKG_PATH || !File.directory?(dir) + if dir.empty? || dir == CLT::PKG_PATH || !File.directory?(dir) path = bundle_path - path.join("Contents", "Developer") if path + path/"Contents/Developer" if path else # Use cleanpath to avoid pathological trailing slash Pathname.new(dir).cleanpath @@ -182,7 +182,7 @@ module OS FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI".freeze MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables".freeze MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base".freeze # obsolete - MAVERICKS_PKG_PATH = "/Library/Developer/CommandLineTools".freeze + PKG_PATH = "/Library/Developer/CommandLineTools".freeze # Returns true even if outdated tools are installed, e.g. # tools from Xcode 4.x on 10.9 @@ -237,7 +237,7 @@ module OS return false if MacOS.version < :lion if MacOS.version >= :mavericks - version = Utils.popen_read("#{MAVERICKS_PKG_PATH}/usr/bin/clang --version") + version = Utils.popen_read("#{PKG_PATH}/usr/bin/clang --version") else version = Utils.popen_read("/usr/bin/clang --version") end @@ -261,7 +261,7 @@ module OS [MAVERICKS_PKG_ID, MAVERICKS_NEW_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].find do |id| if MacOS.version >= :mavericks - next unless File.exist?("#{MAVERICKS_PKG_PATH}/usr/bin/clang") + next unless File.exist?("#{PKG_PATH}/usr/bin/clang") end version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1] return version if version From a17f38dd364af67d5965aaa58438cb768c6d057a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:30:32 +0000 Subject: [PATCH 3/3] xcode: use default location when possible. Xcode can be installed anywhere but for most people it's in `/Applications/Xcode.app` so just look there if `xcode-select` isn't helpful before looking at Spotlight which can return weird results on e.g. backup disks. Fixes #1587. --- Library/Homebrew/os/mac/xcode.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index d13c98b882..e85f21c631 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -3,6 +3,7 @@ module OS module Xcode module_function + DEFAULT_BUNDLE_PATH = Pathname.new("/Applications/Xcode.app").freeze BUNDLE_ID = "com.apple.dt.Xcode".freeze OLD_BUNDLE_ID = "com.apple.Xcode".freeze @@ -67,11 +68,14 @@ module OS Pathname.new("#{prefix}/Toolchains/XcodeDefault.xctoolchain") end - # Ask Spotlight where Xcode is. If the user didn't install the - # helper tools and installed Xcode in a non-conventional place, this - # is our only option. See: https://superuser.com/questions/390757 def bundle_path - MacOS.app_with_bundle_id(V4_BUNDLE_ID, V3_BUNDLE_ID) + # Use the default location if it exists. + return DEFAULT_BUNDLE_PATH if DEFAULT_BUNDLE_PATH.exist? + + # Ask Spotlight where Xcode is. If the user didn't install the + # helper tools and installed Xcode in a non-conventional place, this + # is our only option. See: https://superuser.com/questions/390757 + MacOS.app_with_bundle_id(BUNDLE_ID, OLD_BUNDLE_ID) end def installed?