Check /usr/lib/os-release in addition to /etc/os-release

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-05-06 22:36:43 +02:00
parent aa9fc8646a
commit 253d1f6021

View file

@ -34,8 +34,11 @@ JINJA_ENV = jinja2.Environment(
lstrip_blocks=True) lstrip_blocks=True)
def get_default_target(): def get_default_target():
# TODO: add fallback for /usr/lib/os-release try:
with open("/etc/os-release") as os_release_file: os_release_file = open('/etc/os-release')
except FileNotFoundError:
os_release_file = open('/usr/lib/os-release')
with os_release_file:
conf = configparser.ConfigParser() conf = configparser.ConfigParser()
conf.read_file(itertools.chain(["[os-release]"], os_release_file)) conf.read_file(itertools.chain(["[os-release]"], os_release_file))
os_release = conf["os-release"] os_release = conf["os-release"]