kameleon-builder 2.2.5 → 2.3.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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.rst +21 -0
  4. data/{templates → contrib}/steps/bootstrap/debian/debootstrap_arm.yaml +1 -1
  5. data/{templates → contrib}/steps/export/clean_appliance.yaml +0 -0
  6. data/{templates → contrib}/steps/export/compact_qcow_img.yaml +0 -0
  7. data/{templates → contrib}/steps/setup/archlinux/configure_ruby.yaml +0 -0
  8. data/{templates → contrib}/steps/setup/archlinux/install_dev_tools.yaml +0 -0
  9. data/{templates → contrib}/steps/setup/archlinux/install_gnome.yaml +0 -0
  10. data/{templates → contrib}/steps/setup/archlinux/install_yaourt.yaml +0 -0
  11. data/{templates → contrib}/steps/setup/centos/6.5/configure_repo.yaml +0 -0
  12. data/{templates → contrib}/steps/setup/debian/install_gnome.yaml +0 -0
  13. data/{templates → contrib}/steps/setup/debian/install_kde.yaml +0 -0
  14. data/{templates → erb}/extend.erb +2 -2
  15. data/erb/userconf.erb +5 -0
  16. data/kameleon-builder.gemspec +6 -1
  17. data/lib/kameleon.rb +53 -3
  18. data/lib/kameleon/cli.rb +146 -99
  19. data/lib/kameleon/engine.rb +20 -8
  20. data/lib/kameleon/environment.rb +11 -10
  21. data/lib/kameleon/persistent_cache.rb +1 -9
  22. data/lib/kameleon/recipe.rb +52 -24
  23. data/lib/kameleon/repository.rb +46 -0
  24. data/lib/kameleon/utils.rb +49 -0
  25. data/{templates → tests/recipes}/steps/aliases/defaults.yaml +0 -0
  26. data/tests/recipes/steps/bootstrap/linux/bootstrap.yaml +2 -0
  27. data/tests/recipes/steps/checkpoints/test.yaml +14 -0
  28. data/tests/recipes/steps/enable_something.yaml +2 -0
  29. data/tests/recipes/steps/export/save_appliance.yaml +10 -0
  30. data/tests/recipes/steps/setup/linux/software_install.yaml +7 -0
  31. data/tests/recipes/test_recipe.yaml +41 -0
  32. data/version.txt +1 -1
  33. metadata +34 -139
  34. data/templates/COPYRIGHT +0 -21
  35. data/templates/chroot/debian7-amd64.yaml +0 -119
  36. data/templates/docker/debian7.yaml +0 -107
  37. data/templates/grid5000/debian7.yaml +0 -97
  38. data/templates/qemu/archlinux-desktop-i686.yaml +0 -25
  39. data/templates/qemu/archlinux-desktop-x86_64.yaml +0 -25
  40. data/templates/qemu/archlinux-i686.yaml +0 -25
  41. data/templates/qemu/archlinux-x86_64.yaml +0 -109
  42. data/templates/qemu/centos6.5-x86_64.yaml +0 -122
  43. data/templates/qemu/centos7-x86_64.yaml +0 -122
  44. data/templates/qemu/debian7-amd64.yaml +0 -134
  45. data/templates/qemu/debian7-desktop-amd64.yaml +0 -24
  46. data/templates/qemu/debian7-kameleon-amd64.yaml +0 -40
  47. data/templates/qemu/debian7-oar-amd64.yaml +0 -51
  48. data/templates/qemu/debian8-amd64.yaml +0 -25
  49. data/templates/qemu/fedora20-desktop-x86_64.yaml +0 -21
  50. data/templates/qemu/fedora20-x86_64.yaml +0 -119
  51. data/templates/qemu/ubuntu-12.04-amd64.yaml +0 -132
  52. data/templates/qemu/ubuntu-12.04-desktop-amd64.yaml +0 -25
  53. data/templates/qemu/ubuntu-14.04-amd64.yaml +0 -25
  54. data/templates/qemu/ubuntu-14.04-desktop-amd64.yaml +0 -27
  55. data/templates/steps/bootstrap/archlinux/arch_bootstrap.yaml +0 -211
  56. data/templates/steps/bootstrap/centos/6.5/yum_bootstrap.yaml +0 -67
  57. data/templates/steps/bootstrap/debian/debootstrap.yaml +0 -20
  58. data/templates/steps/bootstrap/fedora/init_pxeboot.yaml +0 -13
  59. data/templates/steps/bootstrap/fedora/yum_bootstrap.yaml +0 -45
  60. data/templates/steps/bootstrap/g5k_reserv.yaml +0 -70
  61. data/templates/steps/bootstrap/initialize_disk.yaml +0 -16
  62. data/templates/steps/bootstrap/initialize_disk_chroot.yaml +0 -80
  63. data/templates/steps/bootstrap/install_requirements.yaml +0 -3
  64. data/templates/steps/bootstrap/prepare_chroot.yaml +0 -126
  65. data/templates/steps/bootstrap/prepare_docker.yaml +0 -51
  66. data/templates/steps/bootstrap/prepare_qemu.yaml +0 -41
  67. data/templates/steps/bootstrap/prepare_virtualbox.yaml +0 -67
  68. data/templates/steps/bootstrap/start_chroot.yaml +0 -51
  69. data/templates/steps/bootstrap/start_docker.yaml +0 -16
  70. data/templates/steps/bootstrap/start_qemu.yaml +0 -74
  71. data/templates/steps/bootstrap/start_virtualbox.yaml +0 -38
  72. data/templates/steps/bootstrap/switch_context_qemu.yaml +0 -84
  73. data/templates/steps/bootstrap/switch_context_virtualbox.yaml +0 -86
  74. data/templates/steps/breakpoint.yaml +0 -3
  75. data/templates/steps/checkpoints/docker.yaml +0 -17
  76. data/templates/steps/checkpoints/qcow2.yaml +0 -40
  77. data/templates/steps/checkpoints/qemu.yaml +0 -33
  78. data/templates/steps/checkpoints/virtualbox.yaml +0 -21
  79. data/templates/steps/disable_checkpoint.yaml +0 -3
  80. data/templates/steps/enable_checkpoint.yaml +0 -5
  81. data/templates/steps/export/qemu_save_appliance.yaml +0 -52
  82. data/templates/steps/export/save_appliance_from_g5k.yaml +0 -47
  83. data/templates/steps/export/vagrant_save_appliance.yaml +0 -14
  84. data/templates/steps/export/virtualbox_save_appliance.yaml +0 -61
  85. data/templates/steps/setup/archlinux/configure_keyboard.yaml +0 -9
  86. data/templates/steps/setup/archlinux/configure_network.yaml +0 -9
  87. data/templates/steps/setup/archlinux/configure_system.yaml +0 -20
  88. data/templates/steps/setup/archlinux/install_bootloader.yaml +0 -23
  89. data/templates/steps/setup/archlinux/install_software.yaml +0 -9
  90. data/templates/steps/setup/autologin.yaml +0 -16
  91. data/templates/steps/setup/centos/6.5/configure_network.yaml +0 -33
  92. data/templates/steps/setup/centos/6.5/configure_system.yaml +0 -46
  93. data/templates/steps/setup/centos/6.5/minimal_install.yaml +0 -3
  94. data/templates/steps/setup/centos/6.5/setup_vagrant_box.yaml +0 -77
  95. data/templates/steps/setup/create_group.yaml +0 -12
  96. data/templates/steps/setup/create_user.yaml +0 -11
  97. data/templates/steps/setup/debian/configure_apt.yaml +0 -73
  98. data/templates/steps/setup/debian/configure_kernel.yaml +0 -13
  99. data/templates/steps/setup/debian/configure_keyboard.yaml +0 -10
  100. data/templates/steps/setup/debian/configure_network.yaml +0 -30
  101. data/templates/steps/setup/debian/configure_system.yaml +0 -12
  102. data/templates/steps/setup/debian/install_bootloader.yaml +0 -36
  103. data/templates/steps/setup/debian/install_software.yaml +0 -2
  104. data/templates/steps/setup/debian/oar/oar_debian_config_frontend.yaml +0 -8
  105. data/templates/steps/setup/debian/oar/oar_debian_config_node.yaml +0 -5
  106. data/templates/steps/setup/debian/oar/oar_debian_config_server.yaml +0 -5
  107. data/templates/steps/setup/debian/oar/oar_prereq_install.yaml +0 -16
  108. data/templates/steps/setup/debian/setup_vagrant_box.yaml +0 -80
  109. data/templates/steps/setup/debian/upgrade_system.yaml +0 -10
  110. data/templates/steps/setup/fedora/configure_kernel.yaml +0 -9
  111. data/templates/steps/setup/fedora/configure_keyboard.yaml +0 -12
  112. data/templates/steps/setup/fedora/configure_network.yaml +0 -38
  113. data/templates/steps/setup/fedora/configure_system.yaml +0 -52
  114. data/templates/steps/setup/fedora/install_bootloader.yaml +0 -53
  115. data/templates/steps/setup/fedora/install_software.yaml +0 -3
  116. data/templates/steps/setup/fedora/minimal_install.yaml +0 -3
  117. data/templates/steps/setup/fedora/update_system.yaml +0 -16
  118. data/templates/steps/setup/oar/oar_config_devel.yaml +0 -21
  119. data/templates/steps/setup/oar/oar_config_frontend.yaml +0 -38
  120. data/templates/steps/setup/oar/oar_config_node.yaml +0 -4
  121. data/templates/steps/setup/oar/oar_config_server.yaml +0 -25
  122. data/templates/steps/setup/oar/oar_config_system.yaml +0 -34
  123. data/templates/steps/setup/oar/oar_devel_prereq_install.yaml +0 -5
  124. data/templates/steps/setup/oar/oar_git_install.yaml +0 -21
  125. data/templates/steps/setup/ubuntu/configure_apt.yaml +0 -62
  126. data/templates/virtualbox/archlinux-desktop-i686.yaml +0 -25
  127. data/templates/virtualbox/archlinux-desktop-x86_64.yaml +0 -28
  128. data/templates/virtualbox/archlinux-i686.yaml +0 -28
  129. data/templates/virtualbox/archlinux-x86_64.yaml +0 -108
  130. data/templates/virtualbox/centos6.5-i386.yaml +0 -39
  131. data/templates/virtualbox/centos6.5-vagrant-x86_64.yaml +0 -33
  132. data/templates/virtualbox/centos6.5-x86_64.yaml +0 -121
  133. data/templates/virtualbox/centos7-x86_64.yaml +0 -118
  134. data/templates/virtualbox/debian7-amd64.yaml +0 -128
  135. data/templates/virtualbox/debian7-desktop-amd64.yaml +0 -25
  136. data/templates/virtualbox/debian7-i386.yaml +0 -31
  137. data/templates/virtualbox/debian7-kameleon-amd64.yaml +0 -38
  138. data/templates/virtualbox/debian7-oar-amd64.yaml +0 -51
  139. data/templates/virtualbox/debian7-vagrant-amd64.yaml +0 -32
  140. data/templates/virtualbox/debian8-amd64.yaml +0 -25
  141. data/templates/virtualbox/debian8-i386.yaml +0 -31
  142. data/templates/virtualbox/fedora20-x86_64.yaml +0 -118
  143. data/templates/virtualbox/ubuntu-12.04-amd64.yaml +0 -128
  144. data/templates/virtualbox/ubuntu-12.04-desktop-amd64.yaml +0 -25
  145. data/templates/virtualbox/ubuntu-14.04-amd64.yaml +0 -25
  146. data/templates/virtualbox/ubuntu-14.04-desktop-amd64.yaml +0 -27
  147. data/tests/recipes/dummy_recipe.yaml +0 -48
  148. data/tests/recipes/steps/bootstrap/dummy_distro/dummy_bootstrap_static.yaml +0 -4
  149. data/tests/recipes/steps/export/dummy_save_appliance.yaml +0 -9
  150. data/tests/recipes/steps/setup/default/dummy_root_passwd.yaml +0 -8
  151. data/tests/recipes/steps/setup/dummy_distro/dummy_software_install.yaml +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 713bfaf539e81472b72965b0c4d4639543b1d616
4
- data.tar.gz: 425144e158dddbf29447ac5f082e546c2f2a304e
3
+ metadata.gz: c6a3d7e9962e22c223344369a554019b3ecdef6a
4
+ data.tar.gz: 25c90de017ffdb6e7f82dcdaa64a5ed7f2d621e1
5
5
  SHA512:
6
- metadata.gz: da5f852444818504e73b889c62683696b9bf7c8a077109a80bc881dbd26848c602b693b834e7d26220cd6aa50a4660d4d4dc1ed65fd1184c23bf3c0f71eb5c57
7
- data.tar.gz: 8d56cfb832300b771fd43832f46655c4e8504db47b9f1b1f7e5260ac244249d16f4e1077d7a30aec78090de70486a206e1a525f41d20f787208ea50e7f0e649a
6
+ metadata.gz: f9846ad8bd70649a76ec8c8408228eb44a172030127361e117672d0076211680c3ee07dcf6829529d73cde1b81d28051b494d92794a23062c7907a28bde4399e
7
+ data.tar.gz: 5143fe65f730c5b2cefd5ded3c0b412c88cd6a0b8dfa85fe5bc30417deec36e650605c9c82e0b066637cd23a4b388d0f1a3d49416eb3ff986b66a2cbca8de51c
data/.gitignore CHANGED
@@ -21,3 +21,4 @@ coverage
21
21
  .vagrant
22
22
  *.log
23
23
  bin/*
24
+ build
@@ -2,6 +2,27 @@ Kameleon CHANGELOG
2
2
  ==================
3
3
 
4
4
 
5
+ version 2.3.0
6
+ -------------
7
+
8
+ Released on Oct 16th 2014
9
+
10
+ - Handled Ctrl-C to make a breakpoint instead of quitting. (Fixed #29)
11
+ - Stored kameleon user configuration file in ``~/.kameleon.d/config`` (Fixed #24)
12
+ - Fixed ``kameleon new`` to take an absolute or relative path and place the recipe in a subdir (Fixed #22)
13
+ - Moved builtin recipes to an external repository : See [http://kameleon.imag.fr/repository.html](Docs) (Fixed #24)
14
+ - Renamed ``--cache`` option to ``--enable-cache``
15
+ - Renamed ``--checkpoint`` option to ``--enable-checkpoint``
16
+ - Removed ``kameleon import`` command
17
+ - Removed ``kameleon templates`` command
18
+ - Added ``kameleon info`` to display detailed information about a recipe
19
+ - Added ``kameleon list`` to list all defined recipes in the current directory
20
+ - Added ``kameleon template info`` to display detailed information about a template
21
+ - Added ``kameleon template import`` to import a template
22
+ - Added ``kameleon template list`` to list all available templates
23
+ - Added ``kameleon template repository`` to manage external git recipes repositories
24
+
25
+
5
26
  version 2.2.5
6
27
  -------------
7
28
 
@@ -6,7 +6,7 @@
6
6
  - check_cmd_out: qemu-arm-static
7
7
  - exec_out:|
8
8
  mkdir -p $$rootfs
9
- debootstrap --no-check-gpg --foreign --variant=minbase --arch=$$arch --include="$$include_pkg" $$release $$rootfs $$repository
9
+ debootstrap --no-check-gpg --foreign --arch=$$arch --include="$$include_pkg" $$release $$rootfs $$repository
10
10
  QEMU_USER_PATH=$(which qemu-arm-static)
11
11
  cp $QEMU_USER_PATH $$rootfs/usr/bin/qemu-arm-static
12
12
  chroot $$rootfs /usr/bin/qemu-arm-static -cpu cortex-a9 /bin/sh /debootstrap/debootstrap --second-stage
@@ -7,10 +7,10 @@
7
7
  #==============================================================================
8
8
 
9
9
  ---
10
- extend: <%= tpl.relative_path %>
10
+ extend: <%= tpl.relative_path_from_recipe(recipe_path) %>
11
11
 
12
12
  global:
13
- # You can see the base template `<%= tpl.relative_path %>.yaml` to know the
13
+ # You can see the base template `<%= tpl.relative_path_from_recipe(recipe_path) %>.yaml` to know the
14
14
  # variables that you can override
15
15
 
16
16
  bootstrap:
@@ -0,0 +1,5 @@
1
+ ---
2
+ repositories_path: <%= Kameleon.default_values[:repositories_path] %>
3
+ script: <%= Kameleon.default_values[:script] %>
4
+ color: <%= Kameleon.default_values[:color] %>
5
+ debug: <%= Kameleon.default_values[:debug] %>
@@ -6,17 +6,20 @@ require 'kameleon/version'
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'kameleon-builder'
8
8
  s.version = Kameleon::VERSION
9
+ s.date = Time.now.strftime('%Y-%m-%d')
9
10
  s.authors = ['Salem Harrache',
10
11
  'Michael Mercier',
11
12
  'Cristan Ruiz',
13
+ 'Pierre Neyron',
12
14
  'Bruno Bzeznik']
13
15
  s.email = ['salem.harrache@inria.fr',
14
16
  'michael.mercier@inria.fr',
15
17
  'cristian.ruiz@imag.fr',
18
+ 'pierre.neyron@imag.fr',
16
19
  'bruno.bzeznik@imag.fr']
17
20
  s.description = %q{The mindful appliance builder}
18
21
  s.summary = %q{Kameleon is a tool to build virtual machines from scratch}
19
- s.homepage = 'http://kameleon.readthedocs.org/'
22
+ s.homepage = 'http://kameleon.imag.fr/'
20
23
  s.license = 'GPL-2'
21
24
 
22
25
  s.files = `git ls-files`.split($/)
@@ -28,4 +31,6 @@ Gem::Specification.new do |s|
28
31
  s.add_dependency 'childprocess', '~> 0.5.3', '>= 0.3.0'
29
32
  s.add_dependency 'thor', '~> 0.19', '>= 0.15.0'
30
33
  s.add_dependency 'table_print', '~> 1.5.2'
34
+
35
+ s.requirements = ['polipo 1.0.3, or greater']
31
36
  end
@@ -10,20 +10,70 @@ require 'pathname'
10
10
  require 'table_print'
11
11
  require 'yaml'
12
12
 
13
+ require 'kameleon/ui'
14
+
13
15
  module Kameleon
14
16
  class << self
15
17
  attr_writer :env
16
18
  attr_writer :ui
17
19
  attr_writer :source_root
18
20
  attr_writer :log_on_progress
21
+ attr_writer :userdir
22
+ attr_writer :userconf_path
23
+ attr_writer :repositories_path
24
+ attr_writer :default_values
19
25
 
20
26
  # The source root is the path to the root directory of the kameleon gem.
21
27
  def source_root
22
28
  @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
23
29
  end
24
30
 
25
- def default_templates_path
26
- File.join(Kameleon.source_root, 'templates')
31
+ def erb_dirpath
32
+ File.join(Kameleon.source_root, 'erb')
33
+ end
34
+
35
+ def userdir
36
+ @userdir ||= Pathname.new(File.join('~', '.kameleon.d'))
37
+ Dir.mkdir(File.expand_path(@userdir.to_path)) unless File.exists?(File.expand_path(@userdir.to_path))
38
+ @userdir
39
+ end
40
+
41
+ def userconf_path
42
+ @userconf_path ||= Pathname.new(File.join(File.expand_path(userdir.to_path), 'config'))
43
+ end
44
+
45
+ def init_userconf()
46
+ if not File.exists?(Kameleon.userconf_path) or File.zero?(Kameleon.userconf_path)
47
+ File.open(Kameleon.userconf_path, 'w+') do |file|
48
+ userconf_erb = File.join(Kameleon.erb_dirpath, "userconf.erb")
49
+ erb = ERB.new(File.open(userconf_erb, 'rb') { |f| f.read })
50
+ result = erb.result(binding)
51
+ file.write(result)
52
+ end
53
+ end
54
+ end
55
+
56
+ def load_userconf
57
+ if File.exists?(Kameleon.userconf_path) and not File.zero?(Kameleon.userconf_path)
58
+ yaml_conf = YAML.load_file Kameleon.userconf_path
59
+ unless yaml_conf.kind_of? Hash
60
+ yaml_conf = {}
61
+ end
62
+ else
63
+ yaml_conf = {}
64
+ end
65
+ return yaml_conf
66
+ end
67
+
68
+ def default_values
69
+ userconf = load_userconf
70
+ @default_values ||= {
71
+ :color => userconf.fetch("color", true),
72
+ :debug => userconf.fetch("debug", false),
73
+ :script => userconf.fetch("script", false),
74
+ :repositories_path => userconf.fetch("repositories_path",
75
+ File.join(userdir.to_path, 'repos')),
76
+ }
27
77
  end
28
78
 
29
79
  def env
@@ -44,7 +94,7 @@ end
44
94
  require 'kameleon/compat'
45
95
  require 'kameleon/utils'
46
96
  require 'kameleon/error'
97
+ require 'kameleon/repository'
47
98
  require 'kameleon/cli'
48
99
  require 'kameleon/environment'
49
100
  require 'kameleon/version'
50
- require 'kameleon/ui'
@@ -3,53 +3,138 @@ require 'kameleon/recipe'
3
3
  require 'kameleon/utils'
4
4
 
5
5
  module Kameleon
6
- class CLI < Thor
6
+
7
+ module CLI
8
+
9
+ class Repository < Thor
10
+ include Thor::Actions
11
+
12
+ desc "add [NAME] [URL]", "Adds a new named <name> repository at <url>."
13
+ method_option :branch, :type => :string ,
14
+ :default => nil,
15
+ :desc => "checkout <branch>",
16
+ :aliases => "-b"
17
+ def add(name, url)
18
+ Kameleon::Repository.add(name, url, options)
19
+ end
20
+
21
+ desc "list", "Lists available repositories."
22
+ def list
23
+ Kameleon::Repository.list
24
+ end
25
+
26
+ desc "update [NAME]", "Updates a named <name> repository"
27
+ def update(name)
28
+ Kameleon::Repository.update(name)
29
+ end
30
+ map %w(-h --help) => :help
31
+ map %w(ls) => :list
32
+ end
33
+
34
+ class Template < Thor
35
+ include Thor::Actions
36
+
37
+ register CLI::Repository, 'repository', 'repository', 'Manages set of remote git repositories'
38
+
39
+ def self.source_root
40
+ Kameleon.env.repositories_path
41
+ end
42
+
43
+ desc "list", "Lists all available templates"
44
+ def list
45
+ Kameleon.ui.info "The following templates are available in " \
46
+ "#{ Kameleon.env.repositories_path }:"
47
+ Utils.list_recipes(Kameleon.env.repositories_path)
48
+ end
49
+
50
+ desc "import [TEMPLATE_NAME]", "Imports the given template"
51
+ def import(template_name)
52
+ template_path = File.join(Kameleon.env.repositories_path, template_name)
53
+ unless template_name.end_with? '.yaml'
54
+ template_path = template_path + '.yaml'
55
+ end
56
+ begin
57
+ tpl = RecipeTemplate.new(template_path)
58
+ rescue
59
+ raise TemplateNotFound, "Template '#{template_name}' not found. " \
60
+ "To see all templates, run the command "\
61
+ "`kameleon template ls`"
62
+ else
63
+ files2copy = tpl.base_recipes_files + tpl.files
64
+ files2copy.each do |path|
65
+ relative_path = path.relative_path_from(Kameleon.env.repositories_path)
66
+ dst = File.join(Kameleon.env.workspace, relative_path)
67
+ copy_file(path, dst)
68
+ end
69
+ end
70
+ end
71
+
72
+ desc "info [TEMPLATE_NAME]", "Display detailed information about a template"
73
+ def info(template_name)
74
+ template_path = File.join(Kameleon.env.repositories_path, template_name)
75
+ unless template_name.end_with? '.yaml'
76
+ template_path = template_path + '.yaml'
77
+ end
78
+ tpl = RecipeTemplate.new(template_path)
79
+ tpl.display_info
80
+ end
81
+ map %w(-h --help) => :help
82
+ map %w(ls) => :list
83
+ end
84
+ end
85
+
86
+
87
+ class Main < Thor
7
88
  include Thor::Actions
8
89
 
9
- class_option :color, :type => :boolean, :default => true,
10
- :desc => "Enable colorization in output"
11
- class_option :debug, :type => :boolean, :default => false,
12
- :desc => "Enable debug output"
13
- class_option :script, :type => :boolean, :default => false,
14
- :desc => "never prompts for user intervention",
90
+ # register CLI::Recipe, 'recipe', 'recipe', 'Manages the local recipes'
91
+ register CLI::Template, 'template', 'template', 'Lists and imports templates'
92
+
93
+ class_option :color, :type => :boolean, :default => Kameleon.default_values[:color],
94
+ :desc => "Enables colorization in output"
95
+ class_option :debug, :type => :boolean, :default => Kameleon.default_values[:debug],
96
+ :desc => "Enables debug output"
97
+ class_option :script, :type => :boolean, :default => Kameleon.default_values[:script],
98
+ :desc => "Never prompts for user intervention",
15
99
  :aliases => "-s"
16
100
  map %w(-h --help) => :help
17
101
 
18
- desc "import [TEMPLATE_NAME]", "Imports the given template"
19
- method_option :templates_path, :type => :string ,
20
- :default => Kameleon.default_templates_path, :aliases => "-t",
21
- :desc => "Using another templates directory"
22
- def import(template_name)
23
- templates_path = Kameleon.env.templates_path
24
- template_path = File.join(templates_path, template_name) + '.yaml'
25
- begin
26
- tpl = RecipeTemplate.new(template_path)
27
- rescue
28
- raise TemplateNotFound, "Template '#{template_name}' not found. " \
29
- "To see all templates, run the command "\
30
- "`kameleon templates`"
31
- else
32
- files2copy = tpl.base_recipes_files + tpl.files
33
- files2copy.each do |path|
34
- relative_path = path.relative_path_from(Kameleon.env.templates_path)
35
- dst = File.join(Kameleon.env.workspace, relative_path)
36
- copy_file(path, dst)
37
- end
38
- end
102
+ desc "version", "Prints the Kameleon's version information"
103
+ def version
104
+ puts "Kameleon version #{Kameleon::VERSION}"
39
105
  end
106
+ map %w(-v --version) => :version
40
107
 
41
- desc "new [RECIPE_NAME] [TEMPLATE_NAME]", "Creates a new recipe"
42
- method_option :templates_path, :type => :string ,
43
- :default => Kameleon.default_templates_path, :aliases => "-t",
44
- :desc => "Using another templates directory"
45
- def new(recipe_name, template_name)
46
- if recipe_name == template_name
47
- fail RecipeError, "Recipe name should be different from template name"
108
+ def self.source_root
109
+ Kameleon.env.repositories_path
110
+ end
111
+
112
+ desc "list", "Lists all defined recipes in the current directory"
113
+ def list
114
+ Utils.list_recipes(Kameleon.env.workspace)
115
+ end
116
+ map %w(ls) => :list
117
+
118
+ desc "new [RECIPE_PATH] [TEMPLATE_NAME]", "Creates a new recipe"
119
+ def new(recipe_path, template_name)
120
+ unless template_name.end_with? '.yaml'
121
+ template_name = template_name + '.yaml'
48
122
  end
49
- templates_path = Kameleon.env.templates_path
50
- template_path = File.join(templates_path, template_name) + '.yaml'
123
+
124
+ unless recipe_path.end_with? '.yaml'
125
+ recipe_path = recipe_path + '.yaml'
126
+ end
127
+
128
+ if recipe_path == template_name
129
+ fail RecipeError, "Recipe path should be different from template name"
130
+ end
131
+
132
+ template_path = File.join(Kameleon.env.repositories_path, template_name)
133
+
134
+ recipe_path = Pathname.new(Kameleon.env.workspace).join(recipe_path).to_path
135
+
51
136
  begin
52
- tpl = RecipeTemplate.new(template_path)
137
+ tpl = Kameleon::RecipeTemplate.new(template_path)
53
138
  rescue
54
139
  raise TemplateNotFound, "Template '#{template_name}' not found. " \
55
140
  "To see all templates, run the command "\
@@ -57,87 +142,53 @@ module Kameleon
57
142
  else
58
143
  files2copy = tpl.base_recipes_files + tpl.files
59
144
  files2copy.each do |path|
60
- relative_path = path.relative_path_from(Kameleon.env.templates_path)
145
+ relative_path = path.relative_path_from(Kameleon.env.repositories_path)
61
146
  dst = File.join(Kameleon.env.workspace, relative_path)
62
147
  copy_file(path, dst)
63
148
  end
64
149
  Dir::mktmpdir do |tmp_dir|
65
- recipe_path = File.join(tmp_dir, recipe_name + '.yaml')
150
+ recipe_temp = File.join(tmp_dir, File.basename(recipe_path))
66
151
  ## copying recipe
67
- File.open(recipe_path, 'w+') do |file|
68
- extend_erb_tpl = File.join(Kameleon.default_templates_path, "extend.erb")
152
+ File.open(recipe_temp, 'w+') do |file|
153
+ extend_erb_tpl = File.join(Kameleon.erb_dirpath, "extend.erb")
69
154
  erb = ERB.new(File.open(extend_erb_tpl, 'rb') { |f| f.read })
70
155
  result = erb.result(binding)
71
156
  file.write(result)
72
157
  end
73
- recipe_dst = File.join(Kameleon.env.workspace, recipe_name + '.yaml')
74
- copy_file(recipe_path, Pathname.new(recipe_dst))
158
+ copy_file(recipe_temp, recipe_path)
75
159
  end
76
160
  end
77
161
  end
78
162
 
79
- desc "templates", "Lists all defined templates"
80
- method_option :templates_path, :type => :string ,
81
- :default => Kameleon.default_templates_path, :aliases => "-t",
82
- :desc => "Using another templates directory"
83
- def templates
84
- puts "The following templates are available in " \
85
- "#{ Kameleon.env.templates_path }:"
86
- templates_hash = []
87
- templates_path = File.join(Kameleon.env.templates_path, "/")
88
- all_yaml_files = Dir["#{templates_path}**/*.yaml"]
89
- steps_files = Dir["#{templates_path}steps/**/*.yaml"]
90
- templates_files = all_yaml_files - steps_files
91
- templates_files.each do |f|
92
- begin
93
- recipe = RecipeTemplate.new(f)
94
- templates_hash.push({
95
- "name" => f.gsub(templates_path, "").chomp(".yaml"),
96
- "description" => recipe.metainfo['description'],
97
- })
98
- rescue => e
99
- raise e if Kameleon.env.debug
100
- end
101
- end
102
- unless templates_hash.empty?
103
- templates_hash = templates_hash.sort_by{ |k| k["name"] }
104
- name_width = templates_hash.map { |k| k['name'].size }.max
105
- desc_width = Kameleon.ui.shell.terminal_width - name_width - 3
106
- end
107
- tp(templates_hash,
108
- {"name" => {:width => name_width}},
109
- { "description" => {:width => desc_width}})
110
- end
111
-
112
- desc "version", "Prints the Kameleon's version information"
113
- def version
114
- puts "Kameleon version #{Kameleon::VERSION}"
163
+ desc "info [RECIPE_PATH]", "Display detailed information about a recipe"
164
+ def info(recipe_path)
165
+ recipe = Kameleon::Recipe.new(recipe_path)
166
+ recipe.display_info
115
167
  end
116
- map %w(-v --version) => :version
117
168
 
118
- desc "build [RECIPE_PATH]", "Builds the appliance from the given recipe"
169
+ desc "build [[RECIPE_PATH]]", "Builds the appliance from the given recipe"
119
170
  method_option :build_path, :type => :string ,
120
171
  :default => nil, :aliases => "-b",
121
- :desc => "Set the build directory path"
172
+ :desc => "Sets the build directory path"
122
173
  method_option :clean, :type => :boolean ,
123
174
  :default => false,
124
- :desc => "Run the command `kameleon clean` first"
175
+ :desc => "Runs the command `kameleon clean` first"
125
176
  method_option :from_checkpoint, :type => :string ,
126
177
  :default => nil,
127
- :desc => "Using specific checkpoint to build the image. " \
178
+ :desc => "Uses specific checkpoint to build the image. " \
128
179
  "Default value is the last checkpoint."
129
- method_option :checkpoint, :type => :boolean ,
180
+ method_option :enable_checkpoint, :type => :boolean ,
130
181
  :default => false,
131
- :desc => "Enable checkpoint"
132
- method_option :cache, :type => :boolean,
182
+ :desc => "Enables checkpoint [experimental]"
183
+ method_option :enable_cache, :type => :boolean,
133
184
  :default => false,
134
- :desc => "Generate a persistent cache for the appliance."
185
+ :desc => "Generates a persistent cache for the appliance."
135
186
  method_option :cache_path, :type => :string ,
136
187
  :default => nil,
137
- :desc => "Set the cache directory path"
188
+ :desc => "Sets the cache directory path"
138
189
  method_option :from_cache, :type => :string ,
139
190
  :default => nil,
140
- :desc => "Using a persistent cache tar file to build the image."
191
+ :desc => "Uses a persistent cache tar file to build the image."
141
192
  method_option :proxy_path, :type => :string ,
142
193
  :default => nil,
143
194
  :desc => "Full path of the proxy binary to use for the persistent cache."
@@ -172,10 +223,10 @@ module Kameleon
172
223
  engine.pretty_checkpoints_list
173
224
  end
174
225
 
175
- desc "clean [RECIPE_PATH]", "Cleaning all contexts and removing the checkpoints"
226
+ desc "clean [RECIPE_PATH]", "Cleans all contexts and removing the checkpoints"
176
227
  method_option :build_path, :type => :string ,
177
228
  :default => nil, :aliases => "-b",
178
- :desc => "Set the build directory path"
229
+ :desc => "Sets the build directory path"
179
230
  def clean(recipe_path)
180
231
  opts = Hash.new.merge options
181
232
  opts[:lazyload] = false
@@ -187,7 +238,7 @@ module Kameleon
187
238
 
188
239
  desc "commands", "Lists all available commands", :hide => true
189
240
  def commands
190
- puts CLI.all_commands.keys - ["commands", "completions"]
241
+ puts Main.all_commands.keys - ["commands", "completions"]
191
242
  end
192
243
 
193
244
  desc "source_root", "Prints the kameleon directory path", :hide => true
@@ -207,7 +258,7 @@ module Kameleon
207
258
  opts = args[1]
208
259
  cmd_name = args[2][:current_command].name
209
260
  if opts.include? "--help" or opts.include? "-h"
210
- CLI.command_help(Kameleon.ui.shell, cmd_name)
261
+ Main.command_help(Kameleon.ui.shell, cmd_name)
211
262
  raise Kameleon::Exit
212
263
  end
213
264
  end
@@ -219,10 +270,6 @@ module Kameleon
219
270
  raise e
220
271
  end
221
272
 
222
- def self.source_root
223
- Kameleon.source_root
224
- end
225
-
226
273
  end
227
274
 
228
275
  end