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.
This commit is contained in:
parent
7a866aa1c3
commit
01aa00837f
10 changed files with 9 additions and 17 deletions
6
osbuild
6
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",
|
||||
|
|
|
|||
|
|
@ -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"])
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
||||
|
|
|
|||
|
|
@ -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__':
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue