| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 09:42:43 -08:00
										 |  |  | require "requirement" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class OsxfuseRequirement < Requirement | 
					
						
							|  |  |  |   download "https://github.com/libfuse/libfuse" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   satisfy(build_env: false) do | 
					
						
							| 
									
										
										
										
											2019-12-03 11:42:09 +00:00
										 |  |  |     next true if libfuse_formula_exists? && Formula["libfuse"].latest_version_installed? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 09:42:43 -08:00
										 |  |  |     includedirs = %w[
 | 
					
						
							|  |  |  |       /usr/include | 
					
						
							|  |  |  |       /usr/local/include | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  |     next true if (includedirs.map do |dir| | 
					
						
							|  |  |  |       File.exist? "#{dir}/fuse.h" | 
					
						
							|  |  |  |     end).any? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 09:42:43 -08:00
										 |  |  |     false | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def message | 
					
						
							|  |  |  |     msg = "libfuse is required to install this formula.\n" | 
					
						
							|  |  |  |     if libfuse_formula_exists? | 
					
						
							| 
									
										
										
										
											2020-08-19 17:12:32 +01:00
										 |  |  |       <<~EOS | 
					
						
							|  |  |  |         #{msg}Run `brew install libfuse` to install it. | 
					
						
							| 
									
										
										
										
											2017-02-20 09:42:43 -08:00
										 |  |  |       EOS | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       msg + super | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   private | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def libfuse_formula_exists? | 
					
						
							|  |  |  |     begin | 
					
						
							|  |  |  |       Formula["libfuse"] | 
					
						
							|  |  |  |     rescue FormulaUnavailableError | 
					
						
							|  |  |  |       return false | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     true | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |