| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:50:57 -05:00
										 |  |  | require "requirement" | 
					
						
							| 
									
										
										
										
											2013-04-02 15:33:35 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 06:51:40 +02:00
										 |  |  | # A requirement on X11. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # @api private | 
					
						
							| 
									
										
										
										
											2015-06-15 09:56:04 +01:00
										 |  |  | class X11Requirement < Requirement | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   extend T::Sig | 
					
						
							| 
									
										
										
										
											2013-04-02 15:33:35 -05:00
										 |  |  |   include Comparable | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-15 14:19:45 +00:00
										 |  |  |   def initialize(tags = []) | 
					
						
							|  |  |  |     odeprecated "depends_on :x11", "depends_on specific X11 formula(e)" | 
					
						
							|  |  |  |     super(tags) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-02 15:33:35 -05:00
										 |  |  |   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" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   sig { returns(String) } | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   sig { returns(String) } | 
					
						
							| 
									
										
										
										
											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") | 
					
						
							| 
									
										
										
										
											2018-08-14 12:08:41 -07:00
										 |  |  |       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 | 
					
						
							| 
									
										
										
										
											2017-12-07 08:44:20 -08:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-08-14 12:08:41 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     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) } | 
					
						
							| 
									
										
										
										
											2014-12-25 20:44:43 +00:00
										 |  |  |   def message | 
					
						
							| 
									
										
										
										
											2020-11-01 12:26:18 -05:00
										 |  |  |     "X11 is required for this software, either Xorg #{min_version} or " \ | 
					
						
							| 
									
										
										
										
											2018-09-02 16:15:09 +01:00
										 |  |  |     "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 | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-03 13:33:16 +00:00
										 |  |  |     0
 | 
					
						
							| 
									
										
										
										
											2014-07-01 21:26:41 -05:00
										 |  |  |   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 | 
					
						
							| 
									
										
										
										
											2017-12-07 08:44:20 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | require "extend/os/requirements/x11_requirement" |