Class: BuildRunner

Inherits:
Object
  • Object
show all
Includes:
Common, PackerExec
Defined in:
lib/bento/build.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PackerExec

#for_packer_run_with, #write_box_metadata, #write_var_file

Methods included from Common

#banner, #box_metadata, #build_list, #builds_yml, #duration, #info, #macos?, #metadata_files, #private_box?, #unix?, #vc_account, #warn, #windows?

Constructor Details

#initialize(opts) ⇒ BuildRunner

Returns a new instance of BuildRunner.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bento/build.rb', line 13

def initialize(opts)
  @template_files = opts.template_files
  @config = opts.config ||= false
  @dry_run = opts.dry_run
  @debug = opts.debug
  @only = opts.only ||= "parallels-iso,virtualbox-iso,vmware-iso"
  @except = opts.except
  @mirror = opts.mirror
  @headed = opts.headed ||= false
  @single = opts.single ||= false
  @override_version = opts.override_version
  @build_timestamp = Time.now.gmtime.strftime("%Y%m%d%H%M%S")
  @cpus = opts.cpus
  @mem = opts.mem
end

Instance Attribute Details

#build_timestampObject (readonly)

Returns the value of attribute build_timestamp.



10
11
12
# File 'lib/bento/build.rb', line 10

def build_timestamp
  @build_timestamp
end

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/bento/build.rb', line 10

def config
  @config
end

#cpusObject (readonly)

Returns the value of attribute cpus.



10
11
12
# File 'lib/bento/build.rb', line 10

def cpus
  @cpus
end

#debugObject (readonly)

Returns the value of attribute debug.



10
11
12
# File 'lib/bento/build.rb', line 10

def debug
  @debug
end

#dry_runObject (readonly)

Returns the value of attribute dry_run.



10
11
12
# File 'lib/bento/build.rb', line 10

def dry_run
  @dry_run
end

#exceptObject (readonly)

Returns the value of attribute except.



10
11
12
# File 'lib/bento/build.rb', line 10

def except
  @except
end

#headedObject (readonly)

Returns the value of attribute headed.



10
11
12
# File 'lib/bento/build.rb', line 10

def headed
  @headed
end

#memObject (readonly)

Returns the value of attribute mem.



10
11
12
# File 'lib/bento/build.rb', line 10

def mem
  @mem
end

#mirrorObject (readonly)

Returns the value of attribute mirror.



10
11
12
# File 'lib/bento/build.rb', line 10

def mirror
  @mirror
end

#onlyObject (readonly)

Returns the value of attribute only.



10
11
12
# File 'lib/bento/build.rb', line 10

def only
  @only
end

#override_versionObject (readonly)

Returns the value of attribute override_version.



10
11
12
# File 'lib/bento/build.rb', line 10

def override_version
  @override_version
end

#singleObject (readonly)

Returns the value of attribute single.



10
11
12
# File 'lib/bento/build.rb', line 10

def single
  @single
end

#template_filesObject (readonly)

Returns the value of attribute template_files.



10
11
12
# File 'lib/bento/build.rb', line 10

def template_files
  @template_files
end

Instance Method Details

#startObject



29
30
31
32
33
34
35
36
37
# File 'lib/bento/build.rb', line 29

def start
  templates = config ? build_list : template_files
  banner("Starting build for templates:")
  templates.each { |t| puts "- #{t}" }
  time = Benchmark.measure do
    templates.each { |template| build(template) }
  end
  banner("Build finished in #{duration(time.real)}.")
end