mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 09:35:54 +02:00
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:
parent
2f49bc18d4
commit
75041d5505
1 changed files with 3 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue