summaryrefslogtreecommitdiffstats
path: root/src/utils/grub.py
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-22 13:41:45 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-22 16:47:44 +0200
commitfb707cef0b1ebf22b7001613203d58c9e36f951f (patch)
tree455b274efbfcb876abda5c75cf2d22240678e266 /src/utils/grub.py
parent373c1b2a724a3855f93d9cc4b48d0c33310a482c (diff)
grub: move get_grub_boot_params() into grub.py
Move get_grub_boot_params() into the file related to all the grub configuration.
Diffstat (limited to 'src/utils/grub.py')
-rw-r--r--src/utils/grub.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils/grub.py b/src/utils/grub.py
index ca7eb86..4b403db 100644
--- a/src/utils/grub.py
+++ b/src/utils/grub.py
@@ -110,6 +110,24 @@ class MenuEntry:
entry_name = entry_name.replace('!', r'\!')
return entry_name
+
+def get_grub_boot_params(mountpoint, device):
+ grub_conf = f'{mountpoint}/etc/default/grub'
+ res = []
+
+ with open(grub_conf, 'r') as f:
+ for line in f:
+ if line.find('=') == -1:
+ continue
+ key, value = line.split('=', 1)
+ if key == 'GRUB_CMDLINE_LINUX' or key == 'GRUB_CMDLINE_LINUX_DEFAULT':
+ value = value.replace('\n', '')
+ value = value.strip('"')
+ res.append(value)
+ res.append(f'root={device}')
+ return " ".join(res)
+
+
def _get_linux_data(disk_num, part_num, mountpoint):
os_entry = {}
os_entry['name'] = f'{os_probe(mountpoint)} ({disk_num}, {part_num})'