debian-forge/runners/org.osbuild.ubuntu1804
Christian Kellner 71adfced70 runners: use osbuild.api.setup_stdio
Each runner used the exact same copy of `setup_stdio`, which is
now provided by `api.setup_stdio`. Use that and remove the code
duplication.
2020-07-27 12:50:38 +01:00

48 lines
1.2 KiB
Python
Executable file

#!/usr/bin/python3
import os
import subprocess
import sys
import osbuild.api
def ldconfig():
# ld.so.conf must exist, or `ldconfig` throws a warning
subprocess.run(["touch", "/etc/ld.so.conf"], check=True)
subprocess.run(["ldconfig"], check=True)
def sysusers():
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)
def tmpfiles():
# 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"], check=False)
def nsswitch():
# the default behavior is fine, but using nss-resolve does not
# necessarily work in a non-booted container, so make sure that
# is not configured.
try:
os.remove("/etc/nsswitch.conf")
except FileNotFoundError:
pass
if __name__ == "__main__":
osbuild.api.setup_stdio()
ldconfig()
sysusers()
tmpfiles()
nsswitch()
r = subprocess.run(sys.argv[1:], check=False)
sys.exit(r.returncode)