lib/kameleon/engine.rb in kameleon-builder-2.2.5 vs lib/kameleon/engine.rb in kameleon-builder-2.3.0
- old
+ new
@@ -11,35 +11,35 @@
def initialize(recipe, options)
@options = options
@recipe = recipe
@cleaned_sections = []
@cwd = @recipe.global["kameleon_cwd"]
- @build_recipe_path = File.join(@cwd, "kameleon_build_recipe.yaml")
+ @build_recipe_path = File.join(@cwd, ".build_recipe")
- @recipe.global["persistent_cache"] = @options[:cache] ? "true" : "false"
+ @recipe.global["persistent_cache"] = @options[:enable_cache] ? "true" : "false"
build_recipe = load_build_recipe
# restore previous build uuid
unless build_recipe.nil?
%w(kameleon_uuid kameleon_short_uuid).each do |key|
@recipe.global[key] = build_recipe["global"][key]
end
end
- @enable_checkpoint = @options[:checkpoint]
+ @enable_checkpoint = @options[:enable_checkpoint]
# Check if the recipe have checkpoint entry
if @enable_checkpoint && @recipe.checkpoint.nil?
fail BuildError, "Checkpoint is unavailable for this recipe"
end
@recipe.resolve!
- if @options[:cache] || @options[:from_cache] then
+ if @options[:enable_cache] || @options[:from_cache] then
@cache = Kameleon::Persistent_cache.instance
@cache.cwd = @cwd
@cache.polipo_path = @options[:proxy_path]
@cache.name = @recipe.name
- @cache.mode = @options[:cache] ? :build : :from
+ @cache.mode = @options[:enable_cache] ? :build : :from
@cache.cache_path = @options[:from_cache]
@cache.recipe_files = @recipe.files + @recipe.base_recipes_files# I'm passing the Pathname objects
@cache.recipe_path = @recipe.path
if @recipe.global["in_context"]["proxy_cache"].nil? then
@@ -91,10 +91,16 @@
:proxy_cache => proxy_cache_in,
:lazyload => lazyload,
:fail_silently => fail_silently)
end
+ def reload_contexts
+ [@local_context, @out_context, @in_context].each do |ctx|
+ ctx.reload if ctx.shell.started?
+ end
+ end
+
def saving_steps_files
@recipe.files.each do |file|
Kameleon.ui.info("File #{file} loaded from the recipe")
end
@@ -180,27 +186,33 @@
create_checkpoint(microstep.identifier)
end
end
end
else
+ begin
Kameleon.ui.info("--> Running the step...")
microstep.commands.each do |cmd|
safe_exec_cmd(cmd)
end
+ rescue SystemExit, Interrupt
+ reload_contexts
+ breakpoint(nil)
+ end
end
- end
Kameleon.ui.info("Step #{macrostep.name} took: #{Time.now.to_i-macrostep_time} secs")
+ end
end
@cleaned_sections.push(section.name)
end
def safe_exec_cmd(cmd, kwargs = {})
finished = false
begin
exec_cmd(cmd, kwargs)
finished = true
- rescue ExecError
+ rescue SystemExit, Interrupt, ExecError
+ reload_contexts
finished = rescue_exec_error(cmd)
end until finished
end
def exec_cmd(cmd, kwargs = {})
@@ -348,10 +360,10 @@
end
end
end
end
end
- @cache.stop_web_proxy if @options[:cache] ## stopping polipo
+ @cache.stop_web_proxy if @options[:enable_cache] ## stopping polipo
end
def build
if @enable_checkpoint
@from_checkpoint = @options[:from_checkpoint]