aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-installer/anaconda/files/0042-support-initramfs-boot.patch
blob: 05743762c11a2d6b593b632d108a5e91e4e31833 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From cedfb60b4cea33edcc6308875a5c8b2aa255bc20 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Sat, 29 Jun 2019 15:46:45 +0800
Subject: [PATCH] support initramfs boot

- Create fake initramfs to cheat grub-mkconfig which
  could generate grub.cfg that have initrd setting.

- Make sure temp dir existed which required by dracut while live install.

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>

Update for anaconda 32:
* refactor code to create fake initrd file
* replace obsolete function util.getSysroot()

Signed-off-by: Kai Kang <kai.kang@windriver.com>

Rebase for anaconda 34.

Signed-off-by: Kai Kang <kai.kang@windriver.com>

Rebase for anaconda 37.
* replace pyanaconda.core.util.mkdirChain with pyanaconda.core.path.make_directories

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 pyanaconda/modules/storage/bootloader/utils.py | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/modules/storage/bootloader/utils.py b/pyanaconda/modules/storage/bootloader/utils.py
index 04b1e5abfd..38fce041a7 100644
--- a/pyanaconda/modules/storage/bootloader/utils.py
+++ b/pyanaconda/modules/storage/bootloader/utils.py
@@ -21,6 +21,7 @@ from glob import glob
 from pyanaconda.modules.common.errors.installation import BootloaderInstallationError
 from pyanaconda.modules.storage.bootloader.image import LinuxBootLoaderImage
 from pyanaconda.core.configuration.anaconda import conf
+from pyanaconda.core.path import make_directories
 from pyanaconda.core.util import execWithRedirect
 from pyanaconda.product import productName
 
@@ -96,7 +97,7 @@ def configure_boot_loader(sysroot, storage, kernel_versions):
         return
 
     # Collect the boot loader images.
-    _collect_os_images(storage, kernel_versions)
+    _collect_os_images(storage, kernel_versions, sysroot)
 
     # Write out /etc/sysconfig/kernel.
     _write_sysconfig_kernel(sysroot, storage)
@@ -113,7 +114,7 @@ def _get_rescue_kernel_versions(sysroot):
     return [f.split("/")[-1][8:] for f in rescue_versions]
 
 
-def _collect_os_images(storage, kernel_versions):
+def _collect_os_images(storage, kernel_versions, sysroot):
     """Collect the OS images for the boot loader.
 
     :param storage: an instance of the storage
@@ -135,6 +136,12 @@ def _collect_os_images(storage, kernel_versions):
     storage.bootloader.add_image(default_image)
     storage.bootloader.default = default_image
 
+    # Create fake initramfs to cheat grub-mkconfig
+    initrd = sysroot + "/boot/initramfs-%s.img" % version
+    if not os.path.exists(initrd):
+        with open(initrd, 'w') as f:
+            f.write('\n')
+
     # now add an image for each of the other kernels
     for version in kernel_versions:
         label = "%s-%s" % (base_label, version)
@@ -145,6 +152,10 @@ def _collect_os_images(storage, kernel_versions):
         )
         storage.bootloader.add_image(image)
 
+        initrd = sysroot + "/boot/initramfs-%s.img" % version
+        if not os.path.exists(initrd):
+            with open(initrd, 'w') as f:
+                f.write('\n')
 
 def _write_sysconfig_kernel(sysroot, storage):
     """Write to /etc/sysconfig/kernel.
@@ -279,6 +290,10 @@ def recreate_initrds(sysroot, kernel_versions):
         log.debug("new-kernel-pkg does not exist, using dracut instead")
         use_dracut = True
 
+    # Make sure temp dir existed, dracut requires it while live install
+    for subdir in ["log", "tmp"]:
+        make_directories(conf.target.system_root + "/var/volatile/%s" % subdir)
+
     for kernel in kernel_versions:
         log.info("Recreating initrd for %s", kernel)
 
-- 
2.7.4