Guess system XQuartz version when mdfind fails

Fixes Homebrew/homebrew#16857.
This commit is contained in:
Jack Nagel 2013-01-02 22:54:36 -06:00
parent 05f29e7463
commit 7a4facae2f

View File

@ -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