osbuild: run further setup in build environment

Introduce `run-stage` script, which sets up the build environment before
running the stage. Run `ldconfig`, `systemd-sysusers`, and
`systemd-tmpfiles` in it.
This commit is contained in:
Lars Karlitski 2019-06-07 21:33:31 +02:00
parent 256bb718ee
commit 5e7a111120
3 changed files with 26 additions and 8 deletions

View file

@ -81,9 +81,10 @@ def main(pipeline_path, from_archive, save):
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",
"/tmp/stage"],
"/tmp/run-stage", "/tmp/stage"],
input=options_str, encoding="utf-8", check=True)
except KeyboardInterrupt:
print()

24
run-stage Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/python3
import argparse
import subprocess
import sys
def main(stage):
subprocess.run(["ldconfig"], check=True)
subprocess.run(["systemd-sysusers"], check=True)
# Allow systemd-tmpfiles to return non-0. Some packages want to create
# directories owned by users that are not set up with systemd-sysusers.
subprocess.run(["systemd-tmpfiles", "--create"])
r = subprocess.run([stage])
return r.returncode
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("stage")
args = parser.parse_args()
sys.exit(main(**vars(args)))

View file

@ -88,13 +88,6 @@ def main(tree, state, kickstart, skip_package_install=False):
with open("/etc/anaconda/product.d/fedora.conf", "w") as f:
f.write(product)
subprocess.run(["ldconfig"], check=True)
subprocess.run(["systemd-sysusers"], check=True)
# Allow systemd-tmpfiles to return non-0. Some packages want to create
# directories owned by users that are not set up with systemd-sysusers.
subprocess.run(["systemd-tmpfiles", "--create"])
cmd = [
"anaconda",
"--cmdline",