kameleon-builder 2.10.9 → 2.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/kameleon/cli.rb CHANGED
@@ -11,7 +11,7 @@ module Kameleon
11
11
  class Repository < Thor
12
12
  include Thor::Actions
13
13
 
14
- desc "add <NAME> <GIT_URL>", "Adds a new repository named <NAME> cloned from <GIT_URL>."
14
+ desc "add <NAME> <GIT_URL>", "Add a new repository named <NAME> cloned from <GIT_URL>"
15
15
  method_option :branch, :type => :string,
16
16
  :default => nil,
17
17
  :desc => "checkout <BRANCH>",
@@ -20,7 +20,7 @@ module Kameleon
20
20
  Kameleon::Repository.add(name, url, options)
21
21
  end
22
22
 
23
- desc "list", "Lists available repositories."
23
+ desc "list", "List available repositories"
24
24
  method_option :git, :type => :boolean,
25
25
  :default => true,
26
26
  :desc => "show the git repository and branch each repository comes from"
@@ -28,7 +28,7 @@ module Kameleon
28
28
  Kameleon::Repository.list(options)
29
29
  end
30
30
 
31
- desc "update <NAME>", "Updates repository named <NAME> from git"
31
+ desc "update <NAME>", "Update repository named <NAME> from git"
32
32
  def update(name)
33
33
  Kameleon::Repository.update(name)
34
34
  end
@@ -38,7 +38,7 @@ module Kameleon
38
38
  Kameleon::Repository.remove(name)
39
39
  end
40
40
 
41
- desc "commands", "Lists all available commands", :hide => true
41
+ desc "commands", "List all available commands", :hide => true
42
42
  def commands
43
43
  puts Repository.all_commands.keys - ["commands"]
44
44
  end
@@ -56,7 +56,7 @@ module Kameleon
56
56
  Kameleon.env.repositories_path
57
57
  end
58
58
 
59
- desc "list", "Lists all available templates"
59
+ desc "list", "List all available templates"
60
60
  method_option :progress, :type => :boolean, :default => true,
61
61
  :desc => "Show progress bar while resolving templates",
62
62
  :aliases => "-p"
@@ -69,10 +69,10 @@ module Kameleon
69
69
  Utils.list_recipes(Kameleon.env.repositories_path, options[:filter], options[:progress], true)
70
70
  end
71
71
 
72
- desc "import <TEMPLATE_NAME>", "Imports the given template"
72
+ desc "import <TEMPLATE_NAME>", "Import the given template"
73
73
  method_option :global, :type => :hash,
74
74
  :default => {}, :aliases => "-g",
75
- :desc => "Set custom global variables."
75
+ :desc => "Set custom global variables"
76
76
  def import(template_name)
77
77
  Kameleon.env.root_dir = Kameleon.env.repositories_path
78
78
  template_path = File.join(Kameleon.env.repositories_path, template_name)
@@ -104,7 +104,7 @@ module Kameleon
104
104
  desc "info <TEMPLATE_NAME>", "Display detailed information about a template"
105
105
  method_option :global, :type => :hash,
106
106
  :default => {}, :aliases => "-g",
107
- :desc => "Set custom global variables."
107
+ :desc => "Set custom global variables"
108
108
  def info(template_name)
109
109
  Kameleon.env.root_dir = Kameleon.env.repositories_path
110
110
  template_path = File.join(Kameleon.env.repositories_path, template_name)
@@ -133,7 +133,7 @@ module Kameleon
133
133
  copy_file(Pathname.new(Kameleon.erb_dirpath).join("extend.yaml.erb"), erb_file)
134
134
  end
135
135
 
136
- desc "commands", "Lists all available commands", :hide => true
136
+ desc "commands", "List all available commands", :hide => true
137
137
  def commands
138
138
  puts Template.all_commands.keys - ["commands"]
139
139
  end
@@ -147,22 +147,22 @@ module Kameleon
147
147
  class Main < Thor
148
148
  include Thor::Actions
149
149
 
150
- desc 'repository <SUBCOMMAND>', 'Manages repositories of recipes'
150
+ desc 'repository <SUBCOMMAND>', 'Manage repositories of recipes'
151
151
  subcommand 'repository', CLI::Repository
152
- desc 'template <SUBCOMMAND>', 'Lists and imports templates'
152
+ desc 'template <SUBCOMMAND>', 'List and import templates'
153
153
  subcommand 'template', CLI::Template
154
154
 
155
155
  class_option :color, :type => :boolean, :default => Kameleon.default_values[:color],
156
- :desc => "Enables colorization in output"
156
+ :desc => "Enable colorization in output"
157
157
  class_option :verbose, :type => :boolean, :default => Kameleon.default_values[:verbose],
158
- :desc => "Enables verbose output for kameleon users"
158
+ :desc => "Enable verbose output for kameleon users"
159
159
  class_option :debug, :type => :boolean, :default => Kameleon.default_values[:debug],
160
- :desc => "Enables debug output for kameleon developpers"
160
+ :desc => "Enable debug output for kameleon developpers"
161
161
  class_option :script, :type => :boolean, :default => Kameleon.default_values[:script],
162
- :desc => "Never prompts for user intervention",
162
+ :desc => "Never prompt for user intervention",
163
163
  :aliases => "-s"
164
164
 
165
- desc "version", "Prints the Kameleon's version information"
165
+ desc "version", "Print the Kameleon's version information"
166
166
  def version
167
167
  puts "Kameleon version #{Kameleon::VERSION}"
168
168
  end
@@ -171,7 +171,7 @@ module Kameleon
171
171
  Kameleon.env.repositories_path
172
172
  end
173
173
 
174
- desc "list", "Lists all defined recipes in the current directory"
174
+ desc "list", "List all defined recipes in the current directory"
175
175
  method_option :progress, :type => :boolean, :default => false,
176
176
  :desc => "Show progress bar while resolving recipes",
177
177
  :aliases => "-p"
@@ -183,10 +183,10 @@ module Kameleon
183
183
  Utils.list_recipes(Kameleon.env.workspace, options[:filter], options[:progress])
184
184
  end
185
185
 
186
- desc "new <RECIPE_PATH> <TEMPLATE_NAME>", "Creates a new recipe from template <TEMPLATE_NAME>"
186
+ desc "new <RECIPE_PATH> <TEMPLATE_NAME>", "Create a new recipe from template <TEMPLATE_NAME>"
187
187
  method_option :global, :type => :hash,
188
188
  :default => {}, :aliases => "-g",
189
- :desc => "Set custom global variables."
189
+ :desc => "Set custom global variables"
190
190
  def new(recipe_name, template_name)
191
191
  Kameleon.env.root_dir = Kameleon.env.repositories_path
192
192
  unless template_name.end_with? '.yaml'
@@ -248,7 +248,7 @@ module Kameleon
248
248
  desc "info <RECIPE_PATH>", "Display detailed information about a recipe"
249
249
  method_option :global, :type => :hash,
250
250
  :default => {}, :aliases => "-g",
251
- :desc => "Set custom global variables."
251
+ :desc => "Set custom global variables"
252
252
  method_option :from_cache, :type => :string,
253
253
  :default => nil,
254
254
  :desc => "Get info from a persistent cache tar file (ignore recipe path)"
@@ -280,7 +280,7 @@ module Kameleon
280
280
  desc "dag <RECIPE_PATH> [<RECIPE_PATH> [<...>]]", "Draw a DAG of the steps to build one or more recipes"
281
281
  method_option :global, :type => :hash,
282
282
  :default => {}, :aliases => "-g",
283
- :desc => "Set custom global variables."
283
+ :desc => "Set custom global variables"
284
284
  method_option :file, :type => :string,
285
285
  :default => "/tmp/kameleon.dag",
286
286
  :desc => "DAG output filename"
@@ -319,25 +319,10 @@ module Kameleon
319
319
  Kameleon.ui.info("Generated GraphViz #{format} file: #{options[:file]}")
320
320
  end
321
321
 
322
- desc "dryrun <RECIPE_PATH>", "Show the steps the build would process"
323
- method_option :global, :type => :hash,
324
- :default => {}, :aliases => "-g",
325
- :desc => "Set custom global variables."
326
- method_option :relative, :type => :boolean,
327
- :default => false,
328
- :desc => "Make pathnames relative to the current working directory"
329
- def dryrun(*recipe_paths)
330
- raise ArgumentError if recipe_paths.empty?
331
- recipe_paths.each do |path|
332
- recipe = Kameleon::Recipe.new(path)
333
- Kameleon::Engine.new(recipe, options.dup.merge({no_create_build_dir: true}).freeze).dryrun
334
- end
335
- end
336
-
337
322
  desc "export <RECIPE_PATH> <EXPORT_PATH>", "Export the given recipe with its steps and data to a given directory"
338
323
  method_option :global, :type => :hash,
339
324
  :default => {}, :aliases => "-g",
340
- :desc => "Set custom global variables."
325
+ :desc => "Set custom global variables"
341
326
  method_option :add, :type => :boolean,
342
327
  :default => false, :aliases => "-A",
343
328
  :desc => "export recipe and steps to an existing directory (this may overwrite some existing files)"
@@ -377,56 +362,64 @@ module Kameleon
377
362
  end
378
363
  end
379
364
 
380
- desc "build <RECIPE_PATH>", "Builds the appliance from the given recipe"
365
+ desc "build <RECIPE_PATH>", "Build the appliance from the given recipe"
381
366
  method_option :build_path, :type => :string,
382
367
  :default => nil, :aliases => "-b",
383
- :desc => "Sets the build directory path"
368
+ :desc => "Set the build directory path"
384
369
  method_option :clean, :type => :boolean,
385
370
  :default => false,
386
- :desc => "Runs the command `kameleon clean` first"
387
- method_option :from_checkpoint, :type => :string,
371
+ :desc => "Run the command `kameleon clean` first"
372
+ method_option :dryrun, :type => :boolean, :aliases => "-d",
373
+ :default => false,
374
+ :desc => "Dry run, only show what would run"
375
+ method_option :relative, :type => :boolean,
376
+ :default => false,
377
+ :desc => "Make dryrun show pathnames relative to the current working directory"
378
+ method_option :from_checkpoint, :type => :string, :aliases => "-F",
379
+ :default => nil,
380
+ :desc => "Restart the build from a specific checkpointed step, instead of the latest one"
381
+ method_option :begin_checkpoint, :type => :string, :aliases => "-B",
388
382
  :default => nil,
389
- :desc => "Uses specific checkpoint to build the image. " \
390
- "Default value is the last checkpoint."
391
- method_option :enable_checkpoint, :type => :boolean,
383
+ :desc => "Only create checkpoints after the given step"
384
+ method_option :end_checkpoint, :type => :string, :aliases => "-E",
385
+ :default => nil,
386
+ :desc => "Do not create checkpoints after the given step"
387
+ method_option :enable_checkpointing, :type => :boolean, :aliases => "-c",
392
388
  :default => false,
393
- :desc => "Enables checkpointing"
394
- method_option :microstep_checkpoint, :type => :string,
389
+ :desc => "Enable creating and using checkpoints"
390
+ method_option :microstep_checkpoints, :type => :string,
395
391
  :enum => ["first", "all"],
396
- :default => "first",
392
+ :default => "all",
397
393
  :desc => "Create checkpoint of the first microstep only, or all"
398
- method_option :list_checkpoints, :type => :boolean, :aliases => "--checkpoints",
394
+ method_option :list_checkpoints, :type => :boolean, :aliases => "-l",
399
395
  :default => false,
400
- :desc => "Lists all availables checkpoints"
401
- method_option :enable_cache, :type => :boolean,
396
+ :desc => "List availables checkpoints"
397
+ method_option :enable_cache, :type => :boolean, :aliases => "-C",
402
398
  :default => false,
403
- :desc => "Generates a persistent cache for the appliance."
399
+ :desc => "Generate a persistent cache for the appliance"
404
400
  method_option :cache_path, :type => :string,
405
401
  :default => nil,
406
- :desc => "Sets the cache directory path"
402
+ :desc => "Set the cache directory path"
407
403
  method_option :from_cache, :type => :string,
408
404
  :default => nil,
409
- :desc => "Uses a persistent cache tar file to build the image."
405
+ :desc => "Use a persistent cache tar file to build the image"
410
406
  method_option :cache_archive_compression, :type => :string,
411
407
  :enum => ["none", "gzip", "bz2", "xz"],
412
408
  :default => "gzip",
413
- :desc => "Set the persistent cache tar file compression."
409
+ :desc => "Set the persistent cache tar file compression"
414
410
  method_option :polipo_path, :type => :string,
415
411
  :default => nil,
416
- :desc => "Full path of the polipo binary to use for the persistent cache."
412
+ :desc => "Full path of the polipo binary to use for the persistent cache"
417
413
  method_option :proxy, :type => :string, :default => "",
418
- :desc => "Specifies the hostname and port number of an HTTP " \
419
- "proxy; it should have the form 'host:port'"
414
+ :desc => "HTTP proxy address and port (expected format is hostname:port)"
420
415
  method_option :proxy_credentials, :type => :string, :default => "",
421
- :desc => "Specifies the username and password if the parent "\
422
- "proxy requires authorisation it should have the "\
423
- "form 'username:password'"
416
+ :desc => "Username and password if required by the parent proxy (expected format is username:password)"
424
417
  method_option :proxy_offline, :type => :boolean,
425
- :default => false, :aliases => "--offline",
426
- :desc => "Prevents Polipo from contacting remote servers"
418
+ :default => false,
419
+ :desc => "Prevent Polipo from contacting remote servers"
427
420
  method_option :global, :type => :hash,
428
421
  :default => {}, :aliases => "-g",
429
- :desc => "Set custom global variables."
422
+ :desc => "Set custom global variables"
430
423
  def build(recipe_path=nil)
431
424
  if recipe_path.nil? && !options[:from_cache].nil?
432
425
  unless File.file?(options[:from_cache])
@@ -440,7 +433,9 @@ module Kameleon
440
433
  end
441
434
  raise BuildError, "A recipe file or a persistent cache archive " \
442
435
  "is required to run this command." if recipe_path.nil?
443
- if options[:clean]
436
+ if options[:dryrun]
437
+ Kameleon::Engine.new(Kameleon::Recipe.new(recipe_path), options.dup.merge({no_create_build_dir: true}).freeze).dryrun
438
+ elsif options[:clean]
444
439
  opts = Hash.new.merge options
445
440
  opts[:lazyload] = false
446
441
  opts[:fail_silently] = true
@@ -458,11 +453,11 @@ module Kameleon
458
453
  total_time = Time.now.to_i - start_time
459
454
  Kameleon.ui.info("")
460
455
  Kameleon.ui.info("Successfully built '#{recipe_path}'")
461
- Kameleon.ui.info("Total duration : #{total_time} secs")
456
+ Kameleon.ui.info("Total duration: #{total_time} secs")
462
457
  end
463
458
  end
464
459
 
465
- desc "commands", "Lists all available commands", :hide => true
460
+ desc "commands", "List all available commands", :hide => true
466
461
  def commands(context="main")
467
462
  Kameleon.ui.debug("Commands for '#{context}':")
468
463
  case context
@@ -475,7 +470,7 @@ module Kameleon
475
470
  end
476
471
  end
477
472
 
478
- desc "source_root", "Prints the kameleon directory path", :hide => true
473
+ desc "source_root", "Print the kameleon directory path", :hide => true
479
474
  def source_root
480
475
  puts Kameleon.source_root
481
476
  end
@@ -79,7 +79,7 @@ module Kameleon
79
79
  do_log(out, log_level) unless out.nil?
80
80
  do_log(err, "error") unless err.nil?
81
81
  end
82
- Kameleon.ui.verbose("Exit status : #{exit_status}")
82
+ Kameleon.ui.verbose("Exit status: #{exit_status}")
83
83
  fail ExecError unless exit_status.eql? 0
84
84
  rescue ShellError, Errno::EPIPE => e
85
85
  Kameleon.ui.verbose("Shell cmd failed to launch: #{@shell.shell_cmd}")