Merge pull request #3483 from sjackman/x11
Implement X11Requirement for Linux
This commit is contained in:
commit
5055c31a86
@ -0,0 +1,42 @@
|
|||||||
|
require "requirement"
|
||||||
|
|
||||||
|
class XQuartzRequirement < Requirement
|
||||||
|
include Comparable
|
||||||
|
|
||||||
|
fatal true
|
||||||
|
cask "xquartz"
|
||||||
|
download "https://xquartz.macosforge.org"
|
||||||
|
|
||||||
|
env { ENV.x11 }
|
||||||
|
|
||||||
|
def initialize(name = "x11", tags = [])
|
||||||
|
@name = name
|
||||||
|
# no-op on version specified as a tag argument
|
||||||
|
tags.shift if /(\d\.)+\d/ =~ tags.first
|
||||||
|
super(tags)
|
||||||
|
end
|
||||||
|
|
||||||
|
def min_version
|
||||||
|
MacOS::XQuartz.minimum_version
|
||||||
|
end
|
||||||
|
|
||||||
|
satisfy build_env: false do
|
||||||
|
next false unless MacOS::XQuartz.installed?
|
||||||
|
min_version <= MacOS::XQuartz.version
|
||||||
|
end
|
||||||
|
|
||||||
|
def message
|
||||||
|
"XQuartz #{min_version} (or newer) is required to install this formula. #{super}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def <=>(other)
|
||||||
|
return unless other.is_a? X11Requirement
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
def inspect
|
||||||
|
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
X11Requirement = XQuartzRequirement
|
@ -0,0 +1 @@
|
|||||||
|
require "extend/os/mac/requirements/x11_requirement" if OS.mac?
|
@ -4,8 +4,6 @@ class X11Requirement < Requirement
|
|||||||
include Comparable
|
include Comparable
|
||||||
|
|
||||||
fatal true
|
fatal true
|
||||||
cask "xquartz"
|
|
||||||
download "https://xquartz.macosforge.org"
|
|
||||||
|
|
||||||
env { ENV.x11 }
|
env { ENV.x11 }
|
||||||
|
|
||||||
@ -17,24 +15,33 @@ class X11Requirement < Requirement
|
|||||||
end
|
end
|
||||||
|
|
||||||
def min_version
|
def min_version
|
||||||
# TODO: remove in https://github.com/Homebrew/brew/pull/3483
|
"1.12.2"
|
||||||
return Version::NULL unless OS.mac?
|
end
|
||||||
|
|
||||||
MacOS::XQuartz.minimum_version
|
def min_xdpyinfo_version
|
||||||
|
"1.3.0"
|
||||||
end
|
end
|
||||||
|
|
||||||
satisfy build_env: false do
|
satisfy build_env: false do
|
||||||
# TODO: remove in https://github.com/Homebrew/brew/pull/3483
|
if which_xorg = which("Xorg")
|
||||||
next false unless OS.mac?
|
version = Utils.popen_read which_xorg, "-version", err: :out
|
||||||
|
next false unless $CHILD_STATUS.success?
|
||||||
next false unless MacOS::XQuartz.installed?
|
version = version[/X Server (\d+\.\d+\.\d+)/, 1]
|
||||||
min_version <= MacOS::XQuartz.version
|
next false unless version
|
||||||
|
Version.new(version) >= min_version
|
||||||
|
elsif which_xdpyinfo = which("xdpyinfo")
|
||||||
|
version = Utils.popen_read which_xdpyinfo, "-version"
|
||||||
|
next false unless $CHILD_STATUS.success?
|
||||||
|
version = version[/^xdpyinfo (\d+\.\d+\.\d+)/, 1]
|
||||||
|
next false unless version
|
||||||
|
Version.new(version) >= min_xdpyinfo_version
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def message
|
def message
|
||||||
s = "XQuartz #{min_version} (or newer) is required to install this formula."
|
"X11 is required to install this formula, either Xorg #{min_version} or xdpyinfo #{min_xdpyinfo_version}, or newer. #{super}"
|
||||||
s += super
|
|
||||||
s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
@ -46,3 +53,5 @@ class X11Requirement < Requirement
|
|||||||
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>"
|
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "extend/os/requirements/x11_requirement"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user