kameleon-builder 2.1.3 → 2.2.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.
Files changed (185) hide show
  1. data/.editorconfig +0 -0
  2. data/.env +2 -6
  3. data/CHANGELOG.rst +74 -1
  4. data/Gemfile +20 -2
  5. data/README.rst +35 -25
  6. data/Thorfile +29 -0
  7. data/contrib/kameleon_bashrc.sh +61 -0
  8. data/contrib/polipo_env.sh +3 -2
  9. data/kameleon-builder.gemspec +3 -10
  10. data/lib/kameleon.rb +10 -14
  11. data/lib/kameleon/cli.rb +92 -105
  12. data/lib/kameleon/context.rb +76 -43
  13. data/lib/kameleon/engine.rb +147 -103
  14. data/lib/kameleon/environment.rb +10 -5
  15. data/lib/kameleon/error.rb +1 -32
  16. data/lib/kameleon/persistent_cache.rb +127 -29
  17. data/lib/kameleon/recipe.rb +63 -106
  18. data/lib/kameleon/shell.rb +32 -17
  19. data/lib/kameleon/step.rb +18 -1
  20. data/lib/kameleon/ui.rb +141 -0
  21. data/lib/kameleon/utils.rb +9 -0
  22. data/templates/{debian7-chroot.yaml → chroot/debian7-amd64.yaml} +29 -21
  23. data/templates/{docker-debian7.yaml → docker/debian7.yaml} +5 -5
  24. data/templates/extend.erb +2 -2
  25. data/templates/{debian7-g5k.yaml → grid5000/debian7.yaml} +1 -1
  26. data/templates/{archlinux-desktop.yaml → qemu/archlinux-desktop-i686.yaml} +2 -2
  27. data/templates/qemu/archlinux-desktop-x86_64.yaml +25 -0
  28. data/templates/qemu/archlinux-i686.yaml +25 -0
  29. data/templates/{archlinux.yaml → qemu/archlinux-x86_64.yaml} +37 -34
  30. data/templates/qemu/centos6.5-x86_64.yaml +113 -0
  31. data/templates/qemu/centos7-x86_64.yaml +119 -0
  32. data/templates/{debian7.yaml → qemu/debian7-amd64.yaml} +45 -40
  33. data/templates/{debian7-desktop.yaml → qemu/debian7-desktop-amd64.yaml} +2 -3
  34. data/templates/{debian7-kameleon.yaml → qemu/debian7-kameleon-amd64.yaml} +3 -6
  35. data/templates/{debian7-oar-dev.yaml → qemu/debian7-oar-amd64.yaml} +2 -2
  36. data/templates/qemu/debian8-amd64.yaml +25 -0
  37. data/templates/{fedora20-desktop.yaml → qemu/fedora20-desktop-x86_64.yaml} +2 -2
  38. data/templates/qemu/fedora20-x86_64.yaml +116 -0
  39. data/templates/{ubuntu-12.04.yaml → qemu/ubuntu-12.04-amd64.yaml} +42 -38
  40. data/templates/{ubuntu-12.04-desktop.yaml → qemu/ubuntu-12.04-desktop-amd64.yaml} +3 -3
  41. data/templates/{ubuntu-14.04.yaml → qemu/ubuntu-14.04-amd64.yaml} +2 -2
  42. data/templates/{ubuntu-14.04-desktop.yaml → qemu/ubuntu-14.04-desktop-amd64.yaml} +2 -2
  43. data/templates/steps/aliases/defaults.yaml +19 -13
  44. data/templates/steps/bootstrap/archlinux/arch_bootstrap.yaml +11 -19
  45. data/templates/steps/bootstrap/debian/debootstrap.yaml +10 -11
  46. data/templates/steps/bootstrap/debian/debootstrap_arm.yaml +11 -19
  47. data/templates/steps/bootstrap/fedora/init_pxeboot.yaml +13 -0
  48. data/templates/steps/bootstrap/fedora/yum_bootstrap.yaml +45 -0
  49. data/templates/steps/bootstrap/initialize_disk.yaml +16 -0
  50. data/templates/steps/bootstrap/initialize_disk_chroot.yaml +10 -14
  51. data/templates/steps/bootstrap/install_requirements.yaml +3 -0
  52. data/templates/steps/bootstrap/prepare_docker.yaml +7 -7
  53. data/templates/steps/bootstrap/prepare_qemu.yaml +20 -26
  54. data/templates/steps/bootstrap/prepare_virtualbox.yaml +63 -0
  55. data/templates/steps/bootstrap/start_chroot.yaml +2 -13
  56. data/templates/steps/bootstrap/start_qemu.yaml +50 -53
  57. data/templates/steps/bootstrap/start_virtualbox.yaml +37 -0
  58. data/templates/steps/bootstrap/switch_context_qemu.yaml +64 -0
  59. data/templates/steps/bootstrap/switch_context_virtualbox.yaml +66 -0
  60. data/templates/steps/breakpoint.yaml +2 -1
  61. data/templates/steps/checkpoints/docker.yaml +14 -11
  62. data/templates/steps/checkpoints/qcow2.yaml +26 -24
  63. data/templates/steps/checkpoints/qemu.yaml +30 -36
  64. data/templates/steps/checkpoints/virtualbox.yaml +21 -0
  65. data/templates/steps/disable_checkpoint.yaml +3 -0
  66. data/templates/steps/enable_checkpoint.yaml +5 -0
  67. data/templates/steps/export/qemu_save_appliance.yaml +52 -0
  68. data/templates/steps/export/virtualbox_save_appliance.yaml +67 -0
  69. data/templates/steps/setup/archlinux/install_bootloader.yaml +23 -0
  70. data/templates/steps/setup/centos/6.5/configure_network.yaml +31 -0
  71. data/templates/steps/setup/centos/6.5/configure_system.yaml +27 -0
  72. data/templates/steps/setup/debian/configure_apt.yaml +1 -6
  73. data/templates/steps/setup/debian/configure_kernel.yaml +0 -5
  74. data/templates/steps/setup/debian/install_bootloader.yaml +36 -0
  75. data/templates/steps/setup/debian/setup_vagrant_box.yaml +48 -18
  76. data/templates/steps/setup/debian/upgrade_system.yaml +2 -7
  77. data/templates/steps/setup/fedora/configure_kernel.yaml +9 -0
  78. data/templates/steps/setup/fedora/configure_keyboard.yaml +12 -0
  79. data/templates/steps/setup/fedora/configure_network.yaml +9 -1
  80. data/templates/steps/setup/fedora/configure_system.yaml +20 -45
  81. data/templates/steps/setup/fedora/install_bootloader.yaml +58 -0
  82. data/templates/steps/setup/fedora/minimal_install.yaml +3 -0
  83. data/templates/steps/setup/fedora/update_system.yaml +13 -5
  84. data/templates/steps/setup/ubuntu/configure_apt.yaml +4 -9
  85. data/templates/vagrant/debian7-amd64.yaml +130 -0
  86. data/templates/virtualbox/archlinux-desktop-i686.yaml +25 -0
  87. data/templates/virtualbox/archlinux-desktop-x86_64.yaml +28 -0
  88. data/templates/virtualbox/archlinux-i686.yaml +28 -0
  89. data/templates/virtualbox/archlinux-x86_64.yaml +109 -0
  90. data/templates/virtualbox/centos6.5-i386.yaml +39 -0
  91. data/templates/virtualbox/centos6.5-x86_64.yaml +111 -0
  92. data/templates/virtualbox/centos7-x86_64.yaml +116 -0
  93. data/{docs/source/debian7.yaml → templates/virtualbox/debian7-amd64.yaml} +53 -52
  94. data/templates/virtualbox/debian7-desktop-amd64.yaml +25 -0
  95. data/templates/{fedora-rawhide.yaml → virtualbox/debian7-i386.yaml} +12 -11
  96. data/templates/virtualbox/debian7-kameleon-amd64.yaml +38 -0
  97. data/templates/virtualbox/debian7-oar-amd64.yaml +51 -0
  98. data/templates/{debian-testing.yaml → virtualbox/debian8-amd64.yaml} +3 -3
  99. data/templates/virtualbox/debian8-i386.yaml +31 -0
  100. data/templates/virtualbox/fedora20-x86_64.yaml +116 -0
  101. data/templates/virtualbox/ubuntu-12.04-amd64.yaml +128 -0
  102. data/templates/virtualbox/ubuntu-12.04-desktop-amd64.yaml +25 -0
  103. data/templates/virtualbox/ubuntu-14.04-amd64.yaml +25 -0
  104. data/templates/virtualbox/ubuntu-14.04-desktop-amd64.yaml +27 -0
  105. data/version.txt +1 -1
  106. metadata +67 -212
  107. data/Rakefile +0 -24
  108. data/docs/.gitignore +0 -1
  109. data/docs/Makefile +0 -181
  110. data/docs/README.md +0 -17
  111. data/docs/make.bat +0 -242
  112. data/docs/source/_static/.gitignore +0 -0
  113. data/docs/source/_static/centos.png +0 -0
  114. data/docs/source/_static/debian.png +0 -0
  115. data/docs/source/_static/kameleon-logo.png +0 -0
  116. data/docs/source/_static/kameleon-logo.xcf +0 -0
  117. data/docs/source/_static/kameleon-long.png +0 -0
  118. data/docs/source/_static/ubuntu.png +0 -0
  119. data/docs/source/_themes/sphinx_rtd_theme/__init__.py +0 -17
  120. data/docs/source/_themes/sphinx_rtd_theme/breadcrumbs.html +0 -19
  121. data/docs/source/_themes/sphinx_rtd_theme/footer.html +0 -32
  122. data/docs/source/_themes/sphinx_rtd_theme/layout.html +0 -160
  123. data/docs/source/_themes/sphinx_rtd_theme/layout_old.html +0 -205
  124. data/docs/source/_themes/sphinx_rtd_theme/search.html +0 -50
  125. data/docs/source/_themes/sphinx_rtd_theme/searchbox.html +0 -7
  126. data/docs/source/_themes/sphinx_rtd_theme/static/css/badge_only.css +0 -1
  127. data/docs/source/_themes/sphinx_rtd_theme/static/css/theme.css +0 -4
  128. data/docs/source/_themes/sphinx_rtd_theme/static/fonts/FontAwesome.otf +0 -0
  129. data/docs/source/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.eot +0 -0
  130. data/docs/source/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.svg +0 -414
  131. data/docs/source/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.ttf +0 -0
  132. data/docs/source/_themes/sphinx_rtd_theme/static/fonts/fontawesome-webfont.woff +0 -0
  133. data/docs/source/_themes/sphinx_rtd_theme/static/js/theme.js +0 -47
  134. data/docs/source/_themes/sphinx_rtd_theme/theme.conf +0 -8
  135. data/docs/source/_themes/sphinx_rtd_theme/versions.html +0 -37
  136. data/docs/source/aliases.rst +0 -31
  137. data/docs/source/atlas_debian_g5k.yaml +0 -36
  138. data/docs/source/checkpoint.rst +0 -30
  139. data/docs/source/commands.rst +0 -63
  140. data/docs/source/conf.py +0 -262
  141. data/docs/source/context.rst +0 -47
  142. data/docs/source/debian_customized.yaml +0 -28
  143. data/docs/source/debian_customized_g5k.yaml +0 -21
  144. data/docs/source/faq.rst +0 -43
  145. data/docs/source/getting_started.rst +0 -260
  146. data/docs/source/grid5000_tutorial.rst +0 -525
  147. data/docs/source/index.rst +0 -53
  148. data/docs/source/install_atlas.yaml +0 -25
  149. data/docs/source/install_hpl.yaml +0 -24
  150. data/docs/source/installation.rst +0 -51
  151. data/docs/source/persistent_cache.rst +0 -34
  152. data/docs/source/recipe.rst +0 -177
  153. data/docs/source/tau_install.yaml +0 -19
  154. data/docs/source/tau_install_g5k.yaml +0 -25
  155. data/docs/source/use_cases.rst +0 -93
  156. data/docs/source/workspace.rst +0 -13
  157. data/lib/kameleon/logger.rb +0 -56
  158. data/omnibus/.gitignore +0 -11
  159. data/omnibus/.kitchen.yml +0 -25
  160. data/omnibus/Berksfile +0 -9
  161. data/omnibus/Berksfile.lock +0 -25
  162. data/omnibus/Gemfile +0 -12
  163. data/omnibus/README.md +0 -94
  164. data/omnibus/config/projects/kameleon.rb +0 -23
  165. data/omnibus/config/software/kameleon.rb +0 -24
  166. data/omnibus/config/software/polipo.rb +0 -30
  167. data/omnibus/config/software/ruby.rb +0 -158
  168. data/omnibus/files/mac_dmg/Resources/background.png +0 -0
  169. data/omnibus/files/mac_dmg/Resources/icon.png +0 -0
  170. data/omnibus/files/mac_pkg/Resources/background.png +0 -0
  171. data/omnibus/files/mac_pkg/Resources/license.html +0 -1
  172. data/omnibus/files/mac_pkg/Resources/welcome.html +0 -9
  173. data/omnibus/omnibus.rb +0 -27
  174. data/omnibus/package-scripts/kameleon/makeselfinst +0 -27
  175. data/omnibus/package-scripts/kameleon/postrm +0 -9
  176. data/templates/fedora20.yaml +0 -105
  177. data/templates/steps/bootstrap/archlinux/install_bootloader.yaml +0 -46
  178. data/templates/steps/bootstrap/archlinux/populate_disk.yaml +0 -39
  179. data/templates/steps/bootstrap/fedora/liveos_bootstrap.yaml +0 -123
  180. data/templates/steps/bootstrap/initialize_disk_qemu.yaml +0 -72
  181. data/templates/steps/bootstrap/install_bootloader.yaml +0 -42
  182. data/templates/steps/bootstrap/ubuntu/debootstrap.yaml +0 -27
  183. data/templates/steps/export/save_appliance.yaml +0 -58
  184. data/templates/steps/export/save_vagrant_box.yaml +0 -29
  185. data/templates/vagrant-debian7.yaml +0 -31
data/.editorconfig CHANGED
File without changes
data/.env CHANGED
@@ -13,11 +13,7 @@ QEMU_MONITOR_PORT=11023
13
13
 
14
14
 
15
15
  function kameleon {
16
- sudo -E BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile bundle exec kameleon $@
17
- }
18
-
19
- function runtest {
20
- sudo -E BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile bundle exec rake $@
16
+ BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile bundle exec kameleon $@
21
17
  }
22
18
 
23
19
  function devrun_chroot_clean() {
@@ -88,7 +84,7 @@ function devrun_qemu() {
88
84
  function devrun_build() {
89
85
  KAMELEON_WORKDIR=${KAMELEON_WORKDIR:-"/tmp/kameleon/"}
90
86
  RECIPE_DEV_NAME=${RECIPE_DEV_NAME:-"mymachine"}
91
- TEMPLATE=${1:-"debian7"}
87
+ TEMPLATE=${1:-"chroot/debian7"}
92
88
  mkdir -p $KAMELEON_WORKDIR && cd $KAMELEON_WORKDIR
93
89
  cmd="kameleon new $RECIPE_DEV_NAME $TEMPLATE \
94
90
  && kameleon build $RECIPE_DEV_NAME.yaml"
data/CHANGELOG.rst CHANGED
@@ -1,9 +1,81 @@
1
1
  Kameleon CHANGELOG
2
2
  ==================
3
3
 
4
+ version 2.2.0
5
+ -------------
6
+
7
+ Released on July 20th 2014
8
+
9
+ - [proxy cache] Added ``proxy_cache`` recipe option to context_in/out to enable
10
+ persistant cache for every context
11
+ - [proxy cache] Added ``--cache-path`` CLI option to set different cache directory
12
+ - [proxy cache] Shared cache directory between recipes by default
13
+ - [proxy cache] No more internal cache for debootstrap
14
+ - [proxy_cache] Polipo does not use default config file anymore
15
+ - [proxy_cache] Recipe is now stored in cache at the end
16
+ - [package] Removed diffy from dependencies
17
+ - [package] Removed log4r-color from dependencies
18
+ - [core] Rewrote checkpoint mechanism. (allow to run multiple commands)
19
+ - [core] Added ``--script`` CLI option to enable non-interactive mode
20
+ - [core] Added ``reload_context`` command that reloads the context from the recipe
21
+ - [core] From now on, Kameleon tries to clean all contexts without blocking the shell
22
+ - [core] Improved cleaning contexts upon interruption
23
+ - [core] If microstep is marked as ``redo`` or ``skip`` (on checkpoint), the ID will be independent from other steps
24
+ - [template] Grouped templates by virtualization tools
25
+ - [template] Removed extlinux timeout for debian
26
+ - [template] Configured apt to install recommended packages by default
27
+ - [template] Added architecture type in templates description
28
+ - [template] Forced killing qemu with sigterm signal
29
+ - [template] Removed ssh ControlPath option
30
+ - [template] Used parted tool in script mode
31
+ - [template] Added a timeout during startup and shutdown VMs
32
+ - [template] Restored eth0 as default interface in Fedora (net.ifnames=0 biosdevname=0)
33
+ - [template] Ensured that the checkpoint was disabled at the beginning of the recipe
34
+ - [template] Make sure that qemu is stopped at the end
35
+ - [template] Replaced netcat by socat
36
+ - [template] Removed duplicated ubuntu repository (restricted)
37
+ - [template] Used a debian-jessie iso to bootstrap the out_context with a minimal linux system
38
+ - [template] Hide default kameleon state files
39
+ - [template] Enabled debug mode with ``KAMELEON_DEBUG=1`` environment variable
40
+ - [template] Added ``download_file`` alias that uses curl/wget or python to download files
41
+ - [template] Enabled kvm only if available
42
+ - [template] Do not run qemu with nohup (Use ``-daemonize`` instead)
43
+ - [template] Improved context_out/in log readability
44
+ - [template] Removed fedora-rawhide templates
45
+ - [template] Added new templates :
46
+
47
+ - qemu/archlinux-desktop-i686
48
+ - qemu/archlinux-i686
49
+ - qemu/centos6.5-x86_64
50
+ - qemu/centos7-x86_64
51
+ - qemu/debian8-amd64
52
+ - vagrant/debian7-amd64
53
+ - virtualbox/archlinux-desktop-i686
54
+ - virtualbox/archlinux-desktop-x86_64
55
+ - virtualbox/archlinux-i686
56
+ - virtualbox/archlinux-x86_64
57
+ - virtualbox/centos6.5-i386
58
+ - virtualbox/centos6.5-x86_64
59
+ - virtualbox/centos7-x86_64
60
+ - virtualbox/debian7-amd64
61
+ - virtualbox/debian7-desktop-amd64
62
+ - virtualbox/debian7-i386
63
+ - virtualbox/debian7-kameleon-amd64
64
+ - virtualbox/debian7-oar-amd64
65
+ - virtualbox/debian8-amd64
66
+ - virtualbox/debian8-i386
67
+ - virtualbox/fedora20-x86_64
68
+ - virtualbox/ubuntu-12.04-amd64
69
+ - virtualbox/ubuntu-12.04-desktop-amd64
70
+ - virtualbox/ubuntu-14.04-amd64
71
+ - virtualbox/ubuntu-14.04-desktop-amd64
72
+
73
+
4
74
  version 2.1.3
5
75
  -------------
6
76
 
77
+ Released on June 16th 2014
78
+
7
79
  - [core] Loading dependent gems based on the users ruby version
8
80
  - [core] Getting back compatibility with ruby 1.8.7
9
81
  - [core] Don't fail if context is not ready
@@ -14,7 +86,7 @@ version 2.1.3
14
86
  version 2.1.0
15
87
  -------------
16
88
 
17
- Released on May 12th 2014
89
+ Released on June 12th 2014
18
90
 
19
91
  - [core] Fixed psych yaml parsing (#1)
20
92
  - [core] Changed option ``--no-no-color`` to ``--color``
@@ -95,3 +167,4 @@ version 2.0.0
95
167
  Released on February 17th 2014
96
168
 
97
169
  Initial public release of kameleon 2
170
+
data/Gemfile CHANGED
@@ -1,4 +1,22 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
+
3
+ gem "syck", :platforms => [:ruby_20, :ruby_21]
4
+
5
+ group :development do
6
+ gem "pry"
7
+ gem "rake"
8
+ platforms :ruby_19, :ruby_20 do
9
+ gem "pry-debugger"
10
+ gem "pry-stack_explorer"
11
+ end
12
+ end
13
+
14
+ group :test do
15
+ gem "coveralls", ">= 0.5.7", :require => false
16
+ gem "rspec", ">= 3"
17
+ gem "rspec-mocks", ">= 3"
18
+ gem "rubocop", ">= 0.19", :platforms => [:ruby_19, :ruby_20, :ruby_21]
19
+ gem "simplecov", :require => false
20
+ end
2
21
 
3
- # Specify your gem's dependencies in kameleon.gemspec
4
22
  gemspec
data/README.rst CHANGED
@@ -11,23 +11,36 @@ you can probably do a lot more than that.
11
11
  Installation
12
12
  ------------
13
13
 
14
+ Gem package
15
+ -----------
16
+
14
17
  To install the latest release from `RubyGems`_:
15
18
 
16
19
  .. _RubyGems: https://rubygems.org/gems/kameleon-builder
17
20
 
18
21
  ::
19
22
 
20
- gem install kameleon-builder --pre
21
-
22
- Or from source:
23
+ gem install kameleon-builder
23
24
 
24
- ::
25
+ Or from source::
25
26
 
26
- git clone https://github.com/oar-team/kameleon.git
27
- cd kameleon
27
+ git clone https://github.com/oar-team/kameleon.git && cd kameleon
28
28
  gem build kameleon-builder.gemspec
29
- gem install kameleon-builder-<version>.gem
29
+ gem install kameleon-builder-*.gem
30
+
31
+ On debian based distribution be sure to install the ``ruby-dev`` package first
32
+
30
33
 
34
+ Dist packages
35
+ -------------
36
+
37
+ These packages contain Kameleon and all its dependencies (Ruby, polipo and all
38
+ gems with their native extensions already compiled). These packages are made
39
+ with `omnibus project`_.
40
+
41
+ .. _`omnibus project`: https://github.com/opscode/omnibus-ruby
42
+
43
+ Please download the package in the following `page <http://kameleon.imag.fr/installation.html#dist-packages>`_
31
44
 
32
45
  -----
33
46
  Usage
@@ -44,19 +57,19 @@ Just type
44
57
  ::
45
58
 
46
59
  Commands:
47
- kameleon build [RECIPE_NAME] # Builds the appliance from the recipe
48
- kameleon checkpoints [RECIPE_NAME] # Lists all availables checkpoints
49
- kameleon clear [RECIPE_NAME] # Cleaning out context and removing all checkpoints
50
- kameleon help [COMMAND] # Describe available commands or one specific command
51
- kameleon new [RECIPE_NAME] -t, --template=TEMPLATE # Creates a new recipe
52
- kameleon templates # Lists all defined templates
53
- kameleon version # Prints the Kameleon's version information
60
+ kameleon build [RECIPE_PATH] # Builds the appliance from the given recipe
61
+ kameleon checkpoints [RECIPE_PATH] # Lists all availables checkpoints
62
+ kameleon clean [RECIPE_PATH] # Cleaning 'out' and 'local' contexts and removing all checkpoints
63
+ kameleon help [COMMAND] # Describe available commands or one specific command
64
+ kameleon import [TEMPLATE_NAME] # Imports the given template
65
+ kameleon new [RECIPE_NAME] [TEMPLATE_NAME] # Creates a new recipe
66
+ kameleon templates # Lists all defined templates
67
+ kameleon version # Prints the Kameleon's version information
54
68
 
55
69
  Options:
56
- [--no-color] # Disable colorization in output
57
- [--debug] # Enable debug output
58
- -w, [--workspace=WORKSPACE] # Change the kameleon current work directory. (The folder containing your
59
- # recipes folder). Default : ./
70
+ [--color], [--no-color] # Enable colorization in output
71
+ # Default: true
72
+ [--debug], [--no-debug] # Enable debug output
60
73
 
61
74
  First, you should select a template. To see the available templates use:
62
75
 
@@ -64,13 +77,11 @@ First, you should select a template. To see the available templates use:
64
77
 
65
78
  kameleon templates
66
79
 
67
- Then, create a new recipe from the template you've just choose. This will
68
- create a `recipes` folder in the current directory. (use `-w` option to set a
69
- different workspace).
80
+ Then, create a new recipe from the template you've just choose.
70
81
 
71
82
  ::
72
83
 
73
- kameleon new my_test_recipe -t template_name
84
+ kameleon new my_test_recipe template_name
74
85
 
75
86
  Then build your new recipe with the build command:
76
87
 
@@ -78,18 +89,17 @@ Then build your new recipe with the build command:
78
89
 
79
90
  kameleon build my_test_recipe
80
91
 
81
- A `builds` directory was created and contains your new image!
92
+ A ``builds`` directory will be created and will contain your new image!
82
93
 
83
94
  To go further, it is highly recommended you start with the `Getting Started`_ guide.
84
95
 
85
96
 
86
- .. _Getting Started: http://kameleon.readthedocs.org/en/latest/getting_started.html
97
+ .. _Getting Started: http://kameleon.imag.fr/getting_started.html
87
98
 
88
99
  ------------
89
100
  Contributing
90
101
  ------------
91
102
 
92
-
93
103
  1. Fork it
94
104
  2. Create your feature branch (`git checkout -b my-new-feature`)
95
105
  3. Commit your changes (`git commit -am 'Add some feature'`)
data/Thorfile ADDED
@@ -0,0 +1,29 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
+
3
+ require "bundler"
4
+ require "thor/rake_compat"
5
+
6
+ class Default < Thor
7
+ include Thor::RakeCompat
8
+ Bundler::GemHelper.install_tasks
9
+
10
+ desc "build", "Build kameleon-#{Kameleon::VERSION}.gem into the pkg directory"
11
+ def build
12
+ Rake::Task["build"].execute
13
+ end
14
+
15
+ desc "install", "Build and install kameleon-#{Kameleon::VERSION}.gem into system gems"
16
+ def install
17
+ Rake::Task["install"].execute
18
+ end
19
+
20
+ desc "release", "Create tag #{Kameleon::VERSION} and build and push kameleon-#{Kameleon::VERSION}.gem to Rubygems"
21
+ def release
22
+ Rake::Task["release"].execute
23
+ end
24
+
25
+ desc "spec", "Run RSpec code examples"
26
+ def spec
27
+ exec "rspec spec"
28
+ end
29
+ end
@@ -136,3 +136,64 @@ else
136
136
  alias ls='ls -G'
137
137
  fi
138
138
  fi
139
+
140
+ function __download {
141
+ echo "Downloading: $1..."
142
+ if which curl >/dev/null; then
143
+ curl -# -L --retry 999 --retry-max-time 0 "$1" -o "$2" 2>&1
144
+ else
145
+ fail "curl is missing, trying with wget..."
146
+ if which wget >/dev/null; then
147
+ wget --progress=bar:force "$1" -O "$2" 2>&1
148
+ else
149
+ fail "wget is missing, trying with python..."
150
+ if which python >/dev/null; then
151
+ python -c "
152
+ import sys
153
+ import time
154
+ if sys.version_info >= (3,):
155
+ import urllib.request as urllib
156
+ else:
157
+ import urllib
158
+
159
+
160
+ def reporthook(count, block_size, total_size):
161
+ global start_time
162
+ if count == 0:
163
+ start_time = time.time()
164
+ return
165
+ duration = time.time() - start_time
166
+ progress_size = float(count * block_size)
167
+ if duration != 0:
168
+ if total_size == -1:
169
+ total_size = block_size
170
+ percent = 'Unknown size, '
171
+ else:
172
+ percent = '%.0f%%, ' % float(count * block_size * 100 / total_size)
173
+ speed = int(progress_size / (1024 * duration))
174
+ sys.stdout.write('\r%s%.2f MB, %d KB/s, %d seconds passed'
175
+ % (percent, progress_size / (1024 * 1024), speed, duration))
176
+ sys.stdout.flush()
177
+
178
+ urllib.urlretrieve('$1', '$2', reporthook=reporthook)
179
+ print('\n')
180
+ "
181
+ true
182
+ else
183
+ fail "Cannot download $1"
184
+ fi
185
+ fi
186
+ fi
187
+ }
188
+
189
+ function __find_linux_boot_device() {
190
+ local PDEVICE=`stat -c %04D /boot`
191
+ for file in $(find /dev -type b 2>/dev/null) ; do
192
+ local CURRENT_DEVICE=$(stat -c "%02t%02T" $file)
193
+ if [ $CURRENT_DEVICE = $PDEVICE ]; then
194
+ ROOTDEVICE="$file"
195
+ break;
196
+ fi
197
+ done
198
+ echo "$ROOTDEVICE"
199
+ }
@@ -1,2 +1,3 @@
1
- export http_proxy=http://10.0.2.2:<%= @cache.polipo_port %>
2
- export ftp_proxy=http://10.0.2.2:<%= @cache.polipo_port %>
1
+ export http_proxy=http://<%= @proxy_cache %>:<%= @cache.polipo_port %>
2
+ export ftp_proxy=http://<%= @proxy_cache %>:<%= @cache.polipo_port %>
3
+ export https_proxy=https://<%= @proxy_cache %>:<%= @cache.polipo_port %>
@@ -20,25 +20,18 @@ Gem::Specification.new do |s|
20
20
  s.license = "GPL-2"
21
21
 
22
22
  s.files = `git ls-files`.split($/)
23
+ s.files.reject! { |file| file.start_with?("docs/") }
24
+ s.files.reject! { |file| file.start_with?("omnibus/") }
23
25
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
26
  s.test_files = s.files.grep(%r{^(tests|s|features)/})
25
27
  s.require_paths = ["lib"]
26
28
 
27
- s.add_dependency 'childprocess', '~> 0.5'
29
+ s.add_dependency 'childprocess', '~> 0.3'
28
30
  s.add_dependency 'thor', '~> 0.15'
29
31
  s.add_dependency 'table_print', '~> 1.5'
30
- s.add_dependency 'log4r-color', '~> 1.2'
31
- s.add_dependency 'diffy', '~> 3.0'
32
32
  # Syck is also a dependency for Ruby 2 environments.
33
33
  # It is installed at install-time if necessary,
34
34
  # via ext/mkrf_conf.rb
35
-
36
- s.add_development_dependency 'pry', '~> 0.9'
37
- s.add_development_dependency 'pry-debugger', '~> 0.2'
38
- s.add_development_dependency 'rake', '~> 10.1'
39
- s.add_development_dependency 'minitest', '~> 4.7'
40
- s.add_development_dependency 'coveralls', '~> 0.7'
41
-
42
35
  # To allow installing the Syck gem when Ruby version is >2.0.0
43
36
  s.extensions = ["ext/mkrf_conf.rb"]
44
37
  end
data/lib/kameleon.rb CHANGED
@@ -6,25 +6,18 @@ require 'tempfile'
6
6
  require 'pp'
7
7
  require 'thor'
8
8
  require 'childprocess'
9
- require 'log4r-color'
10
- require 'log4r-color/configurator'
11
9
  require 'pathname'
12
10
  require 'table_print'
13
- require 'diffy'
14
11
 
15
12
  module Kameleon
16
- # add a PROGRESS and NOTICE level
17
- Log4r::Configurator.custom_levels(:DEBUG, :INFO, :NOTICE,
18
- :PROGRESS, :WARN, :ERROR,
19
- :FATAL)
20
-
21
13
  class << self
22
- attr_writer :logger
23
14
  attr_writer :env
15
+ attr_writer :ui
24
16
  attr_writer :source_root
25
17
  attr_writer :templates_path
26
18
  attr_writer :templates_names
27
19
  attr_writer :templates_files
20
+ attr_writer :log_on_progress
28
21
 
29
22
  # The source root is the path to the root directory of the kameleon gem.
30
23
  def source_root
@@ -55,14 +48,17 @@ module Kameleon
55
48
  @templates_names
56
49
  end
57
50
 
58
- def logger
59
- @logger ||= Log4r::Logger.new("kameleon::[kameleon]")
60
- end
61
-
62
51
  def env
63
52
  @env ||= Environment.new
64
53
  end
65
54
 
55
+ def ui
56
+ @ui ||= UI::Shell.new
57
+ end
58
+
59
+ def log_on_progress
60
+ @log_on_progress ||= false
61
+ end
66
62
  end
67
63
  end
68
64
 
@@ -73,4 +69,4 @@ require 'kameleon/error'
73
69
  require 'kameleon/cli'
74
70
  require 'kameleon/environment'
75
71
  require 'kameleon/version'
76
- require 'kameleon/logger'
72
+ require 'kameleon/ui'
data/lib/kameleon/cli.rb CHANGED
@@ -4,43 +4,37 @@ require 'kameleon/utils'
4
4
 
5
5
  module Kameleon
6
6
  class CLI < Thor
7
-
7
+ include Thor::Actions
8
8
 
9
9
  class_option :color, :type => :boolean, :default => true,
10
10
  :desc => "Enable colorization in output"
11
11
  class_option :debug, :type => :boolean, :default => false,
12
12
  :desc => "Enable debug output"
13
+ class_option :script, :type => :boolean, :default => false,
14
+ :desc => "never prompts for user intervention",
15
+ :aliases => "-s"
13
16
  map %w(-h --help) => :help
14
17
 
15
- no_commands do
16
- def logger
17
- @logger ||= Log4r::Logger.new("kameleon::[kameleon]")
18
- end
19
- end
20
-
21
- method_option :force,:type => :boolean,
22
- :default => false, :aliases => "-f",
23
- :desc => "Overwrite all existing files"
24
18
  desc "import [TEMPLATE_NAME]", "Imports the given template"
25
19
  def import(template_name)
26
20
  templates_path = Kameleon.env.templates_path
27
21
  template_path = File.join(templates_path, template_name) + '.yaml'
28
22
  begin
29
- template_recipe = RecipeTemplate.new(template_path, :strict => false)
23
+ tpl = RecipeTemplate.new(template_path)
30
24
  rescue
31
25
  raise TemplateNotFound, "Template '#{template_name}' not found. " \
32
26
  "To see all templates, run the command "\
33
27
  "`kameleon templates`"
34
28
  else
35
- logger.notice("Importing template '#{template_name}'...")
36
- template_recipe.copy_template(options[:force])
37
- logger.notice("done")
29
+ files2copy = tpl.base_recipes_files + tpl.files
30
+ files2copy.each do |path|
31
+ relative_path = path.relative_path_from(Kameleon.env.templates_path)
32
+ dst = File.join(Kameleon.env.workspace, relative_path)
33
+ copy_file(path, dst)
34
+ end
38
35
  end
39
36
  end
40
37
 
41
- method_option :force,:type => :boolean,
42
- :default => false, :aliases => "-f",
43
- :desc => "Overwrite all existing files"
44
38
  desc "new [RECIPE_NAME] [TEMPLATE_NAME]", "Creates a new recipe"
45
39
  def new(recipe_name, template_name)
46
40
  if recipe_name == template_name
@@ -49,31 +43,47 @@ module Kameleon
49
43
  templates_path = Kameleon.env.templates_path
50
44
  template_path = File.join(templates_path, template_name) + '.yaml'
51
45
  begin
52
- template_recipe = RecipeTemplate.new(template_path, :strict => false)
46
+ tpl = RecipeTemplate.new(template_path)
53
47
  rescue
54
48
  raise TemplateNotFound, "Template '#{template_name}' not found. " \
55
49
  "To see all templates, run the command "\
56
50
  "`kameleon templates`"
57
51
  else
58
- logger.notice("Cloning template '#{template_name}'...")
59
- template_recipe.copy_template(options[:force])
60
- logger.notice("Creating extended recipe from template '#{template_name}'...")
61
- template_recipe.copy_extended_recipe(recipe_name, options[:force])
62
- logger.notice("done")
52
+ files2copy = tpl.base_recipes_files + tpl.files
53
+ files2copy.each do |path|
54
+ relative_path = path.relative_path_from(Kameleon.env.templates_path)
55
+ dst = File.join(Kameleon.env.workspace, relative_path)
56
+ copy_file(path, dst)
57
+ end
58
+ Dir::mktmpdir do |tmp_dir|
59
+ recipe_path = File.join(tmp_dir, recipe_name + '.yaml')
60
+ ## copying recipe
61
+ File.open(recipe_path, 'w+') do |file|
62
+ extend_erb_tpl = File.join(Kameleon.env.templates_path, "extend.erb")
63
+ erb = ERB.new(File.open(extend_erb_tpl, 'rb') { |f| f.read })
64
+ result = erb.result(binding)
65
+ file.write(result)
66
+ end
67
+ recipe_dst = File.join(Kameleon.env.workspace, recipe_name + '.yaml')
68
+ copy_file(recipe_path, Pathname.new(recipe_dst))
69
+ end
63
70
  end
64
71
  end
65
72
 
66
73
  desc "templates", "Lists all defined templates"
67
74
  def templates
68
- Log4r::Outputter['console'].level = Log4r::ERROR unless Kameleon.env.debug
69
75
  puts "The following templates are available in " \
70
76
  "#{ Kameleon.templates_path }:"
71
77
  templates_hash = []
72
- Kameleon.templates_files.each do |f|
78
+ templates_path = File.join(Kameleon.env.templates_path, "/")
79
+ all_yaml_files = Dir["#{templates_path}**/*.yaml"]
80
+ steps_files = Dir["#{templates_path}steps/**/*.yaml"]
81
+ templates_files = all_yaml_files - steps_files
82
+ templates_files.each do |f|
73
83
  begin
74
- recipe = RecipeTemplate.new(f, :strict => false)
84
+ recipe = RecipeTemplate.new(f)
75
85
  templates_hash.push({
76
- "name" => recipe.name,
86
+ "name" => f.gsub(templates_path, "").chomp(".yaml"),
77
87
  "description" => recipe.metainfo['description'],
78
88
  })
79
89
  rescue => e
@@ -81,12 +91,15 @@ module Kameleon
81
91
  end
82
92
  end
83
93
  templates_hash = templates_hash.sort_by{ |k| k["name"] }
84
- tp templates_hash, {"name" => {:width => 30}}, { "description" => {:width => 60}}
94
+ name_width = templates_hash.map { |k| k['name'].size }.max
95
+ desc_width = Kameleon.ui.shell.terminal_width - name_width - 3
96
+ tp(templates_hash,
97
+ {"name" => {:width => name_width}},
98
+ { "description" => {:width => desc_width}})
85
99
  end
86
100
 
87
101
  desc "version", "Prints the Kameleon's version information"
88
102
  def version
89
- Log4r::Outputter['console'].level = Log4r::OFF unless Kameleon.env.debug
90
103
  puts "Kameleon version #{Kameleon::VERSION}"
91
104
  end
92
105
  map %w(-v --version) => :version
@@ -103,11 +116,14 @@ module Kameleon
103
116
  :desc => "Using specific checkpoint to build the image. " \
104
117
  "Default value is the last checkpoint."
105
118
  method_option :checkpoint, :type => :boolean ,
106
- :default => true,
107
- :desc => "Do not use checkpoints"
119
+ :default => false,
120
+ :desc => "Enable checkpoint"
108
121
  method_option :cache, :type => :boolean,
109
122
  :default => false,
110
123
  :desc => "Generate a persistent cache for the appliance."
124
+ method_option :cache_path, :type => :string ,
125
+ :default => nil,
126
+ :desc => "Set the cache directory path"
111
127
  method_option :from_cache, :type => :string ,
112
128
  :default => nil,
113
129
  :desc => "Using a persistent cache tar file to build the image."
@@ -115,19 +131,24 @@ module Kameleon
115
131
  :default => nil,
116
132
  :desc => "Full path of the proxy binary to use for the persistent cache."
117
133
 
118
- def build(recipe_path)
134
+ def build(recipe_path=nil)
135
+ if recipe_path.nil? && !options[:from_cache].nil?
136
+ Kameleon.ui.info("Using the cached recipe")
137
+ @cache = Kameleon::Persistent_cache.instance
138
+ @cache.cache_path = options[:from_cache]
139
+ recipe_path = @cache.get_recipe
140
+ end
141
+ raise BuildError, "A recipe file or a persistent cache archive " \
142
+ "is required to run this command." if recipe_path.nil?
119
143
  clean(recipe_path) if options[:clean]
120
144
  engine = Kameleon::Engine.new(Recipe.new(recipe_path), options)
121
- logger.notice("Starting build recipe '#{recipe_path}'")
145
+ Kameleon.ui.info("Starting build recipe '#{recipe_path}'")
122
146
  start_time = Time.now.to_i
123
147
  engine.build
124
148
  total_time = Time.now.to_i - start_time
125
- logger.notice("")
126
- logger.notice("Build recipe '#{recipe_path}' is completed !")
127
- logger.notice("Build total duration : #{total_time} secs")
128
- logger.notice("Build directory : #{engine.cwd}")
129
- logger.notice("Build recipe file : #{engine.build_recipe_path}")
130
- logger.notice("Log file : #{Kameleon.env.log_file}")
149
+ Kameleon.ui.info("")
150
+ Kameleon.ui.info("Successfully built '#{recipe_path}'")
151
+ Kameleon.ui.info("Total duration : #{total_time} secs")
131
152
  end
132
153
 
133
154
  desc "checkpoints [RECIPE_PATH]", "Lists all availables checkpoints"
@@ -135,25 +156,27 @@ module Kameleon
135
156
  :default => nil, :aliases => "-b",
136
157
  :desc => "Set the build directory path"
137
158
  def checkpoints(recipe_path)
138
- Log4r::Outputter['console'].level = Log4r::ERROR unless Kameleon.env.debug
159
+ Kameleon.ui.level = "error"
139
160
  engine = Kameleon::Engine.new(Recipe.new(recipe_path), options)
140
161
  engine.pretty_checkpoints_list
141
162
  end
142
163
 
143
- desc "clean [RECIPE_PATH]", "Cleaning 'out' and 'local' contexts and removing all checkpoints"
164
+ desc "clean [RECIPE_PATH]", "Cleaning all contexts and removing the checkpoints"
144
165
  method_option :build_path, :type => :string ,
145
166
  :default => nil, :aliases => "-b",
146
167
  :desc => "Set the build directory path"
147
168
  def clean(recipe_path)
148
- Log4r::Outputter['console'].level = Log4r::INFO
149
- engine = Kameleon::Engine.new(Recipe.new(recipe_path), options)
150
- engine.clear
169
+ opts = Hash.new.merge options
170
+ opts[:lazyload] = false
171
+ opts[:fail_silently] = true
172
+ engine = Kameleon::Engine.new(Recipe.new(recipe_path), opts)
173
+ engine.clean(:with_checkpoint => true)
151
174
  end
152
175
  map %w(clear) => :clean
153
176
 
154
177
  desc "commands", "Lists all available commands", :hide => true
155
178
  def commands
156
- puts CLI.all_commands.keys - ["commands", "completions"]
179
+ Kameleon.ui.info CLI.all_commands.keys - ["commands", "completions"]
157
180
  end
158
181
 
159
182
  desc "source_root", "Prints the kameleon directory path", :hide => true
@@ -161,70 +184,34 @@ module Kameleon
161
184
  puts Kameleon.source_root
162
185
  end
163
186
 
164
- # Hack Thor to init Kameleon env soon
165
- def self.init(base_config)
166
- env_options = Hash.new
167
- env_options.merge! base_config[:shell].base.options.clone
168
- # configure logger
169
- env_options["debug"] = true if ENV["KAMELEON_LOG"] == "debug"
170
- ENV["KAMELEON_LOG"] = "debug" if env_options["debug"]
171
- if ENV["KAMELEON_LOG"] && ENV["KAMELEON_LOG"] != ""
172
- level_name = ENV["KAMELEON_LOG"]
173
- else
174
- level_name = "info"
175
- end
176
- # Require Log4r and define the levels we'll be using
177
- require 'log4r-color/config'
178
- Log4r.define_levels(*Log4r::Log4rConfig::LogLevels)
179
-
180
- begin
181
- level = Log4r.const_get(level_name.upcase)
182
- rescue NameError
183
- level = Log4r.const_get("INFO")
184
- $stderr << "Invalid KAMELEON_LOG level is set: #{level_name}.\n" \
185
- "Please use one of the standard log levels: debug," \
186
- " info, warn, or error\n"
187
- raise KameleonError
187
+ def initialize(*args)
188
+ super
189
+ self.options ||= {}
190
+ Kameleon.env = Kameleon::Environment.new(self.options)
191
+ if !$stdout.tty? or !options["color"]
192
+ Thor::Base.shell = Thor::Shell::Basic
188
193
  end
189
- format = ConsoleFormatter.new
190
- # format = Log4r::PatternFormatter.new(:pattern => '%11c: %M')
191
- if !$stdout.tty? or !env_options["color"]
192
- console_output = Log4r::StdoutOutputter.new('console',
193
- :formatter => format)
194
- Diffy::Diff.default_format = :text
195
- else
196
- console_output = Log4r::ColorOutputter.new 'console', {
197
- :colors => { :debug => :light_black,
198
- :info => :green,
199
- :progress_info => :green,
200
- :notice => :light_blue,
201
- :progress_notice => :light_blue,
202
- :warn => :yellow,
203
- :error => :red,
204
- :progress_error => :red,
205
- :fatal => :red,
206
- },
207
- :formatter => format,
208
- }
209
- Diffy::Diff.default_format = :color
194
+ Kameleon.ui = Kameleon::UI::Shell.new(self.options)
195
+ Kameleon.ui.level = "debug" if self.options["debug"]
196
+ opts = args[1]
197
+ cmd_name = args[2][:current_command].name
198
+ if opts.include? "--help"
199
+ CLI.command_help(Kameleon.ui.shell, cmd_name)
200
+ raise Kameleon::Exit
210
201
  end
211
- logger = Log4r::Logger.new('kameleon')
212
- logger.level = level
213
- logger.outputters << console_output
214
- format_file = FileFormatter.new
215
- Kameleon.logger.debug("`kameleon` invoked: #{ARGV.inspect}")
216
- Kameleon.env = Kameleon::Environment.new(env_options)
217
- filelog = Log4r::FileOutputter.new('logfile',
218
- :trunc=>false,
219
- :filename => Kameleon.env.log_file.to_s,
220
- :formatter => format_file)
221
- logger.outputters << filelog
222
- logger = nil
223
202
  end
224
203
 
225
- def self.start(given_args=ARGV, config={})
226
- config[:shell] ||= Thor::Base.shell.new
227
- dispatch(nil, given_args.dup, nil, config) { init(config) }
204
+ def self.start(*)
205
+ super
206
+ rescue Exception => e
207
+ Kameleon.ui = Kameleon::UI::Shell.new
208
+ raise e
209
+ end
210
+
211
+ def self.source_root
212
+ Kameleon.source_root
228
213
  end
214
+
229
215
  end
216
+
230
217
  end