Class: Bosh::Stemcell::BuildEnvironment

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/bosh/stemcell/build_environment.rb

Constant Summary collapse

STEMCELL_BUILDER_SOURCE_DIR =
File.join(File.expand_path('../../../../..', __FILE__), 'stemcell_builder')
STEMCELL_SPECS_DIR =
File.expand_path('../../..', File.dirname(__FILE__))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, definition, version, release_tarball_path, os_image_tarball_path) ⇒ BuildEnvironment

Returns a new instance of BuildEnvironment.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bosh/stemcell/build_environment.rb', line 13

def initialize(env, definition, version, release_tarball_path, os_image_tarball_path)
  @environment = env
  @definition = definition
  @os_image_tarball_path = os_image_tarball_path
  @version = version
  @stemcell_builder_options = BuilderOptions.new(
    env: env,
    definition: definition,
    version: version,
    release_tarball: release_tarball_path,
    os_image_tarball: os_image_tarball_path,
  )
  @shell = Bosh::Core::Shell.new
end

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.



28
29
30
# File 'lib/bosh/stemcell/build_environment.rb', line 28

def version
  @version
end

Instance Method Details

#build_pathObject



65
66
67
# File 'lib/bosh/stemcell/build_environment.rb', line 65

def build_path
  File.join(build_root, 'build')
end

#chroot_dirObject



76
77
78
# File 'lib/bosh/stemcell/build_environment.rb', line 76

def chroot_dir
  File.join(work_path, 'chroot')
end

#command_envObject



96
97
98
# File 'lib/bosh/stemcell/build_environment.rb', line 96

def command_env
  "env #{hash_as_bash_env(proxy_settings_from_environment)}"
end

#os_image_rspec_commandObject



41
42
43
44
45
46
47
48
# File 'lib/bosh/stemcell/build_environment.rb', line 41

def os_image_rspec_command
  [
    "cd #{STEMCELL_SPECS_DIR};",
    "OS_IMAGE=#{os_image_tarball_path}",
    "bundle exec rspec -fd#{exclude_arch_exclusions}",
    "spec/os_image/#{operating_system_spec_name}_spec.rb",
  ].join(' ')
end

#prepare_buildObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/bosh/stemcell/build_environment.rb', line 30

def prepare_build
  if (ENV['resume_from'] == NIL)
    sanitize
    prepare_build_path
  end
  copy_stemcell_builder_to_build_path
  prepare_work_root
  prepare_stemcell_path
  persist_settings_for_bash
end

#settings_pathObject



80
81
82
# File 'lib/bosh/stemcell/build_environment.rb', line 80

def settings_path
  File.join(build_path, 'etc', 'settings.bash')
end

#stemcell_disk_sizeObject



92
93
94
# File 'lib/bosh/stemcell/build_environment.rb', line 92

def stemcell_disk_size
  stemcell_builder_options.image_create_disk_size
end

#stemcell_filesObject



69
70
71
72
73
74
# File 'lib/bosh/stemcell/build_environment.rb', line 69

def stemcell_files
  definition.disk_formats.map do |disk_format|
    stemcell_filename = Stemcell.new(@definition, 'bosh-stemcell', @version, disk_format)
    File.join(work_path, stemcell_filename.name)
  end
end

#stemcell_rspec_commandObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bosh/stemcell/build_environment.rb', line 50

def stemcell_rspec_command
  [
    "cd #{STEMCELL_SPECS_DIR};",
    "STEMCELL_IMAGE=#{image_file_path}",
    "STEMCELL_WORKDIR=#{work_path}",
    "OS_NAME=#{operating_system.name}",
    "bundle exec rspec -fd#{exclude_exclusions}",
    "spec/os_image/#{operating_system_spec_name}_spec.rb",
    "spec/stemcells/#{operating_system_spec_name}_spec.rb",
    "spec/stemcells/#{agent.name}_agent_spec.rb",
    "spec/stemcells/#{infrastructure.name}_spec.rb",
    'spec/stemcells/stig_spec.rb'
  ].join(' ')
end

#stemcell_tarball_pathObject



88
89
90
# File 'lib/bosh/stemcell/build_environment.rb', line 88

def stemcell_tarball_path
  work_path
end

#work_pathObject



84
85
86
# File 'lib/bosh/stemcell/build_environment.rb', line 84

def work_path
  File.join(work_root, 'work')
end