Module: OS::Mac::XQuartz Private

Extended by:
T::Sig
Defined in:
os/mac/xquartz.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper module for querying XQuartz information.

Constant Summary collapse

DEFAULT_BUNDLE_PATH =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

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

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

"org.macosforge.xquartz.X11"
FORGE_PKG_ID =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

"org.macosforge.xquartz.pkg"
PKGINFO_VERSION_MAP =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

{
  "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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



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

def bin
  prefix/"bin"
end

.bundle_pathObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



70
71
72
73
74
75
76
77
# File 'os/mac/xquartz.rb', line 70

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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



49
50
51
52
53
54
55
# File 'os/mac/xquartz.rb', line 49

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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



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

def include
  prefix/"include"
end

.installed?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


97
98
99
# File 'os/mac/xquartz.rb', line 97

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

.latest_versionString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



66
67
68
# File 'os/mac/xquartz.rb', line 66

def latest_version
  "2.7.11"
end

.libObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



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

def lib
  prefix/"lib"
end

.minimum_versionString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



58
59
60
61
62
# File 'os/mac/xquartz.rb', line 58

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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


101
102
103
104
105
# File 'os/mac/xquartz.rb', line 101

def outdated?
  return false unless installed?

  version < latest_version
end

.prefixObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



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

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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



119
120
121
# File 'os/mac/xquartz.rb', line 119

def share
  prefix/"share"
end

.versionObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

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.



41
42
43
44
45
46
47
# File 'os/mac/xquartz.rb', line 41

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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



79
80
81
82
83
84
# File 'os/mac/xquartz.rb', line 79

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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

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.



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

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