osbuild.py: rename run-stage to osbuild-run
Run all programs in the build root through osbuild-run. The things it sets up are probbaly needed by everything.
This commit is contained in:
parent
ce0b01e93d
commit
e6dd428107
3 changed files with 27 additions and 41 deletions
22
osbuild-run
Executable file
22
osbuild-run
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
# ld.so.conf must exist, or `ldconfig` throws a warning
|
||||
subprocess.run(["touch", "/etc/ld.so.conf"], check=True)
|
||||
subprocess.run(["ldconfig"], check=True)
|
||||
|
||||
try:
|
||||
subprocess.run(["systemd-sysusers"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True)
|
||||
except subprocess.CalledProcessError as error:
|
||||
sys.stderr.write(error.stdout)
|
||||
sys.exit(1)
|
||||
|
||||
# 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(sys.argv[1:])
|
||||
sys.exit(r.returncode)
|
||||
10
osbuild.py
10
osbuild.py
|
|
@ -66,9 +66,11 @@ class BuildRoot:
|
|||
"--volatile=yes",
|
||||
f"--machine={self.machine_name}",
|
||||
f"--directory={self.buildroot}",
|
||||
f"--bind={libdir}/osbuild-run:/run/osbuild-run",
|
||||
f"--bind={self.tree}:/tmp/tree",
|
||||
*[f"--bind={src}:{dest}" for src, dest in binds],
|
||||
*[f"--bind-ro={src}:{dest}" for src, dest in readonly_binds]
|
||||
*[f"--bind-ro={src}:{dest}" for src, dest in readonly_binds],
|
||||
"/run/osbuild-run",
|
||||
] + argv, *args, **kwargs)
|
||||
|
||||
def run_stage(self, stage, options={}, input_dir=None):
|
||||
|
|
@ -79,7 +81,6 @@ class BuildRoot:
|
|||
}
|
||||
|
||||
robinds = [
|
||||
(f"{libdir}/run-stage", "/tmp/run-stage"),
|
||||
(f"{libdir}/stages/{stage}", "/tmp/stage"),
|
||||
("/etc/pki", "/etc/pki")
|
||||
]
|
||||
|
|
@ -87,7 +88,7 @@ class BuildRoot:
|
|||
options["input_dir"] = "/tmp/input"
|
||||
robinds.append((input_dir, "/tmp/input"))
|
||||
try:
|
||||
self.run(["/tmp/run-stage", "/tmp/stage"], readonly_binds=robinds,
|
||||
self.run(["/tmp/stage"], readonly_binds=robinds,
|
||||
input=json.dumps(options), encoding="utf-8", check=True)
|
||||
except subprocess.CalledProcessError as error:
|
||||
raise StageFailed(stage, error.returncode)
|
||||
|
|
@ -103,7 +104,6 @@ class BuildRoot:
|
|||
}
|
||||
|
||||
robinds = [
|
||||
(f"{libdir}/run-stage", "/tmp/run-stage"),
|
||||
(f"{libdir}/stages/{name}", "/tmp/stage"),
|
||||
("/etc/pki", "/etc/pki")
|
||||
]
|
||||
|
|
@ -114,7 +114,7 @@ class BuildRoot:
|
|||
binds.append((output_dir, "/tmp/output"))
|
||||
|
||||
try:
|
||||
self.run(["/tmp/run-stage", "/tmp/stage"], binds=binds, readonly_binds=robinds, input=json.dumps(options), encoding="utf-8", check=True)
|
||||
self.run(["/tmp/stage"], binds=binds, readonly_binds=robinds, input=json.dumps(options), encoding="utf-8", check=True)
|
||||
except subprocess.CalledProcessError as error:
|
||||
raise StageFailed(stage, error.returncode)
|
||||
|
||||
|
|
|
|||
36
run-stage
36
run-stage
|
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
RESET = "\033[0m"
|
||||
BOLD = "\033[1m"
|
||||
RED = "\033[31m"
|
||||
|
||||
|
||||
def main(stage):
|
||||
# ld.so.conf must exist, or `ldconfig` throws a warning
|
||||
subprocess.run(["touch", "/etc/ld.so.conf"], check=True)
|
||||
subprocess.run(["ldconfig"], check=True)
|
||||
|
||||
try:
|
||||
subprocess.run(["systemd-sysusers"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True)
|
||||
except subprocess.CalledProcessError as error:
|
||||
sys.stderr.write(error.stdout)
|
||||
return 1
|
||||
|
||||
# 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)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue