blob: 6fb94ccccac88633a9824ec3df3e524484e36b56 (
plain)
1
2
3
4
5
6
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
|
#!/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)
|