summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-efi.py113
1 files changed, 91 insertions, 22 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index ea94fd2424..855bbc2ce2 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -42,19 +42,10 @@ class BootimgEFIPlugin(SourcePlugin):
42 name = 'bootimg-efi' 42 name = 'bootimg-efi'
43 43
44 @classmethod 44 @classmethod
45 def do_configure_partition(self, source_params, part, cr, cr_workdir, 45 def do_configure_grubefi(self, hdddir, cr, cr_workdir):
46 oe_builddir, bootimg_dir, kernel_dir,
47 native_sysroot):
48 """ 46 """
49 Called before do_prepare_partition(), creates grubefi config 47 Create loader-specific (grub-efi) config
50 """ 48 """
51 hdddir = "%s/hdd/boot" % cr_workdir
52 rm_cmd = "rm -rf %s" % cr_workdir
53 exec_cmd(rm_cmd)
54
55 install_cmd = "install -d %s/EFI/BOOT" % hdddir
56 exec_cmd(install_cmd)
57
58 splash = os.path.join(cr_workdir, "/EFI/boot/splash.jpg") 49 splash = os.path.join(cr_workdir, "/EFI/boot/splash.jpg")
59 if os.path.exists(splash): 50 if os.path.exists(splash):
60 splashline = "menu background splash.jpg" 51 splashline = "menu background splash.jpg"
@@ -73,7 +64,7 @@ class BootimgEFIPlugin(SourcePlugin):
73 grubefi_conf += "timeout=%s\n" % timeout 64 grubefi_conf += "timeout=%s\n" % timeout
74 grubefi_conf += "menuentry 'boot'{\n" 65 grubefi_conf += "menuentry 'boot'{\n"
75 66
76 kernel = "/vmlinuz" 67 kernel = "/bzImage"
77 68
78 if cr._ptable_format == 'msdos': 69 if cr._ptable_format == 'msdos':
79 rootstr = rootdev 70 rootstr = rootdev
@@ -93,6 +84,79 @@ class BootimgEFIPlugin(SourcePlugin):
93 cfg.close() 84 cfg.close()
94 85
95 @classmethod 86 @classmethod
87 def do_configure_gummiboot(self, hdddir, cr, cr_workdir):
88 """
89 Create loader-specific (gummiboot) config
90 """
91 install_cmd = "install -d %s/loader" % hdddir
92 exec_cmd(install_cmd)
93
94 install_cmd = "install -d %s/loader/entries" % hdddir
95 exec_cmd(install_cmd)
96
97 (rootdev, root_part_uuid) = cr._get_boot_config()
98 options = cr.ks.handler.bootloader.appendLine
99
100 timeout = kickstart.get_timeout(cr.ks)
101 if not timeout:
102 timeout = 0
103
104 loader_conf = ""
105 loader_conf += "default boot\n"
106 loader_conf += "timeout %d\n" % timeout
107
108 msger.debug("Writing gummiboot config %s/hdd/boot/loader/loader.conf" \
109 % cr_workdir)
110 cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w")
111 cfg.write(loader_conf)
112 cfg.close()
113
114 kernel = "/bzImage"
115
116 if cr._ptable_format == 'msdos':
117 rootstr = rootdev
118 else:
119 raise ImageError("Unsupported partition table format found")
120
121 boot_conf = ""
122 boot_conf += "title boot\n"
123 boot_conf += "linux %s\n" % kernel
124 boot_conf += "options LABEL=Boot root=%s %s\n" \
125 % (rootstr, options)
126
127 msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \
128 % cr_workdir)
129 cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w")
130 cfg.write(boot_conf)
131 cfg.close()
132
133
134 @classmethod
135 def do_configure_partition(self, part, source_params, cr, cr_workdir,
136 oe_builddir, bootimg_dir, kernel_dir,
137 native_sysroot):
138 """
139 Called before do_prepare_partition(), creates loader-specific config
140 """
141 hdddir = "%s/hdd/boot" % cr_workdir
142 rm_cmd = "rm -rf %s" % cr_workdir
143 exec_cmd(rm_cmd)
144
145 install_cmd = "install -d %s/EFI/BOOT" % hdddir
146 exec_cmd(install_cmd)
147
148 try:
149 if source_params['loader'] == 'grub-efi':
150 self.do_configure_grubefi(hdddir, cr, cr_workdir)
151 elif source_params['loader'] == 'gummiboot':
152 self.do_configure_gummiboot(hdddir, cr, cr_workdir)
153 else:
154 msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
155 except KeyError:
156 msger.error("bootimg-efi requires a loader, none specified")
157
158
159 @classmethod
96 def do_prepare_partition(self, part, source_params, cr, cr_workdir, 160 def do_prepare_partition(self, part, source_params, cr, cr_workdir,
97 oe_builddir, bootimg_dir, kernel_dir, 161 oe_builddir, bootimg_dir, kernel_dir,
98 rootfs_dir, native_sysroot): 162 rootfs_dir, native_sysroot):
@@ -117,14 +181,21 @@ class BootimgEFIPlugin(SourcePlugin):
117 (staging_kernel_dir, hdddir) 181 (staging_kernel_dir, hdddir)
118 exec_cmd(install_cmd) 182 exec_cmd(install_cmd)
119 183
120 shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, 184 try:
121 "%s/grub.cfg" % cr_workdir) 185 if source_params['loader'] == 'grub-efi':
122 186 shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
123 cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir) 187 "%s/grub.cfg" % cr_workdir)
124 exec_cmd(cp_cmd, True) 188 cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir)
125 189 exec_cmd(cp_cmd, True)
126 shutil.move("%s/grub.cfg" % cr_workdir, 190 shutil.move("%s/grub.cfg" % cr_workdir,
127 "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir) 191 "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
192 elif source_params['loader'] == 'gummiboot':
193 cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir)
194 exec_cmd(cp_cmd, True)
195 else:
196 msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
197 except KeyError:
198 msger.error("bootimg-efi requires a loader, none specified")
128 199
129 du_cmd = "du -bks %s" % hdddir 200 du_cmd = "du -bks %s" % hdddir
130 out = exec_cmd(du_cmd) 201 out = exec_cmd(du_cmd)
@@ -164,5 +235,3 @@ class BootimgEFIPlugin(SourcePlugin):
164 235
165 part.set_size(bootimg_size) 236 part.set_size(bootimg_size)
166 part.set_source_file(bootimg) 237 part.set_source_file(bootimg)
167
168