zengxyz / rpms / anaconda

Forked from rpms/anaconda 3 months ago
Clone
DistroBaker 73cad9
From 79fa095319696a9e91ab35cc694cdf9919a3428f Mon Sep 17 00:00:00 2001
DistroBaker 73cad9
From: Javier Martinez Canillas <javierm@redhat.com>
DistroBaker 73cad9
Date: Mon, 22 Feb 2021 19:25:01 +0100
DistroBaker 73cad9
Subject: [PATCH] Determine GRUB directory relative path to use in config file
DistroBaker 73cad9
DistroBaker 73cad9
Currently Anaconda is only checking whether /boot/ is a mount point or not
DistroBaker 73cad9
to use the proper relative path to the GRUB directory. But there are more
DistroBaker 73cad9
cases than this, for example /boot/grub2 could be a symlink or a subvolume
DistroBaker 73cad9
in a btrfs filesystem.
DistroBaker 73cad9
DistroBaker 73cad9
Use the grub2-mkrelpath tool to figure out the actual relative path that
DistroBaker 73cad9
has to be used in the GRUB config file.
DistroBaker 73cad9
DistroBaker 73cad9
Resolves: rhbz#1928588
DistroBaker 73cad9
DistroBaker 73cad9
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
DistroBaker 73cad9
---
DistroBaker 73cad9
 pyanaconda/modules/storage/bootloader/efi.py | 7 ++++---
DistroBaker 73cad9
 1 file changed, 4 insertions(+), 3 deletions(-)
DistroBaker 73cad9
DistroBaker 73cad9
diff --git a/pyanaconda/modules/storage/bootloader/efi.py b/pyanaconda/modules/storage/bootloader/efi.py
DistroBaker 73cad9
index 8c08b8c68d..425cb31954 100644
DistroBaker 73cad9
--- a/pyanaconda/modules/storage/bootloader/efi.py
DistroBaker 73cad9
+++ b/pyanaconda/modules/storage/bootloader/efi.py
DistroBaker 73cad9
@@ -173,10 +173,11 @@ class EFIGRUB(EFIBase, GRUB2):
DistroBaker 73cad9
         with open(config_path, "w") as fd:
DistroBaker 73cad9
             grub_dir = self.config_dir
DistroBaker 73cad9
             fs_uuid = self.stage2_device.format.uuid
DistroBaker 73cad9
-            mountpoint = self.stage2_device.format.mountpoint
DistroBaker 73cad9
 
DistroBaker 73cad9
-            if mountpoint != "/" and grub_dir.startswith(mountpoint):
DistroBaker 73cad9
-                grub_dir = grub_dir[len(mountpoint):]
DistroBaker 73cad9
+            grub_dir = util.execWithCapture("grub2-mkrelpath", [grub_dir],
DistroBaker 73cad9
+                                            root=conf.target.system_root)
DistroBaker 73cad9
+            if not grub_dir:
DistroBaker 73cad9
+                raise BootLoaderError("Could not get GRUB directory path")
DistroBaker 73cad9
 
DistroBaker 73cad9
             fd.write("search --no-floppy --fs-uuid --set=dev %s\n" % fs_uuid)
DistroBaker 73cad9
             fd.write("set prefix=($dev)%s\n" % grub_dir)
DistroBaker 73cad9
-- 
DistroBaker 73cad9
2.26.2
DistroBaker 73cad9