osbuild-run: refactor into functions
Prepare for follow-up patches adding more functionality. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
0cf93934eb
commit
9fa827ab04
1 changed files with 31 additions and 18 deletions
49
osbuild-run
49
osbuild-run
|
|
@ -5,25 +5,38 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# ld.so.conf must exist, or `ldconfig` throws a warning
|
def ldconfig():
|
||||||
subprocess.run(["touch", "/etc/ld.so.conf"], check=True)
|
# ld.so.conf must exist, or `ldconfig` throws a warning
|
||||||
subprocess.run(["ldconfig"], check=True)
|
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)
|
|
||||||
|
|
||||||
# generate /etc/pki/tls/certs/ca-bundle.crt
|
def sysusers():
|
||||||
os.makedirs("/etc/pki/ca-trust/extracted/pem")
|
try:
|
||||||
os.makedirs("/etc/pki/tls/certs")
|
subprocess.run(["systemd-sysusers"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True)
|
||||||
os.symlink("/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem", "/etc/pki/tls/certs/ca-bundle.crt")
|
except subprocess.CalledProcessError as error:
|
||||||
subprocess.run(["update-ca-trust"])
|
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:])
|
def update_ca_trust():
|
||||||
sys.exit(r.returncode)
|
# generate /etc/pki/tls/certs/ca-bundle.crt
|
||||||
|
os.makedirs("/etc/pki/ca-trust/extracted/pem")
|
||||||
|
os.makedirs("/etc/pki/tls/certs")
|
||||||
|
os.symlink("/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem", "/etc/pki/tls/certs/ca-bundle.crt")
|
||||||
|
subprocess.run(["update-ca-trust"])
|
||||||
|
|
||||||
|
|
||||||
|
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"])
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
ldconfig()
|
||||||
|
sysusers()
|
||||||
|
update_ca_trust()
|
||||||
|
tmpfiles()
|
||||||
|
|
||||||
|
r = subprocess.run(sys.argv[1:])
|
||||||
|
sys.exit(r.returncode)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue