Class: Veewee::Command::Vagrant::Build

Inherits:
Vagrant::Command::Base
  • Object
show all
Defined in:
lib/veewee/command/vagrant/build.rb

Instance Method Summary collapse

Instance Method Details

#executeObject

Raises:

  • (::Vagrant::Errors::CLIInvalidUsage)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/veewee/command/vagrant/build.rb', line 7

def execute
  options = {}

  opts = OptionParser.new do |opts|
    opts.banner = "Build the box <boxname>"
    opts.separator ""
    opts.separator "Usage: vagrant basebox build <boxname>"

    opts.on("-f", "--force", "overwrite the basebox") do |f|
      options['force'] = f
    end

    opts.on("-n", "--nogui", "no gui") do |n|
      options['nogui'] = n
    end

    opts.on("-a", "--auto", "auto answers") do |a|
      options['auto'] = a
    end

    opts.on("-d", "--debug", "enable debugging") do |d|
      options['debug'] = d
    end

    opts.on("-r", "--redirect-console", "redirects serial console") do |r|
      options['redirectconsole'] = r
    end

    opts.on("-i", "--include",Array,"ruby regexp of postinstall filenames to additionally include") do |i|
      options['postinstall_include'] = i
    end

    opts.on("-e", "--exclude",Array,"ruby regexp of postinstall filenames to exclude") do |e|
      options['postinstall_list'] = e
    end

    opts.on("--[no-]checksum","force to check iso file check sum") do |v|
      options['checksum'] = v
    end

  end

  # Parse the options
  argv = parse_options(opts)
  return if !argv
  raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 1

  begin
    venv=Veewee::Environment.new(options)
    venv.ui=@env.ui
    venv.providers["virtualbox"].get_box(argv[0]).build(options)
  rescue Veewee::Error => ex
    venv.ui.error(ex, :prefix => false)
    exit -1
  end

end