7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/baha/pre_build/command.rb', line 7
def self.execute(mod)
LOG.debug("execute(#{mod.args.inspect})")
command = mod.args['command']
creates = mod.args['creates']
onlyif = mod.args['only_if']
cwd = mod.image.workspace.expand_path
if creates
filepath = cwd + creates
LOG.debug { "Checking if file exists #{filepath}"}
if filepath.exist?
LOG.info("#{creates} exists - skipping command")
return
end
end
if onlyif
exit_status = 0
LOG.info { "Running test [onlyif] #{onlyif.inspect}" }
Open3.popen2e(onlyif,:chdir=>cwd.to_s) do |stdin, oe, wait_thr|
oe.each do |line|
LOG.debug { "++ " + line }
end
exit_status = wait_thr.value end
unless exit_status.success?
LOG.debug { "onlyif did not exist successfully - skipping command" }
return
end
end
LOG.info { "Running command #{command.inspect}" }
Open3.popen2e(command,:chdir=>cwd.to_s) do |stdin, oe, wait_thr|
oe.each do |line|
LOG.debug { "++ " + line.chomp }
end
end
end
|