From 7a4facae2fc4468e2bc80c847ede1e51a1ed6230 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 2 Jan 2013 22:54:36 -0600 Subject: [PATCH] Guess system XQuartz version when mdfind fails Fixes Homebrew/homebrew#16857. --- Library/Homebrew/macos/xquartz.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/macos/xquartz.rb b/Library/Homebrew/macos/xquartz.rb index 07a5c3d3d0..77b75f358b 100644 --- a/Library/Homebrew/macos/xquartz.rb +++ b/Library/Homebrew/macos/xquartz.rb @@ -11,8 +11,19 @@ module MacOS::XQuartz extend self path = MacOS.app_with_bundle_id(FORGE_BUNDLE_ID) || MacOS.app_with_bundle_id(APPLE_BUNDLE_ID) if not path.nil? and path.exist? `mdls -raw -name kMDItemVersion "#{path}" 2>/dev/null`.strip + elsif prefix.to_s == "/usr/X11" + # Some users disable Spotlight indexing. If we're working with the + # system X11 distribution, we can't get the version from pkgutil, so + # just use the expected version. + case MacOS.version + when 10.5 then "2.1.6" + when 10.6 then "2.3.6" + when 10.7 then "2.6.3" + else :dunno + end else - # Some users disable Spotlight indexing. Try to find it via pkgutil + # Finally, try to find it via pkgutil. This is slow, and only works + # for the upstream XQuartz package, so use it as a last resort. MacOS.pkgutil_info(FORGE_PKG_ID) =~ /version: (\d\.\d\.\d).+$/ and $1 end end