mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
Injecting the generated-file warning into the settings dict felt a little unnecessarily magical. A warning like this is always going to be at the top; the way it might differ between files is mainly if the syntax for a comment varies, and in that case a simple substitution like we're doing in this template wouldn't be enough to express the difference anyway. So, embrace the hardcoding. Now, the template and the images.yml entry have a very simple relationship: the keys in one are exactly the keys in the other. That's good for people quickly and confidently understanding it.
26 lines
713 B
Python
Executable File
26 lines
713 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import yaml
|
|
|
|
if __name__ == "__main__":
|
|
os.chdir(os.path.abspath(os.path.dirname(__file__)))
|
|
|
|
with open("Dockerfile.template") as f:
|
|
docker_template = f.read()
|
|
|
|
with open("images.yml") as f:
|
|
dockerfile_settings = yaml.safe_load(f)
|
|
|
|
for distro in dockerfile_settings:
|
|
dockerfile_path = "images/{}/Dockerfile".format(distro)
|
|
os.makedirs(os.path.dirname(dockerfile_path), exist_ok=True)
|
|
with open(dockerfile_path, "w") as f:
|
|
f.write("""\
|
|
# THIS IS A GENERATED FILE. DO NOT EDIT.
|
|
# See template: tools/circleci/Dockerfile.template
|
|
|
|
""")
|
|
f.write(docker_template.format_map(dockerfile_settings[distro]))
|