From 01aa00837fea751bb6a143a88da85fdbd6264149 Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Wed, 12 Jun 2019 15:23:45 +0200 Subject: [PATCH] osbuild: drop state Stages should be as stateless as possible. Don't provide an easy way out of that. Only the dnf stage used stage to save the dnf cache. That's only useful during development and can be solved by pointing to a local repo mirror. --- osbuild | 6 ------ stages/io.weldr.anaconda | 2 +- stages/io.weldr.ansible | 2 +- stages/io.weldr.dnf | 4 +--- stages/io.weldr.locale | 2 +- stages/io.weldr.noop | 2 +- stages/io.weldr.qcow2 | 2 +- stages/io.weldr.remove-uniqueness | 2 +- stages/io.weldr.script | 2 +- stages/io.weldr.systemd | 2 +- 10 files changed, 9 insertions(+), 17 deletions(-) diff --git a/osbuild b/osbuild index 32e5c891..cefdfab4 100755 --- a/osbuild +++ b/osbuild @@ -59,14 +59,9 @@ def main(pipeline_path, from_archive, save, sit): name = stage["name"] options = stage.get("options", {}) options["tree"] = "/tmp/tree" - options["state"] = "/tmp/state" options_str = json.dumps(options, indent=2) - r = subprocess.run(["mkdir", "-p", f"{os.getcwd()}/state/{name}"]) - if r.returncode != 0: - return - print() print(f"{RESET}{BOLD}{i}. {name}{RESET} {options_str}") print("Inspect with:") @@ -81,7 +76,6 @@ def main(pipeline_path, from_archive, save, sit): "--volatile=yes", f"--directory={root}", f"--bind={tree}:/tmp/tree", - f"--bind={os.getcwd()}/state/{name}:/tmp/state", f"--bind={os.getcwd()}/run-stage:/tmp/run-stage", f"--bind={os.getcwd()}/stages/{name}:/tmp/stage", "--bind=/etc/pki", diff --git a/stages/io.weldr.anaconda b/stages/io.weldr.anaconda index 5d6d13d9..00756950 100755 --- a/stages/io.weldr.anaconda +++ b/stages/io.weldr.anaconda @@ -70,7 +70,7 @@ product = """ product_name = Fedora """ -def main(tree, state, kickstart, skip_package_install=False): +def main(tree, kickstart, skip_package_install=False): with open("/tmp/kickstart.ks", "w") as f: if skip_package_install: subprocess.run(["tar", "cvf", "/tmp/empty.tar", "--files-from", "/dev/null"]) diff --git a/stages/io.weldr.ansible b/stages/io.weldr.ansible index 1ea182b4..7007807e 100755 --- a/stages/io.weldr.ansible +++ b/stages/io.weldr.ansible @@ -6,7 +6,7 @@ import subprocess import sys -def main(tree, state, playbook): +def main(tree, playbook): with open("/tmp/inventory", "w") as f: f.write(f"osbuild-tree ansible_connection=chroot ansible_host={tree} ansible_python_interpreter=/usr/bin/python3") diff --git a/stages/io.weldr.dnf b/stages/io.weldr.dnf index 275b3ade..b2c6486a 100755 --- a/stages/io.weldr.dnf +++ b/stages/io.weldr.dnf @@ -7,7 +7,7 @@ import subprocess import sys -def main(tree, state, repos, packages, releasever): +def main(tree, repos, packages, releasever): with open("/tmp/dnf.conf", "w") as conf: p = configparser.ConfigParser() p.read_dict(repos) @@ -30,8 +30,6 @@ def main(tree, state, repos, packages, releasever): "dnf", "-yv", "--installroot", tree, "--setopt", "reposdir=", - "--setopt", f"cachedir={state}/dnf-cache", - "--setopt", "keepcache=True", "--setopt", "install_weak_deps=False", "--releasever", releasever, "--config", "/tmp/dnf.conf", diff --git a/stages/io.weldr.locale b/stages/io.weldr.locale index 2fc6386d..d03f721b 100755 --- a/stages/io.weldr.locale +++ b/stages/io.weldr.locale @@ -3,7 +3,7 @@ import json import sys -def main(tree, state, language, vc_keymap=None): +def main(tree, language, vc_keymap=None): with open(f"{tree}/etc/locale.conf", "w") as f: f.write(f'LANG="{language}"\n') diff --git a/stages/io.weldr.noop b/stages/io.weldr.noop index 45ff696e..52cc6d4e 100755 --- a/stages/io.weldr.noop +++ b/stages/io.weldr.noop @@ -3,7 +3,7 @@ import json import sys -def main(tree, state, **options): +def main(tree, **options): print("Not doing anything with these options:", json.dumps(options)) if __name__ == '__main__': diff --git a/stages/io.weldr.qcow2 b/stages/io.weldr.qcow2 index 795ba541..52ceef2a 100755 --- a/stages/io.weldr.qcow2 +++ b/stages/io.weldr.qcow2 @@ -41,7 +41,7 @@ def loop_device(image): finally: subprocess.run(["losetup", "-d", loop], check=True) -def main(tree, state, target): +def main(tree, target): size = tree_size(tree) with tempfile.TemporaryDirectory(dir=os.getcwd()) as workdir: diff --git a/stages/io.weldr.remove-uniqueness b/stages/io.weldr.remove-uniqueness index a09e1335..f3012f5c 100755 --- a/stages/io.weldr.remove-uniqueness +++ b/stages/io.weldr.remove-uniqueness @@ -5,7 +5,7 @@ import json import os import sys -def main(tree, state): +def main(tree): with contextlib.suppress(FileNotFoundError): os.unlink(f"{tree}/etc/machine-id") os.unlink(f"{tree}/var/lib/systemd/random-seed") diff --git a/stages/io.weldr.script b/stages/io.weldr.script index cdc3d3bf..3dcb374c 100755 --- a/stages/io.weldr.script +++ b/stages/io.weldr.script @@ -7,7 +7,7 @@ import subprocess import sys -def main(tree, state, script): +def main(tree, script): scriptfile = f"{tree}/osbuild-script" with open(scriptfile, "w") as f: diff --git a/stages/io.weldr.systemd b/stages/io.weldr.systemd index 5dfce772..458c8dd6 100755 --- a/stages/io.weldr.systemd +++ b/stages/io.weldr.systemd @@ -4,7 +4,7 @@ import json import os import subprocess -def main(tree, state, enabled_services): +def main(tree, enabled_services): for service in enabled_services: subprocess.run([f"{tree}/usr/bin/systemctl", "--root", tree, "enable", service], check=True)