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
|
2014-12-25 20:44:43 +00:00
|
|
|
cask "xquartz"
|
|
|
|
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
|
|
|
|
# TODO: remove in https://github.com/Homebrew/brew/pull/3483
|
|
|
|
return Version::NULL unless OS.mac?
|
|
|
|
|
|
|
|
MacOS::XQuartz.minimum_version
|
|
|
|
end
|
|
|
|
|
2016-09-17 15:32:44 +01:00
|
|
|
satisfy build_env: false do
|
2017-12-03 13:33:16 +00:00
|
|
|
# TODO: remove in https://github.com/Homebrew/brew/pull/3483
|
|
|
|
next false unless OS.mac?
|
|
|
|
|
|
|
|
next false unless MacOS::XQuartz.installed?
|
|
|
|
min_version <= MacOS::XQuartz.version
|
2013-04-02 15:33:35 -05:00
|
|
|
end
|
|
|
|
|
2014-12-25 20:44:43 +00:00
|
|
|
def message
|
2017-12-03 13:33:16 +00:00
|
|
|
s = "XQuartz #{min_version} (or newer) is required to install this formula."
|
2014-12-25 20:44:43 +00:00
|
|
|
s += super
|
|
|
|
s
|
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
|