Try to find XQuartz via pkgutil if mdls fails

c.f. Homebrew/homebrew#16296.
This commit is contained in:
Jack Nagel 2012-12-22 14:24:25 -06:00
parent d2d4813a07
commit a56a0dadad

View File

@ -1,6 +1,7 @@
module MacOS::XQuartz extend self
FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11"
APPLE_BUNDLE_ID = "org.x.X11"
FORGE_PKG_ID = "org.macosforge.xquartz.pkg"
# This returns the version number of XQuartz, not of the upstream X.org.
# The X11.app distributed by Apple is also XQuartz, and therefore covered
@ -10,6 +11,9 @@ 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
else
# Some users disable Spotlight indexing. Try to find it via pkgutil
MacOS.pkgutil_info(FORGE_PKG_ID) =~ /version: (\d\.\d\.\d).+$/ and $1
end
end
end