diff options
author | John Estabrook <jestabro@vyos.io> | 2024-01-16 23:52:13 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-16 23:52:13 -0600 |
commit | 31d3d7263ee3082bb7f7dd722086e2ce5c892a03 (patch) | |
tree | 62c525749ed7beb7e89a59a265893edfcb055a11 /python/vyos/system/compat.py | |
parent | 6c39a9cb6df6bb56c02583f82d68edc8ef17241d (diff) | |
parent | 2afd5e5575a42bee4483e093e9611fa3363c8adc (diff) | |
download | vyos-1x-31d3d7263ee3082bb7f7dd722086e2ce5c892a03.tar.gz vyos-1x-31d3d7263ee3082bb7f7dd722086e2ce5c892a03.zip |
Merge pull request #2840 from vyos/mergify/bp/sagitta/pr-2818
image-tools: T5923: update system_console.py for new GRUB file structure (backport #2818)
Diffstat (limited to 'python/vyos/system/compat.py')
-rw-r--r-- | python/vyos/system/compat.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/python/vyos/system/compat.py b/python/vyos/system/compat.py index 319c3dabf..436da14e8 100644 --- a/python/vyos/system/compat.py +++ b/python/vyos/system/compat.py @@ -27,7 +27,7 @@ TMPL_GRUB_COMPAT: str = 'grub/grub_compat.j2' # define regexes and variables REGEX_VERSION = r'^menuentry "[^\n]*{\n[^}]*\s+linux /boot/(?P<version>\S+)/[^}]*}' REGEX_MENUENTRY = r'^menuentry "[^\n]*{\n[^}]*\s+linux /boot/(?P<version>\S+)/vmlinuz (?P<options>[^\n]+)\n[^}]*}' -REGEX_CONSOLE = r'^.*console=(?P<console_type>[^\s\d]+)(?P<console_num>[\d]+).*$' +REGEX_CONSOLE = r'^.*console=(?P<console_type>[^\s\d]+)(?P<console_num>[\d]+)(,(?P<console_speed>[\d]+))?.*$' REGEX_SANIT_CONSOLE = r'\ ?console=[^\s\d]+[\d]+(,\d+)?\ ?' REGEX_SANIT_INIT = r'\ ?init=\S*\ ?' REGEX_SANIT_QUIET = r'\ ?quiet\ ?' @@ -131,6 +131,8 @@ def parse_entry(entry: tuple) -> dict: # find console type and number regex_filter = compile(REGEX_CONSOLE) entry_dict.update(regex_filter.match(entry[1]).groupdict()) + speed = entry_dict.get('console_speed', None) + entry_dict['console_speed'] = speed if speed is not None else '115200' entry_dict['boot_opts'] = sanitize_boot_opts(entry[1]) return entry_dict @@ -271,9 +273,11 @@ def grub_cfg_fields(root_dir: str = '') -> dict: root_dir = disk.find_persistence() grub_cfg_main = f'{root_dir}/{grub.GRUB_CFG_MAIN}' + grub_vars = f'{root_dir}/{grub.CFG_VYOS_VARS}' - fields = {'default': 0, 'timeout': 5} - # 'default' and 'timeout' from legacy grub.cfg + fields = grub.vars_read(grub_vars) + # 'default' and 'timeout' from legacy grub.cfg resets 'default' to + # index, rather than uuid fields |= grub.vars_read(grub_cfg_main) fields['tools_version'] = SYSTEM_CFG_VER |