aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-installer/anaconda/files/0052-invoke-grub-install-to-generate-efi-filesystem.patch
blob: 18d69d79c8a3912ccac966bcd4a322796ec62bf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 62ab9a1219ef8b2e38fb8122c54509f849348380 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 6 Jun 2017 15:40:55 +0800
Subject: [PATCH 52/65] invoke grub-install to generate efi filesystem

Previously, the efi filesystem was from package grub-efi
which generated at build time.

Add a wraper to generate efi filesystem with fs_uuid located.

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 pyanaconda/bootloader.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 71a48de..738527b 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1708,6 +1708,11 @@ class EFIBase(object):
             efi_dir = flags.cmdline.get("force_efi_dir")
         return "efi/EFI/%s" % (efi_dir,)
 
+    @property
+    def config_file(self):
+        """ Full path to configuration file. """
+        return "%s/grub/%s" % (self.config_dir, self._config_file)
+
     def efibootmgr(self, *args, **kwargs):
         if flags.imageInstall or flags.dirInstall:
             log.info("Skipping efibootmgr for image/directory install.")
@@ -1797,6 +1802,23 @@ class EFIBase(object):
             self.remove_efi_boot_target()
         self.add_efi_boot_target()
 
+        with open(util.getSysroot() + "/tmp/grub-mkimage-wrapper.sh", "w") as f:
+            f.write('#!/bin/sh\n')
+            f.write('uuid=`grub-probe  --target=fs_uuid  /boot/efi/`\n')
+            f.write('echo "search.fs_uuid ${uuid} root" > /tmp/load.cfg\n')
+            f.write('echo "grub-mkimage -c /tmp/load.cfg $@ search_fs_uuid"\n')
+            f.write('grub-mkimage -c /tmp/load.cfg $@ search_fs_uuid\n')
+        os.chmod(util.getSysroot() + "/tmp/grub-mkimage-wrapper.sh", 0o755)
+
+        rc = util.execInSysroot("grub-install", ["--removable",
+                                                  "--efi-directory=/boot/efi/",
+                                                  "--boot-directory=%s" % self.config_dir,
+                                                  "--grub-mkimage=/tmp/grub-mkimage-wrapper.sh",
+                                                  "/boot/efi/"
+                                                 ])
+        if rc:
+            raise BootLoaderError("boot loader install failed")
+
 
 class EFIGRUB1(EFIBase, GRUB):
     packages = ["efibootmgr"]
-- 
2.7.4