container: Work in the absence of systemd in PATH, for eg. in Arch

Closes: #2072
This commit is contained in:
Aditya Pratap Singh 2021-03-26 22:49:40 +05:30 committed by Sunil Mohan Adapa
parent 95236bcb78
commit c1f2b32b94

View File

@ -382,8 +382,12 @@ def _verify_dependencies():
def _get_systemd_nspawn_version():
"""Retrieve and store systemd-nspawn version (same as systemd)."""
process = subprocess.run(['systemd', '--version'], stdout=subprocess.PIPE,
check=True)
try:
process = subprocess.run(['systemd', '--version'], stdout=subprocess.PIPE,
check=True)
except FileNotFoundError:
process = subprocess.run(['/usr/lib/systemd/systemd', '--version'], stdout=subprocess.PIPE,
check=True)
global systemd_version
systemd_version = float(process.stdout.decode().split()[1])