2014-07-03 14:50:57 -05:00
|
|
|
require "requirement"
|
2013-04-02 15:33:35 -05:00
|
|
|
|
2015-06-15 09:56:04 +01:00
|
|
|
class X11Requirement < Requirement
|
2013-04-02 15:33:35 -05:00
|
|
|
include Comparable
|
|
|
|
|
|
|
|
fatal true
|
|
|
|
|
2018-04-18 09:55:44 +01:00
|
|
|
cask "xquartz"
|
2018-04-18 11:18:29 +01:00
|
|
|
download "https://xquartz.macosforge.org"
|
|
|
|
|
2013-04-02 15:33:35 -05:00
|
|
|
env { ENV.x11 }
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def initialize(name = "x11", tags = [])
|
2013-04-02 15:33:35 -05:00
|
|
|
@name = name
|
2017-12-03 13:33:16 +00:00
|
|
|
# no-op on version specified as a tag argument
|
|
|
|
tags.shift if /(\d\.)+\d/ =~ tags.first
|
2013-04-02 15:33:35 -05:00
|
|
|
super(tags)
|
|
|
|
end
|
|
|
|
|
2017-12-03 13:33:16 +00:00
|
|
|
def min_version
|
2017-12-07 08:44:20 -08:00
|
|
|
"1.12.2"
|
|
|
|
end
|
2017-12-03 13:33:16 +00:00
|
|
|
|
2017-12-07 08:44:20 -08:00
|
|
|
def min_xdpyinfo_version
|
|
|
|
"1.3.0"
|
2017-12-03 13:33:16 +00:00
|
|
|
end
|
|
|
|
|
2016-09-17 15:32:44 +01:00
|
|
|
satisfy build_env: false do
|
2017-12-07 08:44:20 -08:00
|
|
|
if which_xorg = which("Xorg")
|
|
|
|
version = Utils.popen_read which_xorg, "-version", err: :out
|
|
|
|
next false unless $CHILD_STATUS.success?
|
|
|
|
version = version[/X Server (\d+\.\d+\.\d+)/, 1]
|
|
|
|
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
|
2013-04-02 15:33:35 -05:00
|
|
|
end
|
|
|
|
|
2014-12-25 20:44:43 +00:00
|
|
|
def message
|
2017-12-07 08:44:20 -08:00
|
|
|
"X11 is required to install this formula, either Xorg #{min_version} or xdpyinfo #{min_xdpyinfo_version}, or newer. #{super}"
|
2013-04-02 15:33:35 -05:00
|
|
|
end
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def <=>(other)
|
2016-09-11 17:42:44 +01:00
|
|
|
return unless other.is_a? X11Requirement
|
2017-12-03 13:33:16 +00:00
|
|
|
0
|
2014-07-01 21:26:41 -05:00
|
|
|
end
|
2014-07-02 15:44:54 -05:00
|
|
|
|
|
|
|
def inspect
|
2017-12-03 13:33:16 +00:00
|
|
|
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>"
|
2014-07-02 15:44:54 -05:00
|
|
|
end
|
2013-04-02 15:33:35 -05:00
|
|
|
end
|
2017-12-07 08:44:20 -08:00
|
|
|
|
|
|
|
require "extend/os/requirements/x11_requirement"
|