| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | require "tmpdir" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  | module Hbc | 
					
						
							|  |  |  |   class Container | 
					
						
							|  |  |  |     class Xip < Base | 
					
						
							|  |  |  |       def self.me?(criteria) | 
					
						
							|  |  |  |         criteria.magic_number(%r{^xar!}n) && | 
					
						
							|  |  |  |           IO.popen(["/usr/bin/xar", "-t", "-f", criteria.path.to_s], err: "/dev/null") { |io| io.read =~ %r{\AContent\nMetadata\n\Z} } | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def extract | 
					
						
							|  |  |  |         Dir.mktmpdir do |unpack_dir| | 
					
						
							|  |  |  |           begin | 
					
						
							|  |  |  |             ohai "Verifying signature for #{@path.basename}" | 
					
						
							|  |  |  |             @command.run!("/usr/sbin/pkgutil", args: ["--check-signature", @path]) | 
					
						
							|  |  |  |           rescue | 
					
						
							|  |  |  |             raise "Signature check failed." | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           @command.run!("/usr/bin/xar", args: ["-x", "-f", @path, "Content", "-C", unpack_dir]) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |           Dir.chdir(@cask.staged_path) do | 
					
						
							|  |  |  |             @command.run!("/usr/bin/cpio", args: ["--quiet", "-i", "-I", Pathname(unpack_dir).join("Content")]) | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |