Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'rake'
gem 'bosh-stemcell', path: 'bosh-stemcell'
gem "rake"
gem "bosh-stemcell", path: "bosh-stemcell"
gem "standard"
47 changes: 47 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.3)
diff-lcs (1.6.2)
json (2.19.8)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
parallel (1.28.0)
parser (3.3.11.1)
ast (~> 2.4.1)
racc
prism (1.9.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.4.2)
regexp_parser (2.12.0)
rspec (3.13.2)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -27,13 +39,48 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.7)
rubocop (1.84.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.49.1)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-performance (1.26.1)
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.47.1, < 2.0)
ruby-progressbar (1.13.0)
standard (1.54.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.84.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.8)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.9.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.26.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.2.0)

PLATFORMS
ruby

DEPENDENCIES
bosh-stemcell!
rake
standard

BUNDLED WITH
2.5.23
199 changes: 98 additions & 101 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,111 +1,108 @@
require 'json'
require "json"
require "standard/rake"

namespace :stemcell do
desc 'Build a base OS image for use in stemcells'
desc "Build a base OS image for use in stemcells"
task :build_os_image, [:operating_system_name, :operating_system_version, :os_image_path] do |_, args|
begin
require 'bosh/stemcell/archive_handler'
require 'bosh/stemcell/build_environment'
require 'bosh/stemcell/definition'
require 'bosh/stemcell/os_image_builder'
require 'bosh/stemcell/stage_collection'
require 'bosh/stemcell/stage_runner'

definition = Bosh::Stemcell::Definition.for('null', 'null', args.operating_system_name, args.operating_system_version)
environment = Bosh::Stemcell::BuildEnvironment.new(
ENV.to_hash,
definition,
'',
args.os_image_path,
)
collection = Bosh::Stemcell::StageCollection.new(definition)
runner = Bosh::Stemcell::StageRunner.new(
build_path: environment.build_path,
command_env: environment.command_env,
settings_file: environment.settings_path,
work_path: environment.work_path,
)
archive_handler = Bosh::Stemcell::ArchiveHandler.new

builder = Bosh::Stemcell::OsImageBuilder.new(
environment: environment,
collection: collection,
runner: runner,
archive_handler: archive_handler,
)
builder.build(args.os_image_path)

sh(environment.os_image_rspec_command)
rescue RuntimeError => e
print_help
raise e
end
require "bosh/stemcell/archive_handler"
require "bosh/stemcell/build_environment"
require "bosh/stemcell/definition"
require "bosh/stemcell/os_image_builder"
require "bosh/stemcell/stage_collection"
require "bosh/stemcell/stage_runner"

definition = Bosh::Stemcell::Definition.for("null", "null", args.operating_system_name, args.operating_system_version)
environment = Bosh::Stemcell::BuildEnvironment.new(
ENV.to_hash,
definition,
"",
args.os_image_path
)
collection = Bosh::Stemcell::StageCollection.new(definition)
runner = Bosh::Stemcell::StageRunner.new(
build_path: environment.build_path,
command_env: environment.command_env,
settings_file: environment.settings_path,
work_path: environment.work_path
)
archive_handler = Bosh::Stemcell::ArchiveHandler.new

builder = Bosh::Stemcell::OsImageBuilder.new(
environment: environment,
collection: collection,
runner: runner,
archive_handler: archive_handler
)
builder.build(args.os_image_path)

sh(environment.os_image_rspec_command)
rescue RuntimeError => e
print_help
raise e
end

desc 'Build a stemcell, requires `os_image_path` pointing at an image created via `stemcell:build_os_image`'
desc "Build a stemcell, requires `os_image_path` pointing at an image created via `stemcell:build_os_image`"
task :build, [:infrastructure_name, :hypervisor_name, :operating_system_name, :operating_system_version, :os_image_path, :build_number] do |_, args|
begin
require 'bosh/stemcell/build_environment'
require 'bosh/stemcell/definition'
require 'bosh/stemcell/stage_collection'
require 'bosh/stemcell/stage_runner'
require 'bosh/stemcell/stemcell_packager'
require 'bosh/stemcell/stemcell_builder'

args.with_defaults(build_number: '0000')

definition = Bosh::Stemcell::Definition.for(args.infrastructure_name, args.hypervisor_name, args.operating_system_name, args.operating_system_version)
environment = Bosh::Stemcell::BuildEnvironment.new(
ENV.to_hash,
definition,
args.build_number,
args.os_image_path,
)

sh(environment.os_image_rspec_command)

puts "Working from #{environment.work_path}..."
puts "########################################"
runner = Bosh::Stemcell::StageRunner.new(
build_path: environment.build_path,
command_env: environment.command_env,
settings_file: environment.settings_path,
work_path: environment.work_path,
)

stemcell_building_stages = Bosh::Stemcell::StageCollection.new(definition)

builder = Bosh::Stemcell::StemcellBuilder.new(
environment: environment,
runner: runner,
definition: definition,
collection: stemcell_building_stages
)

packager = Bosh::Stemcell::StemcellPackager.new(
definition: definition,
version: environment.version,
work_path: environment.work_path,
tarball_path: environment.stemcell_tarball_path,
disk_size: environment.stemcell_disk_size,
runner: runner,
collection: stemcell_building_stages,
)

builder.build

mkdir_p('tmp')
definition.disk_formats.each do |disk_format|
puts "Packaging #{disk_format}..."
stemcell_tarball = packager.package(disk_format)
cp(stemcell_tarball, 'tmp')
end

sh(environment.stemcell_rspec_command)
rescue RuntimeError => e
print_help
raise e
require "bosh/stemcell/build_environment"
require "bosh/stemcell/definition"
require "bosh/stemcell/stage_collection"
require "bosh/stemcell/stage_runner"
require "bosh/stemcell/stemcell_packager"
require "bosh/stemcell/stemcell_builder"

args.with_defaults(build_number: "0000")

definition = Bosh::Stemcell::Definition.for(args.infrastructure_name, args.hypervisor_name, args.operating_system_name, args.operating_system_version)
environment = Bosh::Stemcell::BuildEnvironment.new(
ENV.to_hash,
definition,
args.build_number,
args.os_image_path
)

sh(environment.os_image_rspec_command)

puts "Working from #{environment.work_path}..."
puts "########################################"
runner = Bosh::Stemcell::StageRunner.new(
build_path: environment.build_path,
command_env: environment.command_env,
settings_file: environment.settings_path,
work_path: environment.work_path
)

stemcell_building_stages = Bosh::Stemcell::StageCollection.new(definition)

builder = Bosh::Stemcell::StemcellBuilder.new(
environment: environment,
runner: runner,
definition: definition,
collection: stemcell_building_stages
)

packager = Bosh::Stemcell::StemcellPackager.new(
definition: definition,
version: environment.version,
work_path: environment.work_path,
tarball_path: environment.stemcell_tarball_path,
disk_size: environment.stemcell_disk_size,
runner: runner,
collection: stemcell_building_stages
)

builder.build

mkdir_p("tmp")
definition.disk_formats.each do |disk_format|
puts "Packaging #{disk_format}..."
stemcell_tarball = packager.package(disk_format)
cp(stemcell_tarball, "tmp")
end

sh(environment.stemcell_rspec_command)
rescue RuntimeError => e
print_help
raise e
end

def print_help
Expand Down
20 changes: 10 additions & 10 deletions ci/tasks/light-aws/merge-builds
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
# from different regions, by concatenating the 'ami' field in
# the manifest

require 'yaml'
require "yaml"
require "tmpdir"

output_dir=File.expand_path("light-stemcell")
output_dir = File.expand_path("light-stemcell")

merged_amis = {}
merged_amis = {}

def run_command(cmd)
result = `#{cmd}`
`#{cmd}`
if $?.exitstatus > 0
abort("Failed to execute #{cmd}")
end
end

Dir['*-stemcell'].each do | tarball_dir |
next if tarball_dir == 'light-stemcell'
Dir.mktmpdir do | temp_dir |
Dir["*-stemcell"].each do |tarball_dir|
next if tarball_dir == "light-stemcell"
Dir.mktmpdir do |temp_dir|
matches = Dir.glob("#{tarball_dir}/*.tgz")
if matches.length == 0
abort("Empty glob for '#{tarball_dir}/*.tgz'")
Expand All @@ -32,11 +32,11 @@ Dir['*-stemcell'].each do | tarball_dir |
run_command("tar -xvf #{tarball_path} -C #{temp_dir}")

yaml = YAML.load_file("#{temp_dir}/stemcell.MF")
ami = yaml['cloud_properties']['ami']
ami = yaml["cloud_properties"]["ami"]
merged_amis = ami.merge(merged_amis)
yaml['cloud_properties']['ami'] = merged_amis
yaml["cloud_properties"]["ami"] = merged_amis

File.open("#{temp_dir}/stemcell.MF",'w') do |s|
File.open("#{temp_dir}/stemcell.MF", "w") do |s|
s.puts yaml.to_yaml
end

Expand Down
Loading