Patchwork [5/7] wic: Add gummiboot support to bootimg-efi

login
register
mail settings
Submitter tom.zanussi@linux.intel.com
Date Aug. 12, 2014, 1:35 a.m.
Message ID <b67452f93fa0bb7bde463e2511e78c7859bb4383.1407806939.git.tom.zanussi@linux.intel.com>
Download mbox | patch
Permalink /patch/77925/
State Accepted
Commit 6e328c94ae402bdf6f664f2bbfd79fdfe7661d03
Headers show

Comments

tom.zanussi@linux.intel.com - Aug. 12, 2014, 1:35 a.m.
Add gummiboot support to bootimg-efi, which retains the existing
grub-efi support (though requires an update to the .wks file).

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 scripts/lib/wic/plugins/source/bootimg-efi.py | 113 +++++++++++++++++++++-----
 1 file changed, 91 insertions(+), 22 deletions(-)

Patch

diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index ea94fd2..855bbc2 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):
     name = 'bootimg-efi'
 
     @classmethod
-    def do_configure_partition(self, source_params, part, cr, cr_workdir,
-                               oe_builddir, bootimg_dir, kernel_dir,
-                               native_sysroot):
+    def do_configure_grubefi(self, hdddir, cr, cr_workdir):
         """
-        Called before do_prepare_partition(), creates grubefi config
+        Create loader-specific (grub-efi) config
         """
-        hdddir = "%s/hdd/boot" % cr_workdir
-        rm_cmd = "rm -rf %s" % cr_workdir
-        exec_cmd(rm_cmd)
-
-        install_cmd = "install -d %s/EFI/BOOT" % hdddir
-        exec_cmd(install_cmd)
-
         splash = os.path.join(cr_workdir, "/EFI/boot/splash.jpg")
         if os.path.exists(splash):
             splashline = "menu background splash.jpg"
@@ -73,7 +64,7 @@  class BootimgEFIPlugin(SourcePlugin):
         grubefi_conf += "timeout=%s\n" % timeout
         grubefi_conf += "menuentry 'boot'{\n"
 
-        kernel = "/vmlinuz"
+        kernel = "/bzImage"
 
         if cr._ptable_format == 'msdos':
             rootstr = rootdev
@@ -93,6 +84,79 @@  class BootimgEFIPlugin(SourcePlugin):
         cfg.close()
 
     @classmethod
+    def do_configure_gummiboot(self, hdddir, cr, cr_workdir):
+        """
+        Create loader-specific (gummiboot) config
+        """
+        install_cmd = "install -d %s/loader" % hdddir
+        exec_cmd(install_cmd)
+
+        install_cmd = "install -d %s/loader/entries" % hdddir
+        exec_cmd(install_cmd)
+
+        (rootdev, root_part_uuid) = cr._get_boot_config()
+        options = cr.ks.handler.bootloader.appendLine
+
+        timeout = kickstart.get_timeout(cr.ks)
+        if not timeout:
+            timeout = 0
+
+        loader_conf = ""
+        loader_conf += "default boot\n"
+        loader_conf += "timeout %d\n" % timeout
+
+        msger.debug("Writing gummiboot config %s/hdd/boot/loader/loader.conf" \
+                        % cr_workdir)
+        cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w")
+        cfg.write(loader_conf)
+        cfg.close()
+
+        kernel = "/bzImage"
+
+        if cr._ptable_format == 'msdos':
+            rootstr = rootdev
+        else:
+            raise ImageError("Unsupported partition table format found")
+
+        boot_conf = ""
+        boot_conf += "title boot\n"
+        boot_conf += "linux %s\n" % kernel
+        boot_conf += "options LABEL=Boot root=%s %s\n" \
+            % (rootstr, options)
+
+        msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \
+                        % cr_workdir)
+        cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w")
+        cfg.write(boot_conf)
+        cfg.close()
+
+
+    @classmethod
+    def do_configure_partition(self, part, source_params, cr, cr_workdir,
+                               oe_builddir, bootimg_dir, kernel_dir,
+                               native_sysroot):
+        """
+        Called before do_prepare_partition(), creates loader-specific config
+        """
+        hdddir = "%s/hdd/boot" % cr_workdir
+        rm_cmd = "rm -rf %s" % cr_workdir
+        exec_cmd(rm_cmd)
+
+        install_cmd = "install -d %s/EFI/BOOT" % hdddir
+        exec_cmd(install_cmd)
+
+        try:
+            if source_params['loader'] == 'grub-efi':
+                self.do_configure_grubefi(hdddir, cr, cr_workdir)
+            elif source_params['loader'] == 'gummiboot':
+                self.do_configure_gummiboot(hdddir, cr, cr_workdir)
+            else:
+                msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
+        except KeyError:
+            msger.error("bootimg-efi requires a loader, none specified")
+
+
+    @classmethod
     def do_prepare_partition(self, part, source_params, cr, cr_workdir,
                              oe_builddir, bootimg_dir, kernel_dir,
                              rootfs_dir, native_sysroot):
@@ -117,14 +181,21 @@  class BootimgEFIPlugin(SourcePlugin):
             (staging_kernel_dir, hdddir)
         exec_cmd(install_cmd)
 
-        shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
-                        "%s/grub.cfg" % cr_workdir)
-
-        cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir)
-        exec_cmd(cp_cmd, True)
-
-        shutil.move("%s/grub.cfg" % cr_workdir,
-                    "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
+        try:
+            if source_params['loader'] == 'grub-efi':
+                shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
+                                "%s/grub.cfg" % cr_workdir)
+                cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir)
+                exec_cmd(cp_cmd, True)
+                shutil.move("%s/grub.cfg" % cr_workdir,
+                            "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
+            elif source_params['loader'] == 'gummiboot':
+                cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir)
+                exec_cmd(cp_cmd, True)
+            else:
+                msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
+        except KeyError:
+            msger.error("bootimg-efi requires a loader, none specified")
 
         du_cmd = "du -bks %s" % hdddir
         out = exec_cmd(du_cmd)
@@ -164,5 +235,3 @@  class BootimgEFIPlugin(SourcePlugin):
 
         part.set_size(bootimg_size)
         part.set_source_file(bootimg)
-
-