| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 06:50:46 +02:00
										 |  |  | # A requirement on a code-signing identity. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # @api private | 
					
						
							| 
									
										
										
										
											2018-10-19 16:38:41 +01:00
										 |  |  | class CodesignRequirement < Requirement | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   extend T::Sig | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-19 16:38:41 +01:00
										 |  |  |   fatal true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def initialize(tags) | 
					
						
							|  |  |  |     options = tags.shift | 
					
						
							| 
									
										
										
										
											2019-02-19 13:11:32 +00:00
										 |  |  |     raise ArgumentError("CodesignRequirement requires an options Hash!") unless options.is_a?(Hash) | 
					
						
							|  |  |  |     raise ArgumentError("CodesignRequirement requires an identity key!") unless options.key?(:identity) | 
					
						
							| 
									
										
										
										
											2018-10-19 16:38:41 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     @identity = options.fetch(:identity) | 
					
						
							|  |  |  |     @with = options.fetch(:with, "code signing") | 
					
						
							|  |  |  |     @url = options.fetch(:url, nil) | 
					
						
							|  |  |  |     super(tags) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   satisfy(build_env: false) do | 
					
						
							|  |  |  |     mktemp do | 
					
						
							|  |  |  |       FileUtils.cp "/usr/bin/false", "codesign_check" | 
					
						
							|  |  |  |       quiet_system "/usr/bin/codesign", "-f", "-s", @identity, | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |                    "--dryrun", "codesign_check" | 
					
						
							| 
									
										
										
										
											2018-10-19 16:38:41 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   sig { returns(String) } | 
					
						
							| 
									
										
										
										
											2018-10-19 16:38:41 +01:00
										 |  |  |   def message | 
					
						
							|  |  |  |     message = "#{@identity} identity must be available to build with #{@with}" | 
					
						
							|  |  |  |     message += ":\n#{@url}" if @url.present? | 
					
						
							|  |  |  |     message | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |