From 32a38c718384ee186d7e5aa098fb423bcd198d92 Mon Sep 17 00:00:00 2001 From: WillyPillow Date: Sun, 30 Aug 2020 01:58:25 +0800 Subject: [PATCH] qvm-template: Eliminate use of lsb_release --- qubesadmin/tools/qvm_template.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qubesadmin/tools/qvm_template.py b/qubesadmin/tools/qvm_template.py index db04dff..3c5421c 100644 --- a/qubesadmin/tools/qvm_template.py +++ b/qubesadmin/tools/qvm_template.py @@ -41,8 +41,16 @@ def qubes_release() -> str: with open('/usr/share/qubes/marker-vm', 'r') as fd: # Get last line (in the format `x.x`) return fd.readlines()[-1].strip() - return subprocess.check_output(['lsb_release', '-sr'], - encoding='UTF-8').strip() + with open('/etc/os-release', 'r') as fd: + for line in fd: + line = line.strip() + if not line or line[0] == '#': + continue + key, val = line.split('=', 1) + if key != 'VERSION_ID': + continue + val = val.strip('\'"') # strip possible quotes + return val def parser_gen() -> argparse.ArgumentParser: """Generate argument parser for the application."""