Module: OS::Mac::XQuartz Private

Defined in:
Library/Homebrew/os/mac/xquartz.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Helper module for querying XQuartz information.

Constant Summary collapse

DEFAULT_BUNDLE_PATH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Pathname.new("Applications/Utilities/XQuartz.app").freeze
FORGE_BUNDLE_ID =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"org.macosforge.xquartz.X11"
FORGE_PKG_ID =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"org.macosforge.xquartz.pkg"
PKGINFO_VERSION_MAP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  "2.6.34"  => "2.6.3",
  "2.7.4"   => "2.7.0",
  "2.7.14"  => "2.7.1",
  "2.7.28"  => "2.7.2",
  "2.7.32"  => "2.7.3",
  "2.7.43"  => "2.7.4",
  "2.7.50"  => "2.7.5_rc1",
  "2.7.51"  => "2.7.5_rc2",
  "2.7.52"  => "2.7.5_rc3",
  "2.7.53"  => "2.7.5_rc4",
  "2.7.54"  => "2.7.5",
  "2.7.61"  => "2.7.6",
  "2.7.73"  => "2.7.7",
  "2.7.86"  => "2.7.8",
  "2.7.94"  => "2.7.9",
  "2.7.108" => "2.7.10",
  "2.7.112" => "2.7.11",
}.freeze

Class Method Summary collapse

Class Method Details

.binObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


103
104
105
# File 'Library/Homebrew/os/mac/xquartz.rb', line 103

def bin
  prefix/"bin"
end

.bundle_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


66
67
68
69
70
71
72
73
# File 'Library/Homebrew/os/mac/xquartz.rb', line 66

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)
end

.detect_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


47
48
49
50
51
52
53
# File 'Library/Homebrew/os/mac/xquartz.rb', line 47

def detect_version
  if (path = bundle_path) && path.exist? && (version = version_from_mdls(path))
    version
  else
    version_from_pkgutil
  end
end

.includeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


107
108
109
# File 'Library/Homebrew/os/mac/xquartz.rb', line 107

def include
  prefix/"include"
end

.installed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

93
94
95
# File 'Library/Homebrew/os/mac/xquartz.rb', line 93

def installed?
  !version.null? && !prefix.nil?
end

.latest_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


62
63
64
# File 'Library/Homebrew/os/mac/xquartz.rb', line 62

def latest_version
  "2.7.11"
end

.libObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


111
112
113
# File 'Library/Homebrew/os/mac/xquartz.rb', line 111

def lib
  prefix/"lib"
end

.minimum_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


55
56
57
58
59
# File 'Library/Homebrew/os/mac/xquartz.rb', line 55

def minimum_version
  # Update this a little later than latest_version to give people
  # time to upgrade.
  "2.7.11"
end

.outdated?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

97
98
99
100
101
# File 'Library/Homebrew/os/mac/xquartz.rb', line 97

def outdated?
  return false unless installed?

  version < latest_version
end

.prefixObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


89
90
91
# File 'Library/Homebrew/os/mac/xquartz.rb', line 89

def prefix
  @prefix ||= Pathname.new("/opt/X11") if Pathname.new("/opt/X11/lib/libpng.dylib").exist?
end

.shareObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


115
116
117
# File 'Library/Homebrew/os/mac/xquartz.rb', line 115

def share
  prefix/"share"
end

.versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.


39
40
41
42
43
44
45
# File 'Library/Homebrew/os/mac/xquartz.rb', line 39

def version
  if @version ||= detect_version
    ::Version.new @version
  else
    ::Version::NULL
  end
end

.version_from_mdls(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


75
76
77
78
79
80
# File 'Library/Homebrew/os/mac/xquartz.rb', line 75

def version_from_mdls(path)
  version = Utils.popen_read(
    "/usr/bin/mdls", "-raw", "-nullMarker", "", "-name", "kMDItemVersion", path.to_s
  ).strip
  version unless version.empty?
end

.version_from_pkgutilObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Upstream XQuartz does have a pkg-info entry, so if we can't get it from mdls, we can try pkgutil. This is very slow.


84
85
86
87
# File 'Library/Homebrew/os/mac/xquartz.rb', line 84

def version_from_pkgutil
  str = MacOS.pkgutil_info(FORGE_PKG_ID)[/version: (\d\.\d\.\d+)$/, 1]
  PKGINFO_VERSION_MAP.fetch(str, str)
end