diff options
author | John Estabrook <jestabro@vyos.io> | 2023-11-09 14:34:24 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-12-16 20:37:10 -0600 |
commit | a1476c24fb549aaf2702f1c9e2383b3eb90bc6ee (patch) | |
tree | 3c906dadfbfc1c3d3b072cef2140fbc8a903ff9a /python | |
parent | a41d2c01295bed792c376aa817ac06365cc8a7a5 (diff) | |
download | vyos-1x-a1476c24fb549aaf2702f1c9e2383b3eb90bc6ee.tar.gz vyos-1x-a1476c24fb549aaf2702f1c9e2383b3eb90bc6ee.zip |
image: T4516: ensure compatibility with legacy RAID 1 installs
(cherry picked from commit bd701768796d6ebb03ca943faf96d1dbea030edd)
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/system/compat.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/python/vyos/system/compat.py b/python/vyos/system/compat.py index aa9b0b4b5..319c3dabf 100644 --- a/python/vyos/system/compat.py +++ b/python/vyos/system/compat.py @@ -86,6 +86,12 @@ def filter_unparsed(grub_path: str) -> str: return filtered +def get_search_root(unparsed: str) -> str: + unparsed_lines = unparsed.splitlines() + search_root = next((x for x in unparsed_lines if 'search' in x), '') + return search_root + + def sanitize_boot_opts(boot_opts: str) -> str: """Sanitize boot options from console and init @@ -269,18 +275,21 @@ def grub_cfg_fields(root_dir: str = '') -> dict: fields = {'default': 0, 'timeout': 5} # 'default' and 'timeout' from legacy grub.cfg fields |= grub.vars_read(grub_cfg_main) + fields['tools_version'] = SYSTEM_CFG_VER menu_entries = update_version_list(root_dir) fields['versions'] = menu_entries + default = get_default(menu_entries, root_dir) if default is not None: fields['default'] = default - p = Path('/sys/firmware/efi') - if p.is_dir(): - fields['efi'] = True - else: - fields['efi'] = False + modules = grub.modules_read(grub_cfg_main) + fields['modules'] = modules + + unparsed = filter_unparsed(grub_cfg_main).splitlines() + search_root = next((x for x in unparsed if 'search' in x), '') + fields['search_root'] = search_root return fields |