kameleon-builder 2.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.editorconfig +0 -0
- data/.env +2 -6
- data/CHANGELOG.rst +74 -1
- data/Gemfile +20 -2
- data/README.rst +35 -25
- data/Thorfile +29 -0
- data/contrib/kameleon_bashrc.sh +61 -0
- data/contrib/polipo_env.sh +3 -2
- data/kameleon-builder.gemspec +3 -10
- data/lib/kameleon.rb +10 -14
- data/lib/kameleon/cli.rb +92 -105
- data/lib/kameleon/context.rb +76 -43
- data/lib/kameleon/engine.rb +147 -103
- data/lib/kameleon/environment.rb +10 -5
- data/lib/kameleon/error.rb +1 -32
- data/lib/kameleon/persistent_cache.rb +127 -29
- data/lib/kameleon/recipe.rb +63 -106
- data/lib/kameleon/shell.rb +32 -17
- data/lib/kameleon/step.rb +18 -1
- data/lib/kameleon/ui.rb +141 -0
- data/lib/kameleon/utils.rb +9 -0
- data/templates/{debian7-chroot.yaml → chroot/debian7-amd64.yaml} +29 -21
- data/templates/{docker-debian7.yaml → docker/debian7.yaml} +5 -5
- data/templates/extend.erb +2 -2
- data/templates/{debian7-g5k.yaml → grid5000/debian7.yaml} +1 -1
- data/templates/{archlinux-desktop.yaml → qemu/archlinux-desktop-i686.yaml} +2 -2
- data/templates/qemu/archlinux-desktop-x86_64.yaml +25 -0
- data/templates/qemu/archlinux-i686.yaml +25 -0
- data/templates/{archlinux.yaml → qemu/archlinux-x86_64.yaml} +37 -34
- data/templates/qemu/centos6.5-x86_64.yaml +113 -0
- data/templates/qemu/centos7-x86_64.yaml +119 -0
- data/templates/{debian7.yaml → qemu/debian7-amd64.yaml} +45 -40
- data/templates/{debian7-desktop.yaml → qemu/debian7-desktop-amd64.yaml} +2 -3
- data/templates/{debian7-kameleon.yaml → qemu/debian7-kameleon-amd64.yaml} +3 -6
- data/templates/{debian7-oar-dev.yaml → qemu/debian7-oar-amd64.yaml} +2 -2
- data/templates/qemu/debian8-amd64.yaml +25 -0
- data/templates/{fedora20-desktop.yaml → qemu/fedora20-desktop-x86_64.yaml} +2 -2
- data/templates/qemu/fedora20-x86_64.yaml +116 -0
- data/templates/{ubuntu-12.04.yaml → qemu/ubuntu-12.04-amd64.yaml} +42 -38
- data/templates/{ubuntu-12.04-desktop.yaml → qemu/ubuntu-12.04-desktop-amd64.yaml} +3 -3
- data/templates/{ubuntu-14.04.yaml → qemu/ubuntu-14.04-amd64.yaml} +2 -2
- data/templates/{ubuntu-14.04-desktop.yaml → qemu/ubuntu-14.04-desktop-amd64.yaml} +2 -2
- data/templates/steps/aliases/defaults.yaml +19 -13
- data/templates/steps/bootstrap/archlinux/arch_bootstrap.yaml +11 -19
- data/templates/steps/bootstrap/debian/debootstrap.yaml +10 -11
- data/templates/steps/bootstrap/debian/debootstrap_arm.yaml +11 -19
- data/templates/steps/bootstrap/fedora/init_pxeboot.yaml +13 -0
- data/templates/steps/bootstrap/fedora/yum_bootstrap.yaml +45 -0
- data/templates/steps/bootstrap/initialize_disk.yaml +16 -0
- data/templates/steps/bootstrap/initialize_disk_chroot.yaml +10 -14
- data/templates/steps/bootstrap/install_requirements.yaml +3 -0
- data/templates/steps/bootstrap/prepare_docker.yaml +7 -7
- data/templates/steps/bootstrap/prepare_qemu.yaml +20 -26
- data/templates/steps/bootstrap/prepare_virtualbox.yaml +63 -0
- data/templates/steps/bootstrap/start_chroot.yaml +2 -13
- data/templates/steps/bootstrap/start_qemu.yaml +50 -53
- data/templates/steps/bootstrap/start_virtualbox.yaml +37 -0
- data/templates/steps/bootstrap/switch_context_qemu.yaml +64 -0
- data/templates/steps/bootstrap/switch_context_virtualbox.yaml +66 -0
- data/templates/steps/breakpoint.yaml +2 -1
- data/templates/steps/checkpoints/docker.yaml +14 -11
- data/templates/steps/checkpoints/qcow2.yaml +26 -24
- data/templates/steps/checkpoints/qemu.yaml +30 -36
- data/templates/steps/checkpoints/virtualbox.yaml +21 -0
- data/templates/steps/disable_checkpoint.yaml +3 -0
- data/templates/steps/enable_checkpoint.yaml +5 -0
- data/templates/steps/export/qemu_save_appliance.yaml +52 -0
- data/templates/steps/export/virtualbox_save_appliance.yaml +67 -0
- data/templates/steps/setup/archlinux/install_bootloader.yaml +23 -0
- data/templates/steps/setup/centos/6.5/configure_network.yaml +31 -0
- data/templates/steps/setup/centos/6.5/configure_system.yaml +27 -0
- data/templates/steps/setup/debian/configure_apt.yaml +1 -6
- data/templates/steps/setup/debian/configure_kernel.yaml +0 -5
- data/templates/steps/setup/debian/install_bootloader.yaml +36 -0
- data/templates/steps/setup/debian/setup_vagrant_box.yaml +48 -18
- data/templates/steps/setup/debian/upgrade_system.yaml +2 -7
- data/templates/steps/setup/fedora/configure_kernel.yaml +9 -0
- data/templates/steps/setup/fedora/configure_keyboard.yaml +12 -0
- data/templates/steps/setup/fedora/configure_network.yaml +9 -1
- data/templates/steps/setup/fedora/configure_system.yaml +20 -45
- data/templates/steps/setup/fedora/install_bootloader.yaml +58 -0
- data/templates/steps/setup/fedora/minimal_install.yaml +3 -0
- data/templates/steps/setup/fedora/update_system.yaml +13 -5
- data/templates/steps/setup/ubuntu/configure_apt.yaml +4 -9
- data/templates/vagrant/debian7-amd64.yaml +130 -0
- data/templates/virtualbox/archlinux-desktop-i686.yaml +25 -0
- data/templates/virtualbox/archlinux-desktop-x86_64.yaml +28 -0
- data/templates/virtualbox/archlinux-i686.yaml +28 -0
- data/templates/virtualbox/archlinux-x86_64.yaml +109 -0
- data/templates/virtualbox/centos6.5-i386.yaml +39 -0
- data/templates/virtualbox/centos6.5-x86_64.yaml +111 -0
- data/templates/virtualbox/centos7-x86_64.yaml +116 -0
- data/{docs/source/debian7.yaml → templates/virtualbox/debian7-amd64.yaml} +53 -52
- data/templates/virtualbox/debian7-desktop-amd64.yaml +25 -0
- data/templates/{fedora-rawhide.yaml → virtualbox/debian7-i386.yaml} +12 -11
- data/templates/virtualbox/debian7-kameleon-amd64.yaml +38 -0
- data/templates/virtualbox/debian7-oar-amd64.yaml +51 -0
- data/templates/{debian-testing.yaml → virtualbox/debian8-amd64.yaml} +3 -3
- data/templates/virtualbox/debian8-i386.yaml +31 -0
- data/templates/virtualbox/fedora20-x86_64.yaml +116 -0
- data/templates/virtualbox/ubuntu-12.04-amd64.yaml +128 -0
- data/templates/virtualbox/ubuntu-12.04-desktop-amd64.yaml +25 -0
- data/templates/virtualbox/ubuntu-14.04-amd64.yaml +25 -0
- data/templates/virtualbox/ubuntu-14.04-desktop-amd64.yaml +27 -0
- data/version.txt +1 -1
- metadata +67 -212
- data/Rakefile +0 -24
- data/docs/.gitignore +0 -1
- data/docs/Makefile +0 -181
- data/docs/README.md +0 -17
- data/docs/make.bat +0 -242
- data/docs/source/_static/.gitignore +0 -0
- data/docs/source/_static/centos.png +0 -0
- data/docs/source/_static/debian.png +0 -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/_static/ubuntu.png +0 -0
- data/docs/source/_themes/sphinx_rtd_theme/__init__.py +0 -17
- data/docs/source/_themes/sphinx_rtd_theme/breadcrumbs.html +0 -19
- data/docs/source/_themes/sphinx_rtd_theme/footer.html +0 -32
- data/docs/source/_themes/sphinx_rtd_theme/layout.html +0 -160
- data/docs/source/_themes/sphinx_rtd_theme/layout_old.html +0 -205
- data/docs/source/_themes/sphinx_rtd_theme/search.html +0 -50
- data/docs/source/_themes/sphinx_rtd_theme/searchbox.html +0 -7
- data/docs/source/_themes/sphinx_rtd_theme/static/css/badge_only.css +0 -1
- data/docs/source/_themes/sphinx_rtd_theme/static/css/theme.css +0 -4
- data/docs/source/_themes/sphinx_rtd_theme/static/fonts/FontAwesome.otf +0 -0
- data/docs/source/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.eot +0 -0
- data/docs/source/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.svg +0 -414
- data/docs/source/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.ttf +0 -0
- data/docs/source/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.woff +0 -0
- data/docs/source/_themes/sphinx_rtd_theme/static/js/theme.js +0 -47
- data/docs/source/_themes/sphinx_rtd_theme/theme.conf +0 -8
- data/docs/source/_themes/sphinx_rtd_theme/versions.html +0 -37
- data/docs/source/aliases.rst +0 -31
- data/docs/source/atlas_debian_g5k.yaml +0 -36
- data/docs/source/checkpoint.rst +0 -30
- data/docs/source/commands.rst +0 -63
- data/docs/source/conf.py +0 -262
- data/docs/source/context.rst +0 -47
- data/docs/source/debian_customized.yaml +0 -28
- data/docs/source/debian_customized_g5k.yaml +0 -21
- data/docs/source/faq.rst +0 -43
- data/docs/source/getting_started.rst +0 -260
- data/docs/source/grid5000_tutorial.rst +0 -525
- data/docs/source/index.rst +0 -53
- data/docs/source/install_atlas.yaml +0 -25
- data/docs/source/install_hpl.yaml +0 -24
- data/docs/source/installation.rst +0 -51
- data/docs/source/persistent_cache.rst +0 -34
- data/docs/source/recipe.rst +0 -177
- data/docs/source/tau_install.yaml +0 -19
- data/docs/source/tau_install_g5k.yaml +0 -25
- data/docs/source/use_cases.rst +0 -93
- data/docs/source/workspace.rst +0 -13
- data/lib/kameleon/logger.rb +0 -56
- data/omnibus/.gitignore +0 -11
- data/omnibus/.kitchen.yml +0 -25
- data/omnibus/Berksfile +0 -9
- data/omnibus/Berksfile.lock +0 -25
- data/omnibus/Gemfile +0 -12
- data/omnibus/README.md +0 -94
- data/omnibus/config/projects/kameleon.rb +0 -23
- data/omnibus/config/software/kameleon.rb +0 -24
- data/omnibus/config/software/polipo.rb +0 -30
- data/omnibus/config/software/ruby.rb +0 -158
- 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 +0 -1
- data/omnibus/files/mac_pkg/Resources/welcome.html +0 -9
- data/omnibus/omnibus.rb +0 -27
- data/omnibus/package-scripts/kameleon/makeselfinst +0 -27
- data/omnibus/package-scripts/kameleon/postrm +0 -9
- data/templates/fedora20.yaml +0 -105
- data/templates/steps/bootstrap/archlinux/install_bootloader.yaml +0 -46
- data/templates/steps/bootstrap/archlinux/populate_disk.yaml +0 -39
- data/templates/steps/bootstrap/fedora/liveos_bootstrap.yaml +0 -123
- data/templates/steps/bootstrap/initialize_disk_qemu.yaml +0 -72
- data/templates/steps/bootstrap/install_bootloader.yaml +0 -42
- data/templates/steps/bootstrap/ubuntu/debootstrap.yaml +0 -27
- data/templates/steps/export/save_appliance.yaml +0 -58
- data/templates/steps/export/save_vagrant_box.yaml +0 -29
- data/templates/vagrant-debian7.yaml +0 -31
data/lib/kameleon/shell.rb
CHANGED
@@ -12,18 +12,17 @@ module Kameleon
|
|
12
12
|
attr :process
|
13
13
|
attr :shell_cmd
|
14
14
|
|
15
|
-
def initialize(context_name, cmd, shell_workdir, local_workdir,
|
16
|
-
@logger = Log4r::Logger.new("kameleon::[kameleon]")
|
15
|
+
def initialize(context_name, cmd, shell_workdir, local_workdir, proxy_cache)
|
17
16
|
@cmd = cmd.chomp
|
18
17
|
@context_name = context_name
|
19
18
|
@local_workdir = local_workdir
|
20
19
|
@shell_workdir = shell_workdir
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
20
|
+
@proxy_cache = proxy_cache
|
21
|
+
@bashrc_file = ".kameleon_#{@context_name}_bash_rc"
|
22
|
+
@bash_history_file = ".kameleon_#{@context_name}_bash_history"
|
23
|
+
@bash_env_file = ".kameleon_#{@context_name}_bash_env"
|
24
24
|
@default_bashrc_file = File.join(Kameleon.source_root,
|
25
|
-
"contrib",
|
26
|
-
"kameleon_bashrc.sh")
|
25
|
+
"contrib", "kameleon_bashrc.sh")
|
27
26
|
if @shell_workdir
|
28
27
|
@bashrc_file = File.join(@shell_workdir, @bashrc_file)
|
29
28
|
@bash_history_file = File.join(@shell_workdir, @bash_history_file)
|
@@ -35,10 +34,10 @@ module Kameleon
|
|
35
34
|
|
36
35
|
@shell_cmd = "source #{@default_bashrc_file} 2> /dev/null; "\
|
37
36
|
"#{@cmd} --rcfile #{@bashrc_file}"
|
38
|
-
|
37
|
+
Kameleon.ui.debug("Initialize shell (#{self})")
|
39
38
|
# Injecting all variables of the options and assign the variables
|
40
39
|
instance_variables.each do |v|
|
41
|
-
|
40
|
+
Kameleon.ui.debug(" #{v} = #{instance_variable_get(v)}")
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
@@ -87,17 +86,29 @@ module Kameleon
|
|
87
86
|
## log shell error message
|
88
87
|
error = read_io(@stderr)
|
89
88
|
init_stdout = read_io(@stdout)
|
90
|
-
|
91
|
-
|
89
|
+
Kameleon.ui.error(error) unless error.empty?
|
90
|
+
Kameleon.ui.info(init_stdout) unless init_stdout.empty?
|
92
91
|
bashrc_content = ""
|
93
92
|
if File.file?(@default_bashrc_file)
|
94
93
|
tpl = ERB.new(File.read(@default_bashrc_file))
|
95
94
|
bashrc_content = tpl.result(binding)
|
96
95
|
if @cache.activated? then
|
97
|
-
|
98
|
-
|
96
|
+
if @proxy_cache.nil? then
|
97
|
+
Kameleon.ui.warn("Variable 'proxy_cache' not defined for this context, persistent cache will not be generated")
|
98
|
+
else
|
99
|
+
tpl = ERB.new(File.read(@cache.polipo_env))
|
100
|
+
bashrc_content << "\n" + ERB.new(File.read(@cache.polipo_env)).result(binding)
|
101
|
+
end
|
99
102
|
end
|
100
103
|
end
|
104
|
+
# Inject sigint handler
|
105
|
+
bashrc_content << <<-SCRIPT
|
106
|
+
function save_state_handler {
|
107
|
+
echo "Saved ENV in #{@bash_env_file} file"
|
108
|
+
(comm -3 <(declare | sort) <(declare -f | sort)) > #{@bash_env_file}
|
109
|
+
}
|
110
|
+
trap save_state_handler EXIT
|
111
|
+
SCRIPT
|
101
112
|
bashrc = Shellwords.escape(bashrc_content)
|
102
113
|
if @shell_workdir
|
103
114
|
unless @shell_workdir.eql? "/"
|
@@ -114,6 +125,7 @@ module Kameleon
|
|
114
125
|
end
|
115
126
|
shell_cmd << "source #{@bashrc_file}\n"
|
116
127
|
shell_cmd << "export KAMELEON_WORKDIR=$PWD\n"
|
128
|
+
shell_cmd << "(comm -3 <(declare | sort) <(declare -f | sort)) > #{@bash_env_file}\n"
|
117
129
|
shell_cmd
|
118
130
|
end
|
119
131
|
|
@@ -124,11 +136,11 @@ module Kameleon
|
|
124
136
|
shell_cmd << init_shell_cmd
|
125
137
|
@sent_first_cmd = true
|
126
138
|
end
|
139
|
+
shell_cmd << "source #{@bash_env_file} 2> /dev/null || true\n"
|
127
140
|
shell_cmd << "KAMELEON_LAST_COMMAND=#{Shellwords.escape(cmd.value)}\n"
|
128
|
-
shell_cmd << "( set -o posix ; set ) > #{@bash_env_file}\n"
|
129
|
-
shell_cmd << "env | xargs -I {} echo export {} >> #{@bash_env_file}\n"
|
130
141
|
shell_cmd << "#{ cmd.value }\nexport __exit_status__=$?\n"
|
131
142
|
shell_cmd << "#{ ECHO_CMD } $KAMELEON_LAST_COMMAND >> \"$HISTFILE\"\n"
|
143
|
+
shell_cmd << "(comm -3 <(declare | sort) <(declare -f | sort)) > #{@bash_env_file}\n"
|
132
144
|
shell_cmd << "#{ ECHO_CMD } -n #{ cmd.end_err } 1>&2\n"
|
133
145
|
shell_cmd << "#{ ECHO_CMD } -n #{ cmd.end_out }\n"
|
134
146
|
@process.io.stdin.puts shell_cmd
|
@@ -156,6 +168,9 @@ module Kameleon
|
|
156
168
|
:yield => lambda{|buf| yield(buf, nil)} }
|
157
169
|
}
|
158
170
|
while true
|
171
|
+
if @process.exited?
|
172
|
+
raise ShellError, "Process '#{@cmd}' exited..."
|
173
|
+
end
|
159
174
|
iodata.each do |_, iodat|
|
160
175
|
if iodat[:end] and not iodat[:begin]
|
161
176
|
raise ShellError, "Cannot read #{iodat[:begin]} from shell"
|
@@ -246,8 +261,8 @@ module Kameleon
|
|
246
261
|
|
247
262
|
def fork(io)
|
248
263
|
command = ["bash", "-c", @shell_cmd]
|
249
|
-
|
250
|
-
|
264
|
+
Kameleon.ui.info("Starting process: #{@cmd.inspect}")
|
265
|
+
Kameleon.ui.debug("Starting shell process: #{ command.inspect}")
|
251
266
|
ChildProcess.posix_spawn = true
|
252
267
|
process = ChildProcess.build(*command)
|
253
268
|
# Create the pipes so we can read the output in real time as
|
data/lib/kameleon/step.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
module Kameleon
|
2
2
|
|
3
3
|
class Command
|
4
|
+
|
4
5
|
attr_accessor :string_cmd
|
5
6
|
attr_accessor :microstep_name
|
7
|
+
attr_accessor :identifier
|
6
8
|
|
7
9
|
def initialize(yaml_cmd, microstep_name)
|
8
10
|
@string_cmd = YAML.dump(yaml_cmd).gsub("---", "").strip
|
9
11
|
@microstep_name = microstep_name
|
12
|
+
@identifier = nil
|
10
13
|
end
|
11
14
|
|
12
15
|
def resolve!
|
@@ -16,7 +19,12 @@ module Kameleon
|
|
16
19
|
|
17
20
|
def key
|
18
21
|
if @key.nil?
|
19
|
-
|
22
|
+
object = YAML.load(@string_cmd)
|
23
|
+
if object.kind_of? String
|
24
|
+
@key = object
|
25
|
+
else
|
26
|
+
@key = object.keys.first
|
27
|
+
end
|
20
28
|
end
|
21
29
|
@key
|
22
30
|
rescue
|
@@ -30,6 +38,8 @@ module Kameleon
|
|
30
38
|
object = YAML.load(@string_cmd)
|
31
39
|
if object.kind_of? Command
|
32
40
|
@value = object
|
41
|
+
elsif object.kind_of? String
|
42
|
+
@value = nil
|
33
43
|
else
|
34
44
|
raise RecipeError unless object.kind_of? Hash
|
35
45
|
raise RecipeError unless object.keys.count == 1
|
@@ -68,6 +78,7 @@ module Kameleon
|
|
68
78
|
@value.gsub!(arg1, arg2)
|
69
79
|
end
|
70
80
|
@string_cmd = YAML.dump(to_array).gsub("---", "").strip
|
81
|
+
return self
|
71
82
|
end
|
72
83
|
|
73
84
|
end
|
@@ -122,6 +133,11 @@ module Kameleon
|
|
122
133
|
commands_str = @commands.map { |cmd| cmd.string_cmd.to_s }
|
123
134
|
content_id = commands_str.join(' ') + salt
|
124
135
|
@identifier = "#{ Digest::SHA1.hexdigest content_id }"[0..11]
|
136
|
+
@commands.each do |cmd|
|
137
|
+
map_id = cmd.string_cmd.to_s + @identifier
|
138
|
+
cmd.identifier = "#{ Digest::SHA1.hexdigest map_id }"[0..11]
|
139
|
+
end
|
140
|
+
@identifier
|
125
141
|
end
|
126
142
|
|
127
143
|
def to_array
|
@@ -216,6 +232,7 @@ module Kameleon
|
|
216
232
|
"identifier" => microstep.identifier.to_s,
|
217
233
|
"cmds" => microstep.to_array
|
218
234
|
}
|
235
|
+
|
219
236
|
section_array.push({ microstep.slug => hash })
|
220
237
|
end
|
221
238
|
end
|
data/lib/kameleon/ui.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
module Kameleon
|
2
|
+
module UI
|
3
|
+
|
4
|
+
class Silent
|
5
|
+
def info(message, newline = nil)
|
6
|
+
end
|
7
|
+
|
8
|
+
def confirm(message, newline = nil)
|
9
|
+
end
|
10
|
+
|
11
|
+
def warn(message, newline = nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
def error(message, newline = nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
def debug(message, newline = nil)
|
18
|
+
end
|
19
|
+
|
20
|
+
def debug?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
def quiet?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
def ask(message)
|
29
|
+
end
|
30
|
+
|
31
|
+
def level=(name)
|
32
|
+
end
|
33
|
+
|
34
|
+
def level(name = nil)
|
35
|
+
end
|
36
|
+
|
37
|
+
def trace(message, newline = nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
def silence
|
41
|
+
yield
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Shell
|
46
|
+
LEVELS = %w(silent error warn confirm info debug)
|
47
|
+
|
48
|
+
attr_accessor :shell
|
49
|
+
|
50
|
+
def initialize(options = {})
|
51
|
+
@shell = Thor::Base.shell.new
|
52
|
+
@level = ENV['KAMELEON_DEBUG'] ? "debug" : "info"
|
53
|
+
end
|
54
|
+
|
55
|
+
def info(msg, newline = nil)
|
56
|
+
tell_me(msg, nil, newline) if level("info")
|
57
|
+
end
|
58
|
+
|
59
|
+
def confirm(msg, newline = nil)
|
60
|
+
tell_me(msg, :green, newline) if level("confirm")
|
61
|
+
end
|
62
|
+
|
63
|
+
def warn(msg, newline = nil)
|
64
|
+
tell_me(msg, :yellow, newline) if level("warn")
|
65
|
+
end
|
66
|
+
|
67
|
+
def error(msg, newline = nil)
|
68
|
+
tell_me(msg, :red, newline) if level("error")
|
69
|
+
end
|
70
|
+
|
71
|
+
def debug(msg, newline = nil)
|
72
|
+
tell_me("[debug] #{msg}", nil, newline) if level("debug")
|
73
|
+
end
|
74
|
+
|
75
|
+
def debug?
|
76
|
+
# needs to be false instead of nil to be newline param to other methods
|
77
|
+
level("debug")
|
78
|
+
end
|
79
|
+
|
80
|
+
def quiet?
|
81
|
+
LEVELS.index(@level) <= LEVELS.index("warn")
|
82
|
+
end
|
83
|
+
|
84
|
+
def ask(msg)
|
85
|
+
@shell.ask(msg)
|
86
|
+
end
|
87
|
+
|
88
|
+
def level=(level)
|
89
|
+
raise ArgumentError unless LEVELS.include?(level.to_s)
|
90
|
+
@level = level
|
91
|
+
end
|
92
|
+
|
93
|
+
def level(name = nil)
|
94
|
+
name ? LEVELS.index(name) <= LEVELS.index(@level) : @level
|
95
|
+
end
|
96
|
+
|
97
|
+
def trace(e, newline = nil)
|
98
|
+
msg = ["#{e.class}: #{e.message}", *e.backtrace].join("\n")
|
99
|
+
if debug?
|
100
|
+
tell_me(msg, nil, newline)
|
101
|
+
elsif @trace
|
102
|
+
STDERR.puts "#{msg}#{newline}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def silence
|
107
|
+
old_level, @level = @level, "silent"
|
108
|
+
yield
|
109
|
+
ensure
|
110
|
+
@level = old_level
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
# valimism
|
116
|
+
def tell_me(msg, color = nil, newline = nil)
|
117
|
+
msg = word_wrap(msg) if newline.is_a?(Hash) && newline[:wrap]
|
118
|
+
if newline.nil?
|
119
|
+
if Kameleon.log_on_progress
|
120
|
+
Kameleon.log_on_progress = false
|
121
|
+
msg = "\n" + msg
|
122
|
+
end
|
123
|
+
@shell.say(msg, color)
|
124
|
+
else
|
125
|
+
@shell.say(msg, color, newline)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def strip_leading_spaces(text)
|
130
|
+
spaces = text[/\A\s+/, 0]
|
131
|
+
spaces ? text.gsub(/#{spaces}/, '') : text
|
132
|
+
end
|
133
|
+
|
134
|
+
def word_wrap(text, line_width = @shell.terminal_width)
|
135
|
+
strip_leading_spaces(text).split("\n").collect do |line|
|
136
|
+
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
|
137
|
+
end * "\n"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/lib/kameleon/utils.rb
CHANGED
@@ -43,5 +43,14 @@ module Kameleon
|
|
43
43
|
rescue
|
44
44
|
end
|
45
45
|
|
46
|
+
def self.copy_files(relative_dir, dest_dir, files2copy)
|
47
|
+
files2copy.each do |path|
|
48
|
+
relative_path = path.relative_path_from(relative_dir)
|
49
|
+
dst = File.join(dest_dir,relative_path)
|
50
|
+
FileUtils.mkdir_p File.dirname(dst)
|
51
|
+
FileUtils.copy_file(path, dst)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
46
55
|
end
|
47
56
|
end
|
@@ -21,6 +21,8 @@ global:
|
|
21
21
|
distrib: debian
|
22
22
|
release: wheezy
|
23
23
|
arch: amd64
|
24
|
+
kernel_arch: $$arch
|
25
|
+
hostname: kameleon-$$distrib
|
24
26
|
|
25
27
|
## Disk options
|
26
28
|
nbd_device: /dev/nbd1
|
@@ -30,7 +32,6 @@ global:
|
|
30
32
|
|
31
33
|
# rootfs options
|
32
34
|
rootfs: $$kameleon_cwd/rootfs
|
33
|
-
rootfs_download_path: /var/cache/kameleon/$$distrib/$$release/$$arch/rootfs
|
34
35
|
|
35
36
|
## System variables. Required by kameleon engine
|
36
37
|
# Include specific steps
|
@@ -38,33 +39,36 @@ global:
|
|
38
39
|
- $$distrib/$$release
|
39
40
|
- $$distrib
|
40
41
|
|
42
|
+
# Apt options
|
43
|
+
apt_repository: http://ftp.debian.org/debian/
|
44
|
+
apt_enable_contrib: true
|
45
|
+
apt_enable_nonfree: true
|
46
|
+
|
41
47
|
# Shell session from where we launch exec_out commands. There is often a
|
42
48
|
# local bash session, but it can be a remote shell on other machines or on
|
43
49
|
# any shell. (eg. bash, chroot, fakechroot, ssh, tmux, lxc...)
|
44
50
|
out_context:
|
45
51
|
cmd: bash
|
46
52
|
workdir: $$kameleon_cwd
|
47
|
-
|
53
|
+
proxy_cache: 127.0.0.1
|
48
54
|
# Shell session that allows us to connect to the building machine in order to
|
49
55
|
# configure it and setup additional programs
|
50
56
|
in_context:
|
51
57
|
cmd: USER=root HOME=/root LC_ALL=POSIX chroot $$kameleon_cwd/rootfs bash
|
52
58
|
workdir: /root/kameleon_workdir
|
59
|
+
proxy_cache: 127.0.0.1
|
53
60
|
|
54
61
|
#== Bootstrap the new system and create the 'in_context'
|
55
62
|
bootstrap:
|
63
|
+
- initialize_disk_chroot
|
64
|
+
- enable_checkpoint
|
56
65
|
- debootstrap:
|
57
|
-
- include_pkg:
|
58
|
-
ifupdown locales libui-dialog-perl dialog isc-dhcp-client netbase
|
59
|
-
net-tools iproute acpid openssh-server pciutils extlinux
|
60
|
-
linux-image-$$arch
|
66
|
+
- include_pkg: apt-utils ca-certificates locales less
|
61
67
|
- release: $$release
|
62
68
|
- arch: $$arch
|
63
|
-
- repository: http://ftp.
|
64
|
-
-
|
65
|
-
- initialize_disk_chroot
|
69
|
+
- repository: http://ftp.debian.org/debian/
|
70
|
+
- variant: minbase
|
66
71
|
- start_chroot
|
67
|
-
- install_bootloader
|
68
72
|
|
69
73
|
#== Install and configuration steps
|
70
74
|
# WARNING: this part should be independante from the out context (whenever
|
@@ -72,16 +76,18 @@ bootstrap:
|
|
72
76
|
setup:
|
73
77
|
# Install
|
74
78
|
- configure_apt:
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
79
|
+
- repository: $$apt_repository
|
80
|
+
- enable_contrib_repo: $$apt_enable_contrib
|
81
|
+
- enable_nonfree_repo: $$apt_enable_nonfree
|
78
82
|
- upgrade_system:
|
79
83
|
- dist_upgrade: true
|
80
84
|
- install_software:
|
81
85
|
- packages: >
|
82
|
-
debian-keyring ntp
|
83
|
-
|
84
|
-
|
86
|
+
debian-keyring ntp sudo less vim bash-completion curl less acpid
|
87
|
+
linux-image-$$kernel_arch isc-dhcp-client isc-dhcp-common ifupdown
|
88
|
+
iptables iputils-ping iproute pciutils psmisc resolvconf extlinux
|
89
|
+
- configure_kernel
|
90
|
+
- install_bootloader
|
85
91
|
# Configuration
|
86
92
|
- configure_system:
|
87
93
|
- locales: POSIX C en_US fr_FR de_DE
|
@@ -89,8 +95,7 @@ setup:
|
|
89
95
|
- timezone: UTC
|
90
96
|
- configure_keyboard:
|
91
97
|
- layout: "us,fr,de"
|
92
|
-
- configure_network
|
93
|
-
- hostname: kameleon-$$distrib
|
98
|
+
- configure_network
|
94
99
|
- create_group:
|
95
100
|
- name: admin
|
96
101
|
- create_user:
|
@@ -100,12 +105,15 @@ setup:
|
|
100
105
|
|
101
106
|
#== Export the generated appliance in the format of your choice
|
102
107
|
export:
|
103
|
-
-
|
104
|
-
|
108
|
+
- disable_checkpoint
|
109
|
+
- qemu_save_appliance:
|
110
|
+
- input: $$image_disk
|
105
111
|
- output: $$kameleon_cwd/$$kameleon_recipe_name
|
106
112
|
- save_as_qcow2
|
107
113
|
# - save_as_qed
|
108
|
-
# -
|
114
|
+
# - save_as_tar_gz
|
115
|
+
# - save_as_tar_xz
|
116
|
+
# - save_as_tar_bz2
|
109
117
|
# - save_as_raw
|
110
118
|
# - save_as_vmdk
|
111
119
|
# - save_as_vdi
|