Don't print systemd-nspawn's messages about starting and stopping containers. Also supress a ldconfig warning and only show output from systemd-sysusers when it fails.
44 lines
1.2 KiB
Python
Executable file
44 lines
1.2 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import argparse
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
RESET = "\033[0m"
|
|
BOLD = "\033[1m"
|
|
RED = "\033[31m"
|
|
|
|
|
|
def main(stage, sit):
|
|
# 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])
|
|
if sit and r.returncode != 0:
|
|
import signal
|
|
print()
|
|
print(f"{RESET}{BOLD}{RED}Stage failed with code {r.returncode}{RESET}")
|
|
print("Keeping the build environment running...")
|
|
signal.pause()
|
|
|
|
return r.returncode
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("stage")
|
|
parser.add_argument("--sit", action="store_true")
|
|
args = parser.parse_args()
|
|
sys.exit(main(**vars(args)))
|