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

Ed Bartosh ed.bartosh at linux.intel.com
Thu Sep 28 15:47:07 UTC 2017


On Wed, Sep 20, 2017 at 12:03:27PM -0400, Tom Rini wrote:
> 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.

What's wrong with this approach?

I'd be happy to make wic to do only partitioning and assembling the
image and avoiding to modify image content as much as possible.
That would make wic design much more clear and let us to remove
a lot of duplication between wic and meta/classes code.

Regarding boot partition content, I think preparing it from bootfs
directory the same way as it's done for root partition is the way to go.
You can find more details about it here:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=10073

>  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
> 

-- 
--
Regards,
Ed



More information about the Openembedded-core mailing list