2012-07-25 15:04:46 -05:00
|
|
|
module MacOS::XQuartz extend self
|
|
|
|
FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11"
|
|
|
|
APPLE_BUNDLE_ID = "org.x.X11"
|
2012-12-22 14:24:25 -06:00
|
|
|
FORGE_PKG_ID = "org.macosforge.xquartz.pkg"
|
2012-07-25 15:04:46 -05:00
|
|
|
|
|
|
|
# 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
|
|
|
|
# by this method.
|
|
|
|
def version
|
2012-12-21 12:55:38 -06:00
|
|
|
@version ||= begin
|
|
|
|
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
|
2013-01-02 22:54:36 -06:00
|
|
|
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
|
2012-12-22 14:24:25 -06:00
|
|
|
else
|
2013-01-02 22:54:36 -06:00
|
|
|
# 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.
|
2012-12-22 14:24:25 -06:00
|
|
|
MacOS.pkgutil_info(FORGE_PKG_ID) =~ /version: (\d\.\d\.\d).+$/ and $1
|
2012-12-21 12:55:38 -06:00
|
|
|
end
|
2012-07-25 15:04:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-11 11:54:03 -08:00
|
|
|
def latest_version
|
|
|
|
"2.7.4"
|
|
|
|
end
|
|
|
|
|
2012-11-12 19:42:26 -06:00
|
|
|
def provided_by_apple?
|
|
|
|
[FORGE_BUNDLE_ID, APPLE_BUNDLE_ID].find do |id|
|
|
|
|
MacOS.app_with_bundle_id(id)
|
|
|
|
end == APPLE_BUNDLE_ID
|
|
|
|
end
|
|
|
|
|
2012-07-25 15:04:46 -05:00
|
|
|
# This should really be private, but for compatibility reasons it must
|
|
|
|
# remain public. New code should use MacOS::XQuartz.{bin,lib,include}
|
|
|
|
# instead, as that accounts for Xcode-only systems.
|
|
|
|
def prefix
|
|
|
|
@prefix ||= if Pathname.new('/opt/X11/lib/libpng.dylib').exist?
|
|
|
|
Pathname.new('/opt/X11')
|
|
|
|
elsif Pathname.new('/usr/X11/lib/libpng.dylib').exist?
|
|
|
|
Pathname.new('/usr/X11')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def installed?
|
2012-12-21 12:55:38 -06:00
|
|
|
!version.nil? && !prefix.nil?
|
2012-07-25 15:04:46 -05:00
|
|
|
end
|
2012-08-06 00:33:36 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
module MacOS::X11 extend self
|
|
|
|
def prefix
|
|
|
|
MacOS::XQuartz.prefix
|
|
|
|
end
|
|
|
|
|
|
|
|
def installed?
|
|
|
|
MacOS::XQuartz.installed?
|
|
|
|
end
|
2012-07-25 15:04:46 -05:00
|
|
|
|
|
|
|
# If XQuartz and/or the CLT are installed, headers will be found under
|
|
|
|
# /opt/X11/include or /usr/X11/include. For Xcode-only systems, they are
|
|
|
|
# found in the SDK, so we use sdk_path for both the headers and libraries.
|
|
|
|
# Confusingly, executables (e.g. config scripts) are only found under
|
|
|
|
# /opt/X11/bin or /usr/X11/bin in all cases.
|
|
|
|
def bin
|
|
|
|
prefix/'bin'
|
|
|
|
end
|
|
|
|
|
|
|
|
def include
|
|
|
|
@include ||= if use_sdk?
|
|
|
|
MacOS.sdk_path/'usr/X11/include'
|
|
|
|
else
|
|
|
|
prefix/'include'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def lib
|
|
|
|
@lib ||= if use_sdk?
|
|
|
|
MacOS.sdk_path/'usr/X11/lib'
|
|
|
|
else
|
|
|
|
prefix/'lib'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def share
|
|
|
|
prefix/'share'
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def use_sdk?
|
|
|
|
not (prefix.to_s == '/opt/X11' or MacOS::CLT.installed?)
|
|
|
|
end
|
|
|
|
end
|