src/python/jw/pkg/cmds/CmdDistro: Fix ID regex

The ID regex on /etc/os-release also matches ID_LIKE, which is
obviously nonsense. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-14 20:36:27 +01:00
commit 75041d5505

View file

@ -22,10 +22,10 @@ class CmdDistro(CmdBase): # export
else:
os_release = '/etc/os-release'
with open(os_release, 'r') as file:
matches = re.findall(r'^ID="?([^"]+)"?$', file.read(), re.MULTILINE)
if len(matches) != 1:
m = re.search(r'^\s*ID\s*=\s*("?)([^"\n]+)\1\s*$', file.read(), re.MULTILINE)
if m is None:
raise Exception(f'Could not read "ID=" from "{os_release}"')
self.__id = matches[0]
self.__id = m.group(2)
return self.__id
def add_arguments(self, p: ArgumentParser) -> None: