kameleon-builder 2.0.0 → 2.1.0
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.
- data/.editorconfig +0 -0
- data/.env +63 -15
- data/.gitignore +1 -0
- data/README.rst +4 -2
- data/Vagrantfile +13 -52
- data/bin/kameleon +5 -0
- data/completion/_kameleon.zsh +18 -0
- data/completion/kameleon.bash +13 -0
- data/completion/kameleon.fish +10 -0
- data/contrib/polipo_env.sh +2 -0
- data/contrib/steps/export/save_as_g5k.yaml +63 -0
- data/contrib/steps/setup/add_to_sudoers.yaml +5 -0
- data/docs/Makefile +10 -6
- data/docs/README.md +17 -0
- data/docs/source/_static/kameleon-logo.png +0 -0
- data/docs/source/_static/kameleon-logo.xcf +0 -0
- data/docs/source/_static/kameleon-long.png +0 -0
- data/docs/source/aliases.rst +4 -2
- data/docs/source/checkpoint.rst +2 -0
- data/docs/source/commands.rst +4 -3
- data/docs/source/conf.py +15 -7
- data/docs/source/context.rst +7 -4
- data/docs/source/faq.rst +39 -1
- data/docs/source/getting_started.rst +227 -1
- data/docs/source/grid5000_tutorial.rst +110 -0
- data/docs/source/index.rst +7 -2
- data/docs/source/installation.rst +12 -4
- data/docs/source/persistent_cache.rst +34 -0
- data/docs/source/recipe.rst +23 -16
- data/docs/source/use_cases.rst +93 -0
- data/docs/source/workspace.rst +2 -0
- data/kameleon-builder.gemspec +7 -1
- data/lib/kameleon.rb +3 -6
- data/lib/kameleon/cli.rb +104 -50
- data/lib/kameleon/compat.rb +39 -0
- data/lib/kameleon/context.rb +43 -13
- data/lib/kameleon/engine.rb +118 -77
- data/lib/kameleon/environment.rb +3 -5
- data/lib/kameleon/error.rb +15 -9
- data/lib/kameleon/logger.rb +7 -4
- data/lib/kameleon/persistent_cache.rb +139 -0
- data/lib/kameleon/recipe.rb +200 -81
- data/lib/kameleon/shell.rb +51 -16
- data/omnibus/.gitignore +11 -0
- data/omnibus/.kitchen.yml +25 -0
- data/omnibus/Berksfile +9 -0
- data/omnibus/Berksfile.lock +25 -0
- data/omnibus/Gemfile +12 -0
- data/omnibus/README.md +94 -0
- data/omnibus/config/projects/kameleon.rb +23 -0
- data/omnibus/config/software/kameleon.rb +24 -0
- data/omnibus/config/software/polipo.rb +30 -0
- data/omnibus/config/software/ruby.rb +158 -0
- data/omnibus/files/mac_dmg/Resources/background.png +0 -0
- data/omnibus/files/mac_dmg/Resources/icon.png +0 -0
- data/omnibus/files/mac_pkg/Resources/background.png +0 -0
- data/omnibus/files/mac_pkg/Resources/license.html +1 -0
- data/omnibus/files/mac_pkg/Resources/welcome.html +9 -0
- data/omnibus/omnibus.rb +27 -0
- data/omnibus/package-scripts/kameleon/makeselfinst +27 -0
- data/omnibus/package-scripts/kameleon/postrm +9 -0
- data/templates/archlinux-desktop.yaml +25 -0
- data/templates/archlinux.yaml +106 -0
- data/templates/debian-testing.yaml +25 -0
- data/templates/debian7-desktop.yaml +25 -0
- data/templates/{debian-wheezy-docker.yaml → debian7-docker.yaml} +30 -16
- data/templates/debian7-g5k.yaml +97 -0
- data/templates/debian7-oar-dev.yaml +51 -0
- data/templates/debian7.yaml +128 -0
- data/templates/extend.erb +23 -0
- data/templates/fedora-rawhide.yaml +30 -0
- data/templates/fedora20-desktop.yaml +21 -0
- data/templates/fedora20.yaml +105 -0
- data/templates/{debian-wheezy-chroot.yaml → old-debian7.yaml} +51 -38
- data/templates/{aliases → steps/aliases}/defaults.yaml +37 -12
- data/templates/steps/bootstrap/archlinux/arch_bootstrap.yaml +219 -0
- data/templates/steps/bootstrap/archlinux/install_bootloader.yaml +46 -0
- data/templates/steps/bootstrap/archlinux/populate_disk.yaml +39 -0
- data/templates/steps/bootstrap/debian/debootstrap.yaml +18 -10
- data/templates/steps/bootstrap/debian/debootstrap_arm.yaml +31 -0
- data/templates/steps/bootstrap/fedora/liveos_bootstrap.yaml +123 -0
- data/templates/steps/bootstrap/g5k_reserv.yaml +70 -0
- data/templates/steps/bootstrap/initialize_disk_chroot.yaml +84 -0
- data/templates/steps/bootstrap/initialize_disk_qemu.yaml +72 -0
- data/templates/steps/bootstrap/install_bootloader.yaml +42 -0
- data/templates/steps/bootstrap/prepare_chroot.yaml +126 -0
- data/templates/steps/bootstrap/prepare_docker.yaml +19 -8
- data/templates/steps/bootstrap/prepare_qemu.yaml +47 -0
- data/templates/steps/bootstrap/start_chroot.yaml +11 -2
- data/templates/steps/bootstrap/start_docker.yaml +2 -2
- data/templates/steps/bootstrap/start_qemu.yaml +75 -0
- data/templates/steps/bootstrap/ubuntu/debootstrap.yaml +27 -0
- data/templates/steps/breakpoint.yaml +2 -0
- data/templates/{checkpoints → steps/checkpoints}/docker.yaml +0 -0
- data/templates/steps/checkpoints/qcow2.yaml +38 -0
- data/templates/steps/checkpoints/qemu.yaml +39 -0
- data/templates/steps/export/clean_appliance.yaml +7 -1
- data/templates/steps/export/compact_qcow_img.yaml +12 -0
- data/templates/steps/export/save_appliance.yaml +58 -0
- data/templates/steps/export/save_appliance_from_g5k.yaml +47 -0
- data/templates/steps/export/save_vagrant_box.yaml +29 -0
- data/templates/steps/setup/archlinux/configure_keyboard.yaml +9 -0
- data/templates/steps/setup/archlinux/configure_network.yaml +9 -0
- data/templates/steps/setup/archlinux/configure_ruby.yaml +7 -0
- data/templates/steps/setup/archlinux/configure_system.yaml +20 -0
- data/templates/steps/setup/archlinux/install_dev_tools.yaml +18 -0
- data/templates/steps/setup/archlinux/install_gnome.yaml +27 -0
- data/templates/steps/setup/archlinux/install_software.yaml +9 -0
- data/templates/steps/setup/archlinux/install_yaourt.yaml +29 -0
- data/templates/steps/setup/autologin.yaml +16 -0
- data/templates/steps/setup/create_group.yaml +12 -0
- data/templates/steps/setup/create_user.yaml +9 -10
- data/templates/steps/setup/debian/configure_apt.yaml +65 -0
- data/templates/steps/setup/debian/configure_kernel.yaml +18 -0
- data/templates/steps/setup/debian/{keyboard_config.yaml → configure_keyboard.yaml} +1 -1
- data/templates/steps/setup/debian/{network_config.yaml → configure_network.yaml} +0 -0
- data/templates/steps/setup/debian/{system_config.yaml → configure_system.yaml} +0 -0
- data/templates/steps/setup/debian/install_gnome.yaml +13 -0
- data/templates/steps/setup/debian/install_kde.yaml +13 -0
- data/templates/steps/setup/debian/install_software.yaml +2 -0
- data/templates/steps/setup/debian/oar/oar_debian_config_frontend.yaml +8 -0
- data/templates/steps/setup/debian/oar/oar_debian_config_node.yaml +5 -0
- data/templates/steps/setup/debian/oar/oar_debian_config_server.yaml +5 -0
- data/templates/steps/setup/debian/oar/oar_prereq_install.yaml +16 -0
- data/templates/steps/setup/debian/setup_vagrant_box.yaml +52 -0
- data/templates/steps/setup/debian/upgrade_system.yaml +15 -0
- data/templates/steps/setup/fedora/configure_network.yaml +30 -0
- data/templates/steps/setup/fedora/configure_system.yaml +59 -0
- data/templates/steps/setup/fedora/install_software.yaml +3 -0
- data/templates/steps/setup/fedora/update_system.yaml +10 -0
- data/templates/steps/setup/oar/oar_config_devel.yaml +21 -0
- data/templates/steps/setup/oar/oar_config_frontend.yaml +38 -0
- data/templates/steps/setup/oar/oar_config_node.yaml +4 -0
- data/templates/steps/setup/oar/oar_config_server.yaml +25 -0
- data/templates/steps/setup/oar/oar_config_system.yaml +34 -0
- data/templates/steps/setup/oar/oar_devel_prereq_install.yaml +5 -0
- data/templates/steps/setup/oar/oar_git_install.yaml +21 -0
- data/templates/steps/setup/ubuntu/configure_apt.yaml +67 -0
- data/templates/ubuntu-12.04-desktop.yaml +25 -0
- data/templates/ubuntu-12.04.yaml +128 -0
- data/templates/ubuntu-14.04-desktop.yaml +27 -0
- data/templates/ubuntu-14.04.yaml +25 -0
- data/templates/vagrant-debian7.yaml +31 -0
- data/version.txt +1 -1
- metadata +155 -28
- checksums.yaml +0 -7
- data/templates/checkpoints/qcow2.yaml +0 -44
- data/templates/fedora-docker.yaml +0 -96
- data/templates/steps/bootstrap/fedora/docker_bootstrap.yaml +0 -25
- data/templates/steps/bootstrap/fedora/yum_bootstrap.yaml +0 -22
- data/templates/steps/bootstrap/prepare_appliance_with_nbd.yaml +0 -93
- data/templates/steps/export/build_appliance_from_docker.yaml +0 -105
- data/templates/steps/export/save_appliance_from_nbd.yaml +0 -54
- data/templates/steps/setup/debian/kernel_install.yaml +0 -20
- data/templates/steps/setup/debian/software_install.yaml +0 -15
- data/templates/steps/setup/fedora/kernel_install.yaml +0 -27
- data/templates/steps/setup/fedora/software_install.yaml +0 -10
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
YAML::ENGINE.yamler = 'syck' if (defined?(Syck) || defined?(YAML::Syck)) && defined?(YAML::ENGINE)
|
5
|
+
|
6
|
+
if RUBY_VERSION < "1.9.3"
|
7
|
+
# Backport of missing SecureRandom methods from 1.9
|
8
|
+
# Snippet from http://softover.com/UUID_in_Ruby_1.8
|
9
|
+
module SecureRandom
|
10
|
+
class << self
|
11
|
+
def method_missing(method_sym, *arguments, &block)
|
12
|
+
case method_sym
|
13
|
+
when :urlsafe_base64
|
14
|
+
r19_urlsafe_base64(*arguments)
|
15
|
+
when :uuid
|
16
|
+
r19_uuid(*arguments)
|
17
|
+
else
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def r19_urlsafe_base64(n=nil, padding=false)
|
24
|
+
s = [random_bytes(n)].pack("m*")
|
25
|
+
s.delete!("\n")
|
26
|
+
s.tr!("+/", "-_")
|
27
|
+
s.delete!("=") if !padding
|
28
|
+
s
|
29
|
+
end
|
30
|
+
|
31
|
+
def r19_uuid
|
32
|
+
ary = random_bytes(16).unpack("NnnnnN")
|
33
|
+
ary[2] = (ary[2] & 0x0fff) | 0x4000
|
34
|
+
ary[3] = (ary[3] & 0x3fff) | 0x8000
|
35
|
+
"%08x-%04x-%04x-%04x-%04x%08x" % ary
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/kameleon/context.rb
CHANGED
@@ -14,13 +14,27 @@ module Kameleon
|
|
14
14
|
@local_workdir = local_workdir
|
15
15
|
@shell = Kameleon::Shell.new(@name, @cmd, @workdir, @local_workdir)
|
16
16
|
@logger.debug("Initialize new ctx (#{name})")
|
17
|
+
@log_on_progress = false
|
17
18
|
|
18
19
|
instance_variables.each do |v|
|
19
20
|
@logger.debug(" #{v} = #{instance_variable_get(v)}")
|
20
21
|
end
|
21
|
-
|
22
|
-
@
|
23
|
-
|
22
|
+
|
23
|
+
@cache = Kameleon::Persistent_cache.instance
|
24
|
+
end
|
25
|
+
|
26
|
+
def do_log(out, log_level)
|
27
|
+
if @log_on_progress
|
28
|
+
log_progress(log_level, out)
|
29
|
+
@log_on_progress = false if out.match(/\n$/)
|
30
|
+
else
|
31
|
+
if out.match(/\n$/)
|
32
|
+
out.split( /\r?\n/ ).each {|m| log(log_level, m) }
|
33
|
+
else
|
34
|
+
log_progress(log_level, out)
|
35
|
+
@log_on_progress = true
|
36
|
+
end
|
37
|
+
end
|
24
38
|
end
|
25
39
|
|
26
40
|
def log(log_level, msg)
|
@@ -29,42 +43,58 @@ module Kameleon
|
|
29
43
|
@logger.debug msg if log_level == "debug"
|
30
44
|
end
|
31
45
|
|
46
|
+
def log_progress(log_level, msg)
|
47
|
+
@logger.progress_info msg if log_level == "info"
|
48
|
+
@logger.progress_error msg if log_level == "error"
|
49
|
+
@logger.debug msg if log_level == "debug"
|
50
|
+
end
|
51
|
+
|
32
52
|
def execute(cmd, kwargs = {})
|
53
|
+
lazyload_shell
|
33
54
|
cmd_with_prefix = "#{@exec_prefix} #{cmd}"
|
34
55
|
cmd_with_prefix.split( /\r?\n/ ).each {|m| @logger.debug "+ #{m}" }
|
35
56
|
log_level = kwargs.fetch(:log_level, "info")
|
36
57
|
exit_status = @shell.execute(cmd_with_prefix, kwargs) do |out, err|
|
37
|
-
out
|
38
|
-
err
|
58
|
+
do_log(out, log_level) unless out.nil?
|
59
|
+
do_log(err, "error") unless err.nil?
|
39
60
|
end
|
40
61
|
@logger.debug("Exit status : #{exit_status}")
|
41
62
|
fail ExecError unless exit_status.eql? 0
|
42
|
-
rescue ShellError => e
|
43
|
-
@logger.
|
44
|
-
|
63
|
+
rescue ShellError, Errno::EPIPE => e
|
64
|
+
@logger.debug("Shell cmd failed to launch: #{@shell.shell_cmd}")
|
65
|
+
raise ShellError, e.message + ". Check the cmd argument of the '#{@name}_context'."
|
45
66
|
end
|
46
67
|
|
47
68
|
def pipe(cmd, other_cmd, other_ctx)
|
48
69
|
tmp = Tempfile.new("pipe-#{ Kameleon::Utils.generate_slug(cmd)[0..20] }")
|
49
|
-
@logger.
|
50
|
-
@logger.
|
70
|
+
@logger.debug("Running piped commands")
|
71
|
+
@logger.debug("Saving STDOUT from #{@name}_ctx to local file #{tmp.path}")
|
51
72
|
execute(cmd, :stdout => tmp)
|
52
73
|
tmp.close
|
53
|
-
@logger.
|
54
|
-
dest_pipe_path = "
|
74
|
+
@logger.debug("Forwarding #{tmp.path} to STDIN of #{other_ctx.name}_ctx")
|
75
|
+
dest_pipe_path = "${KAMELEON_WORKDIR}/pipe-#{ Kameleon::Utils.generate_slug(other_cmd)[0..20] }"
|
55
76
|
other_ctx.send_file(tmp.path, dest_pipe_path)
|
56
77
|
other_cmd_with_pipe = "cat #{dest_pipe_path} | #{other_cmd} && rm #{dest_pipe_path}"
|
57
78
|
other_ctx.execute(other_cmd_with_pipe)
|
58
79
|
end
|
59
80
|
|
81
|
+
def lazyload_shell()
|
82
|
+
unless @shell.started?
|
83
|
+
# Start the shell process
|
84
|
+
@shell.start
|
85
|
+
execute("echo The '#{name}_context' has been initialized", :log_level => "info")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
60
89
|
def start_shell
|
61
90
|
#TODO: Load env and history
|
91
|
+
lazyload_shell
|
62
92
|
@logger.info("Starting interactive shell")
|
63
93
|
@shell.fork_and_wait
|
64
94
|
end
|
65
95
|
|
66
96
|
def closed?
|
67
|
-
@shell.exited?
|
97
|
+
return !@shell.started? || @shell.exited?
|
68
98
|
end
|
69
99
|
|
70
100
|
def close!
|
data/lib/kameleon/engine.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'kameleon/recipe'
|
2
2
|
require 'kameleon/context'
|
3
|
-
|
3
|
+
require 'kameleon/persistent_cache'
|
4
4
|
|
5
5
|
module Kameleon
|
6
6
|
|
@@ -9,7 +9,7 @@ module Kameleon
|
|
9
9
|
|
10
10
|
def initialize(recipe, options)
|
11
11
|
@options = options
|
12
|
-
@logger = Log4r::Logger.new("kameleon::[
|
12
|
+
@logger = Log4r::Logger.new("kameleon::[kameleon]")
|
13
13
|
@recipe = recipe
|
14
14
|
@cleaned_sections = []
|
15
15
|
@cwd = @recipe.global["kameleon_cwd"]
|
@@ -29,6 +29,17 @@ module Kameleon
|
|
29
29
|
@enable_checkpoint = !@recipe.checkpoint.nil? if @enable_checkpoint
|
30
30
|
|
31
31
|
@recipe.resolve!
|
32
|
+
|
33
|
+
if @options[:cache] || @options[:from_cache] then
|
34
|
+
@cache = Kameleon::Persistent_cache.instance
|
35
|
+
@cache.activated = true
|
36
|
+
@cache.cwd = @cwd
|
37
|
+
@cache.polipo_path = @options[:proxy_path]
|
38
|
+
@cache.check_polipo_binary
|
39
|
+
@cache.name = @recipe.name
|
40
|
+
#saving_steps_files
|
41
|
+
end
|
42
|
+
|
32
43
|
@in_context = nil
|
33
44
|
begin
|
34
45
|
@logger.notice("Creating kameleon working directory : #{@cwd}")
|
@@ -44,6 +55,34 @@ module Kameleon
|
|
44
55
|
@recipe.global["out_context"]["workdir"],
|
45
56
|
@recipe.global["out_context"]["exec_prefix"],
|
46
57
|
@cwd)
|
58
|
+
@logger.notice("Building internal context [in]")
|
59
|
+
@in_context = Context.new("in",
|
60
|
+
@recipe.global["in_context"]["cmd"],
|
61
|
+
@recipe.global["in_context"]["workdir"],
|
62
|
+
@recipe.global["in_context"]["exec_prefix"],
|
63
|
+
@cwd)
|
64
|
+
if @options[:from_cache] then
|
65
|
+
begin
|
66
|
+
@cache.unpack(@options[:from_cache])
|
67
|
+
rescue
|
68
|
+
raise BuildError, "Failed to untar the persistent cache file"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def saving_steps_files
|
74
|
+
@recipe.files.each do |file|
|
75
|
+
@logger.notice("File #{file} loaded from the recipe")
|
76
|
+
sleep 1
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def create_cache_directory(step_name)
|
82
|
+
@logger.notice("Creating directory for cache #{step_name}")
|
83
|
+
directory_name = @cache.cache_dir + "/#{step_name}"
|
84
|
+
FileUtils.mkdir_p directory_name
|
85
|
+
directory_name
|
47
86
|
end
|
48
87
|
|
49
88
|
def create_checkpoint(microstep_id)
|
@@ -82,16 +121,22 @@ module Kameleon
|
|
82
121
|
def do_steps(section_name)
|
83
122
|
section = @recipe.sections.fetch(section_name)
|
84
123
|
section.sequence do |macrostep|
|
124
|
+
|
125
|
+
if @cache then
|
126
|
+
# the following function start a polipo web proxy and stops a previous run
|
127
|
+
dir_cache = @cache.create_cache_directory(macrostep.name) #unless @options[:from_cache]
|
128
|
+
@cache.start_web_proxy_in(dir_cache)
|
129
|
+
end
|
130
|
+
|
85
131
|
macrostep.sequence do |microstep|
|
86
132
|
@logger.notice("Step #{ microstep.order } : #{ microstep.slug }")
|
87
|
-
@logger.notice(" ---> #{ microstep.identifier }")
|
88
133
|
if @enable_checkpoint
|
89
134
|
if microstep.on_checkpoint == "skip"
|
90
135
|
@logger.notice(" ---> Skipped")
|
91
136
|
next
|
92
137
|
end
|
93
138
|
if microstep.in_cache && microstep.on_checkpoint == "use_cache"
|
94
|
-
@logger.notice(" ---> Using cache")
|
139
|
+
@logger.notice(" ---> Using cache this time")
|
95
140
|
else
|
96
141
|
@logger.notice(" ---> Running step")
|
97
142
|
microstep.commands.each do |cmd|
|
@@ -111,6 +156,12 @@ module Kameleon
|
|
111
156
|
end
|
112
157
|
end
|
113
158
|
@cleaned_sections.push(section.name)
|
159
|
+
|
160
|
+
if @cache then
|
161
|
+
@cache.stop_web_proxy
|
162
|
+
@cache.pack unless @options[:from_cache]
|
163
|
+
end
|
164
|
+
|
114
165
|
end
|
115
166
|
|
116
167
|
def safe_exec_cmd(cmd, kwargs = {})
|
@@ -124,41 +175,32 @@ module Kameleon
|
|
124
175
|
end
|
125
176
|
|
126
177
|
def exec_cmd(cmd, kwargs = {})
|
127
|
-
def skip_alert(cmd)
|
128
|
-
@logger.warn("Skipping cmd '#{cmd.string_cmd}'. The in_context is" \
|
129
|
-
" not ready yet")
|
130
|
-
end
|
131
178
|
case cmd.key
|
132
179
|
when "breakpoint"
|
133
|
-
breakpoint(cmd.value
|
180
|
+
breakpoint(cmd.value)
|
134
181
|
when "exec_in"
|
135
182
|
skip_alert(cmd) if @in_context.nil?
|
136
|
-
@in_context.execute(cmd.value, kwargs)
|
183
|
+
@in_context.execute(cmd.value, kwargs)
|
137
184
|
when "exec_out"
|
138
185
|
@out_context.execute(cmd.value, kwargs)
|
139
186
|
when "exec_local"
|
140
187
|
@local_context.execute(cmd.value, kwargs)
|
141
188
|
when "pipe"
|
142
189
|
first_cmd, second_cmd = cmd.value
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
unless expected_cmds.include?(key)
|
150
|
-
@logger.error("Invalid pipe arguments. Expected "\
|
151
|
-
"#{expected_cmds} commands")
|
152
|
-
fail ExecError
|
153
|
-
end
|
190
|
+
expected_cmds = ["exec_in", "exec_out", "exec_local"]
|
191
|
+
[first_cmd.key, second_cmd.key].each do |key|
|
192
|
+
unless expected_cmds.include?(key)
|
193
|
+
@logger.error("Invalid pipe arguments. Expected "\
|
194
|
+
"#{expected_cmds} commands")
|
195
|
+
fail ExecError
|
154
196
|
end
|
155
|
-
map = {"exec_in" => @in_context,
|
156
|
-
"exec_out" => @out_context,
|
157
|
-
"exec_local" => @local_context,}
|
158
|
-
first_context = map[first_cmd.key]
|
159
|
-
second_context = map[second_cmd.key]
|
160
|
-
first_context.pipe(first_cmd.value, second_cmd.value, second_context)
|
161
197
|
end
|
198
|
+
map = {"exec_in" => @in_context,
|
199
|
+
"exec_out" => @out_context,
|
200
|
+
"exec_local" => @local_context,}
|
201
|
+
first_context = map[first_cmd.key]
|
202
|
+
second_context = map[second_cmd.key]
|
203
|
+
first_context.pipe(first_cmd.value, second_cmd.value, second_context)
|
162
204
|
when "rescue"
|
163
205
|
first_cmd, second_cmd = cmd.value
|
164
206
|
begin
|
@@ -179,17 +221,17 @@ module Kameleon
|
|
179
221
|
msg << "Press [r] to retry\n" if enable_retry
|
180
222
|
msg << "Press [c] to continue with execution"
|
181
223
|
msg << "\nPress [a] to abort execution"
|
182
|
-
msg << "\nPress [l] to switch to local_context shell"
|
183
|
-
msg << "\nPress [o] to switch to out_context shell"
|
184
|
-
msg << "\nPress [i] to switch to in_context shell"
|
224
|
+
msg << "\nPress [l] to switch to local_context shell"
|
225
|
+
msg << "\nPress [o] to switch to out_context shell"
|
226
|
+
msg << "\nPress [i] to switch to in_context shell"
|
185
227
|
responses = {"c" => "continue", "a" => "abort"}
|
186
228
|
responses["r"] = "retry" if enable_retry
|
187
|
-
responses.merge!({"l" => "launch local_context"})
|
188
|
-
responses.merge!({"o" => "launch out_context"})
|
189
|
-
responses.merge!({"i" => "launch in_context"})
|
229
|
+
responses.merge!({"l" => "launch local_context"})
|
230
|
+
responses.merge!({"o" => "launch out_context"})
|
231
|
+
responses.merge!({"i" => "launch in_context"})
|
190
232
|
while true
|
191
233
|
msg.split( /\r?\n/ ).each {|m| @logger.notice "#{m}" }
|
192
|
-
@logger.
|
234
|
+
@logger.progress_notice "answer ? [" + responses.keys().join("/") + "]: "
|
193
235
|
answer = $stdin.gets
|
194
236
|
raise AbortError, "Execution aborted..." if answer.nil?
|
195
237
|
answer.chomp!
|
@@ -203,13 +245,14 @@ module Kameleon
|
|
203
245
|
else
|
204
246
|
@in_context.start_shell
|
205
247
|
end
|
206
|
-
@logger.notice("Getting back to Kameleon
|
248
|
+
@logger.notice("Getting back to Kameleon...")
|
207
249
|
elsif answer.eql? "a"
|
208
250
|
raise AbortError, "Execution aborted..."
|
209
251
|
elsif answer.eql? "c"
|
210
252
|
## resetting the exit status
|
211
|
-
@in_context.execute("true")
|
212
|
-
@out_context.execute("true")
|
253
|
+
@in_context.execute("true")
|
254
|
+
@out_context.execute("true")
|
255
|
+
@local_context.execute("true")
|
213
256
|
return true
|
214
257
|
elsif answer.eql? "r"
|
215
258
|
@logger.notice("Retrying the previous command...")
|
@@ -225,39 +268,32 @@ module Kameleon
|
|
225
268
|
return breakpoint(message, :enable_retry => true)
|
226
269
|
end
|
227
270
|
|
228
|
-
def
|
271
|
+
def clean()
|
229
272
|
@recipe.sections.values.each do |section|
|
230
273
|
next if @cleaned_sections.include?(section.name)
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
microstep.commands.each do |cmd|
|
235
|
-
begin
|
236
|
-
exec_cmd(cmd)
|
237
|
-
rescue
|
238
|
-
@logger.warn("An error occurred while executing : #{cmd.value}")
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
def clear
|
247
|
-
@recipe.sections.values.each do |section|
|
274
|
+
map = {"exec_in" => @in_context,
|
275
|
+
"exec_out" => @out_context,
|
276
|
+
"exec_local" => @local_context}
|
248
277
|
@logger.notice("Cleaning #{section.name} section")
|
249
278
|
section.clean_macrostep.sequence do |microstep|
|
250
279
|
microstep.commands.each do |cmd|
|
251
|
-
if
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
280
|
+
if map.keys.include? cmd.key
|
281
|
+
unless map[cmd.key].closed?
|
282
|
+
begin
|
283
|
+
exec_cmd(cmd)
|
284
|
+
rescue
|
285
|
+
@logger.warn("An error occurred while executing : #{cmd.value}")
|
286
|
+
end
|
256
287
|
end
|
257
288
|
end
|
258
289
|
end
|
259
290
|
end
|
260
291
|
end
|
292
|
+
@cache.stop_web_proxy if @options[:cache] ## stopping polipo
|
293
|
+
end
|
294
|
+
|
295
|
+
def clear
|
296
|
+
clean
|
261
297
|
unless @recipe.checkpoint.nil?
|
262
298
|
@logger.notice("Removing all old checkpoints")
|
263
299
|
cmd = @recipe.checkpoint["clear"]
|
@@ -291,24 +327,27 @@ module Kameleon
|
|
291
327
|
end
|
292
328
|
dump_build_recipe
|
293
329
|
begin
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
@cwd)
|
301
|
-
do_steps("setup")
|
302
|
-
do_steps("export")
|
303
|
-
rescue Exception => e
|
330
|
+
["bootstrap", "setup", "export"].each do |section|
|
331
|
+
do_steps(section)
|
332
|
+
end
|
333
|
+
clean
|
334
|
+
rescue AbortError => e
|
335
|
+
@logger.error("Aborted...")
|
304
336
|
@logger.warn("Waiting for cleanup before exiting...")
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
@out_context.
|
310
|
-
@in_context.
|
311
|
-
@local_context.
|
337
|
+
clean
|
338
|
+
raise e
|
339
|
+
rescue SystemExit, Interrupt => e
|
340
|
+
@logger.error("Interrupted...")
|
341
|
+
@out_context.reopen
|
342
|
+
@in_context.reopen
|
343
|
+
@local_context.reopen
|
344
|
+
@logger.warn("Waiting for cleanup before exiting...")
|
345
|
+
clean
|
346
|
+
raise e
|
347
|
+
rescue Exception => e
|
348
|
+
@out_context.close!
|
349
|
+
@in_context.close!
|
350
|
+
@local_context.close!
|
312
351
|
raise e
|
313
352
|
end
|
314
353
|
end
|
@@ -328,6 +367,8 @@ module Kameleon
|
|
328
367
|
end
|
329
368
|
|
330
369
|
def pretty_checkpoints_list
|
370
|
+
|
371
|
+
|
331
372
|
def find_microstep_slug_by_id(id)
|
332
373
|
@recipe.microsteps.each do |m|
|
333
374
|
return m.slug if m.identifier == id
|