lib/kameleon/engine.rb in kameleon-builder-2.1.0 vs lib/kameleon/engine.rb in kameleon-builder-2.1.1

- old
+ new

@@ -3,11 +3,14 @@ require 'kameleon/persistent_cache' module Kameleon class Engine - attr_accessor :recipe, :cwd, :build_recipe_path, :pretty_list_checkpoints + attr_accessor :recipe + attr_accessor :cwd + attr_accessor :build_recipe_path + attr_accessor :pretty_list_checkpoints def initialize(recipe, options) @options = options @logger = Log4r::Logger.new("kameleon::[kameleon]") @recipe = recipe @@ -248,13 +251,13 @@ @logger.notice("Getting back to Kameleon...") elsif answer.eql? "a" raise AbortError, "Execution aborted..." elsif answer.eql? "c" ## resetting the exit status - @in_context.execute("true") - @out_context.execute("true") - @local_context.execute("true") + @in_context.execute("true") unless @in_context.closed? + @out_context.execute("true") unless @out_context.closed? + @local_context.execute("true") unless @local_context.closed? return true elsif answer.eql? "r" @logger.notice("Retrying the previous command...") return false end @@ -329,27 +332,26 @@ begin ["bootstrap", "setup", "export"].each do |section| do_steps(section) end clean - rescue AbortError => e - @logger.error("Aborted...") + rescue Exception => e + if e.is_a?(AbortError) + @logger.error("Aborted...") + elsif e.is_a?(SystemExit) || e.is_a?(Interrupt) + @logger.error("Interrupted...") + @out_context.reopen + @in_context.reopen + @local_context.reopen + else + @logger.fatal("fatal error...") + end @logger.warn("Waiting for cleanup before exiting...") clean - raise e - rescue SystemExit, Interrupt => e - @logger.error("Interrupted...") - @out_context.reopen - @in_context.reopen - @local_context.reopen - @logger.warn("Waiting for cleanup before exiting...") - clean - raise e - rescue Exception => e @out_context.close! @in_context.close! @local_context.close! - raise e + raise end end def dump_build_recipe File.open(@build_recipe_path, 'w') do |f|