forked from crs4/hadoop-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manual_build.py
executable file
·47 lines (36 loc) · 1.13 KB
/
manual_build.py
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
#!/usr/bin/env python3
"""\
Manual image builder for local use. "Official" images are built and
pushed by Travis.
"""
import argparse
import io
import os
import subprocess
import sys
import yaml
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
TRAVIS_FN = os.path.join(THIS_DIR, ".travis.yml")
def get_env_settings():
rval = []
with io.open(TRAVIS_FN, "rt") as f:
data = yaml.safe_load(f)
for d in data["env"]:
env = dict(_.split("=") for _ in d.split())
rval.append(env)
return rval
def build_images(env_list, dry_run=False):
script = os.path.join(THIS_DIR, "build.sh")
for env in env_list:
print(f"* env: {env}")
if dry_run:
continue
subprocess.check_call(f"bash {script}", env=env, shell=True)
def main(args):
env_list = get_env_settings()
build_images(env_list, dry_run=args.dry_run)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--dry-run", action="store_true",
help="show env combos, but don't build anything")
main(parser.parse_args(sys.argv[1:]))