#!/usr/bin/ruby require "digest/sha1" require "digest" require "getoptlong" require "json" require "socket" require "yaml" def process_yaml(build_basedir, local_build) env_yaml_path = "#{File.dirname($0)}/config.yaml" if ! File.file?(env_yaml_path) STDERR.puts "Unable to find config.yaml. Exiting." exit(1) end tag = "latest" yml = YAML.load_file(env_yaml_path) yml["gentoo_baseimage"] = {} yml["gentoo_baseimage"]["image_name"] = "gentoo_baseimage" yml["gentoo_baseimage"]["container_name"] = "gentoo_baseimage" yml["gentoo_baseimage"]["build_dir"] = "#{build_basedir}/gentoo_baseimage" yml["ansible"] = {} yml["ansible"]["build_dir"] = "#{build_basedir}/ansible" yml["ci"] = {} yml["ci"]["build_dir"] = "#{build_basedir}/ci" yml["ci"]["tag"] = tag yml["ci"]["local_build"] = YAML.load(local_build) yml end def main() build_basedir = nil local_build = "false" opts = GetoptLong.new(["--build-basedir", "-d", GetoptLong::REQUIRED_ARGUMENT], ["--local-build", "-l", GetoptLong::REQUIRED_ARGUMENT]) opts.each do |opt, arg| case opt when "--build-basedir" build_basedir = arg when "--local-build" local_build = arg end end if ! build_basedir raise "--build-basedir must be supplied." end yml = process_yaml(build_basedir, local_build) puts yml.to_json end main() exit(0)