[OE-core] [PATCH] wic: Generate startup.nsh for EFI cases if none found

Tom Rini trini at konsulko.com
Wed Sep 20 16:03:27 UTC 2017


In the case of non-wic images there is logic today to generate a
startup.nsh file that will be executed by EFI to run the loader that the
image contains.  In the WIC case is currently depends on that file being
generated elsewhere and placed in DEPLOY_DIR_IMAGE and only used if
present there.  This extends the logic we have today in wic to save the
name of the loader that's being placed and if no startup.nsh is provided
already generate the default kind that grub-efi/systemd-boot.bbclass
generate.

Cc: Ed Bartosh <ed.bartosh at linux.intel.com>
Cc: Christopher Larson <chris_larson at mentor.com>
Signed-off-by: Tom Rini <trini at konsulko.com>
---
 scripts/lib/wic/plugins/source/bootimg-efi.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 4c4f36a32f56..f4643fc233b2 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -204,13 +204,15 @@ class BootimgEFIPlugin(SourcePlugin):
                 shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
                                 "%s/grub.cfg" % cr_workdir)
                 for mod in [x for x in os.listdir(kernel_dir) if x.startswith("grub-efi-")]:
-                    cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[9:])
+                    loader = mod[9:]
+                    cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, loader)
                     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'] == 'systemd-boot':
                 for mod in [x for x in os.listdir(kernel_dir) if x.startswith("systemd-")]:
-                    cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[8:])
+                    loader = mod[8:]
+                    cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, loader)
                     exec_cmd(cp_cmd, True)
             else:
                 raise WicError("unrecognized bootimg-efi loader: %s" %
@@ -222,6 +224,10 @@ class BootimgEFIPlugin(SourcePlugin):
         if os.path.exists(startup):
             cp_cmd = "cp %s %s/" % (startup, hdddir)
             exec_cmd(cp_cmd, True)
+        else:
+            cfg = open("%s/startup.nsh" % hdddir, "w")
+            cfg.write("fs0:EFI\\BOOT\\%s\n" % loader)
+            cfg.close()
 
         du_cmd = "du -bks %s" % hdddir
         out = exec_cmd(du_cmd)
-- 
1.9.1




More information about the Openembedded-core mailing list