brew/Library/Homebrew/requirements/x11_requirement.rb

64 lines
1.3 KiB
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
require "requirement"
2013-04-02 15:33:35 -05:00
2020-08-19 06:51:40 +02:00
# A requirement on X11.
#
# @api private
class X11Requirement < Requirement
2020-10-20 12:03:48 +02:00
extend T::Sig
2013-04-02 15:33:35 -05:00
include Comparable
fatal true
cask "xquartz"
download "https://xquartz.macosforge.org"
2013-04-02 15:33:35 -05:00
env { ENV.x11 }
2020-10-20 12:03:48 +02:00
sig { returns(String) }
def min_version
"1.12.2"
end
2020-10-20 12:03:48 +02:00
sig { returns(String) }
def min_xdpyinfo_version
"1.3.0"
end
satisfy build_env: false do
if which_xorg = which("Xorg")
version = Utils.popen_read(which_xorg, "-version", err: :out)[/X Server (\d+\.\d+\.\d+)/, 1]
next true if $CHILD_STATUS.success? && version && Version.new(version) >= min_version
end
if which_xdpyinfo = which("xdpyinfo")
version = Utils.popen_read(which_xdpyinfo, "-version")[/^xdpyinfo (\d+\.\d+\.\d+)/, 1]
next true if $CHILD_STATUS.success? && version && Version.new(version) >= min_xdpyinfo_version
end
false
2013-04-02 15:33:35 -05:00
end
2020-10-20 12:03:48 +02:00
sig { returns(String) }
def message
"X11 is required for this software, either Xorg #{min_version} or " \
"xdpyinfo #{min_xdpyinfo_version}, or newer. #{super}"
2013-04-02 15:33:35 -05:00
end
def <=>(other)
return unless other.is_a? X11Requirement
2018-09-17 02:45:00 +02:00
0
end
2020-10-20 12:03:48 +02:00
sig { returns(String) }
def inspect
"#<#{self.class.name}: #{tags.inspect}>"
end
2013-04-02 15:33:35 -05:00
end
require "extend/os/requirements/x11_requirement"