kameleon-builder 2.9.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10a1d0784e9debc5d6a2ff2fbeecea448ae460ab
4
- data.tar.gz: 4ba768376ef0c21b166d4a80e1dda5c8cb40eb46
3
+ metadata.gz: 2b11eb6024451e8df957feaa54ba6f655569dd54
4
+ data.tar.gz: 5f903059a1e2dd4cb01ea11d91fdcfa885b4bfa0
5
5
  SHA512:
6
- metadata.gz: 54f16a561da4b4ba99d1bb70dcce202ddff375293f3759afc9c0e1f65fbb3176ede757d7e40a17276903992aa67197a46c9725e5f0b4c4d2c80d8c4eb7f429b6
7
- data.tar.gz: ec49aeb1b0178b397f71e4e1179838948821f67336f3d671135d45966fe63a9b32d275ce95de2063a8d314cea4becf17cc76ab79632ff20a3a20f0641ec73ae9
6
+ metadata.gz: 773ff3b250101855bc17abf0e468486a63642675d68463e2c7ac9f8b73663124cb34a6eaf2205856847c6b44f54f3c963168096bf45f2aaface7bbb5ee124dea
7
+ data.tar.gz: 5a108c1268d2d40737e4744091e546a8db14bd581f9fdcfbdce382374efde9e19a110f45b7628325697149f7f823b753ab9673fc59ec438666ec50fdcafeeefc
@@ -1,7 +1,7 @@
1
1
  [bumpversion]
2
2
  commit = True
3
3
  tag = True
4
- current_version = 2.9.0
4
+ current_version = 2.9.1
5
5
  parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+))?
6
6
  serialize =
7
7
  {major}.{minor}.{patch}.{release}
data/CHANGES CHANGED
@@ -1,6 +1,11 @@
1
1
  Kameleon CHANGELOG
2
2
  ==================
3
3
 
4
+ Version 2.9.1
5
+ -------------
6
+
7
+ - Make the test and group command work in the cleaning steps.
8
+
4
9
  Version 2.9.0
5
10
  -------------
6
11
 
@@ -88,7 +88,7 @@ module Kameleon
88
88
  raise ContextClosed, "The ctx '#{name}' was closed"
89
89
  end
90
90
 
91
- def pipe(cmd, other_cmd, other_ctx)
91
+ def pipe(cmd, other_cmd, other_ctx, kwargs = {})
92
92
  if @cache.mode == :from then
93
93
  Kameleon.ui.info("Redirecting pipe into cache")
94
94
  tmp = @cache.get_cache_cmd(cmd)
@@ -96,7 +96,7 @@ module Kameleon
96
96
  tmp = Tempfile.new("pipe-#{ Kameleon::Utils.generate_slug(cmd)[0..20] }")
97
97
  Kameleon.ui.verbose("Running piped commands")
98
98
  Kameleon.ui.verbose("Saving STDOUT from #{@name}_ctx to local file #{tmp.path}")
99
- execute(cmd, :stdout => tmp)
99
+ execute(cmd, kwargs.merge({:stdout => tmp}))
100
100
  tmp.close
101
101
  end
102
102
  ## Saving one side of the pipe into the cache
@@ -108,7 +108,7 @@ module Kameleon
108
108
  dest_pipe_path = "${KAMELEON_WORKDIR}/pipe-#{ Kameleon::Utils.generate_slug(other_cmd)[0..20] }"
109
109
  other_ctx.send_file(tmp.path, dest_pipe_path)
110
110
  other_cmd_with_pipe = "cat #{dest_pipe_path} | #{other_cmd} && rm #{dest_pipe_path}"
111
- other_ctx.execute(other_cmd_with_pipe)
111
+ other_ctx.execute(other_cmd_with_pipe, kwargs)
112
112
  end
113
113
 
114
114
  def load_shell()
@@ -270,46 +270,59 @@ module Kameleon
270
270
  else
271
271
  map[context].reload
272
272
  end
273
- when "exec_in"
274
- @in_context.execute(cmd.value, kwargs)
275
- when "exec_out"
276
- @out_context.execute(cmd.value, kwargs)
277
- when "exec_local"
278
- @local_context.execute(cmd.value, kwargs)
273
+ when "exec_in", "exec_out", "exec_local"
274
+ if kwargs[:only_with_context] and map[cmd.key].closed?
275
+ Kameleon.ui.debug("Not executing #{cmd.key} command (context closed): #{cmd.value}")
276
+ else
277
+ map[cmd.key].execute(cmd.value, kwargs)
278
+ end
279
279
  when "pipe"
280
280
  first_cmd, second_cmd = cmd.value
281
281
  expected_cmds = ["exec_in", "exec_out", "exec_local"]
282
+ execute = true
282
283
  [first_cmd.key, second_cmd.key].each do |key|
283
284
  unless expected_cmds.include?(key)
284
285
  Kameleon.ui.error("Invalid pipe arguments. Expected : "\
285
286
  "#{expected_cmds}")
286
287
  fail ExecError
287
288
  end
289
+ if kwargs[:only_with_context] and map[key].closed?
290
+ Kameleon.ui.debug("Not executing pipe command (context closed sub command #{key})")
291
+ execute = false
292
+ end
293
+ end
294
+ if execute
295
+ first_context = map[first_cmd.key]
296
+ second_context = map[second_cmd.key]
297
+ @cache.cache_cmd_raw(cmd.raw_cmd_id) if @cache
298
+ first_context.pipe(first_cmd.value, second_cmd.value, second_context, kwargs)
288
299
  end
289
- first_context = map[first_cmd.key]
290
- second_context = map[second_cmd.key]
291
- @cache.cache_cmd_raw(cmd.raw_cmd_id) if @cache
292
- first_context.pipe(first_cmd.value, second_cmd.value, second_context)
293
300
  when "rescue"
294
301
  first_cmd, second_cmd = cmd.value
295
302
  begin
296
- exec_cmd(first_cmd)
303
+ exec_cmd(first_cmd, kwargs)
297
304
  rescue ExecError
298
- safe_exec_cmd(second_cmd)
305
+ safe_exec_cmd(second_cmd, kwargs)
299
306
  end
300
307
  when "test"
301
308
  first_cmd, second_cmd, third_cmd = cmd.value
302
309
  begin
303
- exec_cmd(first_cmd)
310
+ Kameleon.ui.debug("Execute test condition")
311
+ # Drop any :only_with_context flag, so that "if" fails if a closed
312
+ # context exception occurs. In that case, the "else" statement must
313
+ # be executed rather than the "then" statement.
314
+ exec_cmd(first_cmd, kwargs.reject {|k| k == :only_with_context})
304
315
  rescue ExecError
305
- safe_exec_cmd(third_cmd) unless third_cmd.nil?
316
+ Kameleon.ui.debug("Execute test 'else' statment'")
317
+ exec_cmd(third_cmd, kwargs) unless third_cmd.nil?
306
318
  else
307
- safe_exec_cmd(second_cmd)
319
+ Kameleon.ui.debug("Execute test 'then' statment'")
320
+ exec_cmd(second_cmd, kwargs)
308
321
  end
309
322
  when "group"
310
323
  cmds = cmd.value
311
324
  cmds.each do |cmd|
312
- safe_exec_cmd(cmd)
325
+ exec_cmd(cmd, kwargs)
313
326
  end
314
327
  else
315
328
  Kameleon.ui.warn("Unknown command : #{cmd.key}")
@@ -379,18 +392,14 @@ module Kameleon
379
392
  end
380
393
 
381
394
  def clean(kwargs = {})
382
- map = {"exec_in" => @in_context,
383
- "exec_out" => @out_context,
384
- "exec_local" => @local_context}
395
+ kwargs = kwargs.merge({:only_with_context => true})
385
396
  if kwargs.fetch(:with_checkpoint, false)
386
397
  Kameleon.ui.info("Removing all checkpoints")
387
398
  @recipe.checkpoint["clear"].each do |cmd|
388
- if map.keys.include? cmd.key
389
- begin
390
- exec_cmd(cmd) unless map[cmd.key].closed?
391
- rescue
392
- Kameleon.ui.warn("An error occurred while executing : #{cmd.value}")
393
- end
399
+ begin
400
+ exec_cmd(cmd, kwargs)
401
+ rescue
402
+ Kameleon.ui.warn("An error occurred while executing : #{cmd.value}")
394
403
  end
395
404
  end
396
405
  end
@@ -404,12 +413,10 @@ module Kameleon
404
413
  end
405
414
  end
406
415
  microstep.commands.each do |cmd|
407
- if map.keys.include? cmd.key
408
- begin
409
- exec_cmd(cmd) unless map[cmd.key].closed?
410
- rescue
411
- Kameleon.ui.warn("An error occurred while executing : #{cmd.value}")
412
- end
416
+ begin
417
+ exec_cmd(cmd, kwargs)
418
+ rescue
419
+ Kameleon.ui.warn("An error occurred while executing : #{cmd.value}")
413
420
  end
414
421
  end
415
422
  end
@@ -1 +1 @@
1
- 2.9.0
1
+ 2.9.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kameleon-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salem Harrache
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-06-29 00:00:00.000000000 Z
15
+ date: 2018-01-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: childprocess
@@ -223,7 +223,7 @@ requirements:
223
223
  - polipo 1.0.3, or greater
224
224
  - graphviz 2.38.0 or greater
225
225
  rubyforge_project:
226
- rubygems_version: 2.5.2
226
+ rubygems_version: 2.5.2.1
227
227
  signing_key:
228
228
  specification_version: 4
229
229
  summary: Kameleon is a tool to build virtual machines from scratch