| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | require "hbc/artifact/base" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  | module Hbc | 
					
						
							|  |  |  |   module Artifact | 
					
						
							|  |  |  |     class Installer < Base | 
					
						
							|  |  |  |       # TODO: for backward compatibility, removeme | 
					
						
							|  |  |  |       def install | 
					
						
							|  |  |  |         install_phase | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       # TODO: for backward compatibility, removeme | 
					
						
							|  |  |  |       def uninstall | 
					
						
							|  |  |  |         uninstall_phase | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def install_phase | 
					
						
							|  |  |  |         @cask.artifacts[self.class.artifact_dsl_key].each do |artifact| | 
					
						
							|  |  |  |           if artifact.manual | 
					
						
							|  |  |  |             puts <<-EOS.undent
 | 
					
						
							|  |  |  |               To complete the installation of Cask #{@cask}, you must also | 
					
						
							|  |  |  |               run the installer at | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |                 '#{@cask.staged_path.join(artifact.manual)}' | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |             EOS | 
					
						
							|  |  |  |           else | 
					
						
							|  |  |  |             executable, script_arguments = self.class.read_script_arguments(artifact.script, | 
					
						
							|  |  |  |                                                                             self.class.artifact_dsl_key.to_s, | 
					
						
							|  |  |  |                                                                             { must_succeed: true, sudo: true }, | 
					
						
							|  |  |  |                                                                             print_stdout: true) | 
					
						
							|  |  |  |             ohai "Running #{self.class.artifact_dsl_key} script #{executable}" | 
					
						
							|  |  |  |             raise CaskInvalidError.new(@cask, "#{self.class.artifact_dsl_key} missing executable") if executable.nil? | 
					
						
							|  |  |  |             executable_path = @cask.staged_path.join(executable) | 
					
						
							|  |  |  |             @command.run("/bin/chmod", args: ["--", "+x", executable_path]) if File.exist?(executable_path) | 
					
						
							|  |  |  |             @command.run(executable_path, script_arguments) | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |       def uninstall_phase | 
					
						
							|  |  |  |         odebug "Nothing to do. The #{self.class.artifact_dsl_key} artifact has no uninstall phase." | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |