wic/bootimg-efi: allow multiple initrd

Submitted by chee.yang.lee@intel.com on June 13, 2019, 6:21 a.m. | Patch ID: 162170

Details

Message ID 1560406896-37282-1-git-send-email-chee.yang.lee@intel.com
State Superseded
Commit 21386ce48c79aa590d65f34fb21c99bd166bc009
Headers show

Commit Message

chee.yang.lee@intel.com June 13, 2019, 6:21 a.m.
From: Chee Yang Lee <chee.yang.lee@intel.com>

Allow plugin bootimg-efi to configure with multiple initrd
through source parameter.

Uses ; to separate each initrd.

e.g:
--sourceparams="loader=${EFI_PROVIDER},initrd=initrd1;initrd2"

Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
---
 scripts/lib/wic/plugins/source/bootimg-efi.py | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index d87db1f..f3440fb 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -55,8 +55,10 @@  class BootimgEFIPlugin(SourcePlugin):
             if not bootimg_dir:
                 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
 
-            cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir)
-            exec_cmd(cp_cmd, True)
+            initrds = initrd.split(';')
+            for rd in initrds:
+                cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir)
+                exec_cmd(cp_cmd, True)
         else:
             logger.debug("Ignoring missing initrd")
 
@@ -83,8 +85,11 @@  class BootimgEFIPlugin(SourcePlugin):
             grubefi_conf += "linux /%s %s rootwait %s\n" \
                 % (kernel, label_conf, bootloader.append)
 
-            if initrd:
-               grubefi_conf += "initrd /%s\n" % initrd
+            if initrds:
+                grubefi_conf += "initrd"
+                for rd in initrds:
+                    grubefi_conf += " /%s" % rd
+                grubefi_conf += "\n"
 
             grubefi_conf += "}\n"
 
@@ -119,8 +124,10 @@  class BootimgEFIPlugin(SourcePlugin):
             if not bootimg_dir:
                 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
 
-            cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir)
-            exec_cmd(cp_cmd, True)
+            initrds = initrd.split(';')
+            for rd in initrds:
+                cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir)
+                exec_cmd(cp_cmd, True)
         else:
             logger.debug("Ignoring missing initrd")
 
@@ -163,8 +170,9 @@  class BootimgEFIPlugin(SourcePlugin):
             boot_conf += "options %s %s\n" % \
                              (label_conf, bootloader.append)
 
-            if initrd:
-                boot_conf += "initrd /%s\n" % initrd
+            if initrds:
+                for rd in initrds:
+                    boot_conf += "initrd /%s\n" % rd
 
         logger.debug("Writing systemd-boot config "
                      "%s/hdd/boot/loader/entries/boot.conf", cr_workdir)

Comments

Richard Purdie June 17, 2019, 8:37 p.m.
On Thu, 2019-06-13 at 14:21 +0800, chee.yang.lee@intel.com wrote:
> From: Chee Yang Lee <chee.yang.lee@intel.com>
> 
> Allow plugin bootimg-efi to configure with multiple initrd
> through source parameter.
> 
> Uses ; to separate each initrd.
> 
> e.g:
> --sourceparams="loader=${EFI_PROVIDER},initrd=initrd1;initrd2"
> 
> Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
> ---
>  scripts/lib/wic/plugins/source/bootimg-efi.py | 24 ++++++++++++++++-
> -------
>  1 file changed, 16 insertions(+), 8 deletions(-)


How was this tested? It broke the autobuilder build:

| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_image_wic
| INFO: Creating image(s)...
| 
| Traceback (most recent call last):
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/wic", line 525, in <module>
|     sys.exit(main(sys.argv[1:]))
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/wic", line 520, in main
|     return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/help.py", line 83, in invoke_subcommand
|     subcmd[0](args, usage)
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/wic", line 220, in wic_create_subcommand
|     native_sysroot, options)
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/engine.py", line 189, in wic_create
|     plugin.do_create()
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/imager/direct.py", line 86, in do_create
|     self.create()
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/imager/direct.py", line 196, in create
|     self._image.prepare(self)
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/imager/direct.py", line 362, in prepare
|     imager.kernel_dir, imager.native_sysroot)
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/partition.py", line 167, in prepare
|     kernel_dir, native_sysroot)
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/source/bootimg-efi.py", line 198, in do_configure_partition
|     cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params)
|   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/source/bootimg-efi.py", line 88, in do_configure_grubefi
|     if initrds:
| UnboundLocalError: local variable 'initrds' referenced before assignment
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_image_wic (log file is located at /home/pokybuild/yocto-worker/genericx86/build/build/tmp/work/genericx86-poky-linux/core-image-minimal-initramfs/1.0-r0/temp/log.do_image_wic.23700)


https://autobuilder.yoctoproject.org/typhoon/#/builders/48/builds/712
https://autobuilder.yoctoproject.org/typhoon/#/builders/37/builds/717
https://autobuilder.yoctoproject.org/typhoon/#/builders/43/builds/712
https://autobuilder.yoctoproject.org/typhoon/#/builders/49/builds/711
https://autobuilder.yoctoproject.org/typhoon/#/builders/58/builds/699

wic selftests don't even work:
https://autobuilder.yoctoproject.org/typhoon/#/builders/56/builds/526


Richard
chee.yang.lee@intel.com June 18, 2019, 12:06 p.m.
My bad, I should test it with complete oe-selftest wic module.

´╗┐On 6/18/19, 4:37 AM, "Richard Purdie" <richard.purdie@linuxfoundation.org> wrote:

    On Thu, 2019-06-13 at 14:21 +0800, chee.yang.lee@intel.com wrote:
    > From: Chee Yang Lee <chee.yang.lee@intel.com>

    > 

    > Allow plugin bootimg-efi to configure with multiple initrd

    > through source parameter.

    > 

    > Uses ; to separate each initrd.

    > 

    > e.g:

    > --sourceparams="loader=${EFI_PROVIDER},initrd=initrd1;initrd2"

    > 

    > Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>

    > ---

    >  scripts/lib/wic/plugins/source/bootimg-efi.py | 24 ++++++++++++++++-

    > -------

    >  1 file changed, 16 insertions(+), 8 deletions(-)

    
    
    How was this tested? It broke the autobuilder build:
    
    | DEBUG: Python function extend_recipe_sysroot finished
    | DEBUG: Executing shell function do_image_wic
    | INFO: Creating image(s)...
    | 
    | Traceback (most recent call last):
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/wic", line 525, in <module>
    |     sys.exit(main(sys.argv[1:]))
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/wic", line 520, in main
    |     return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands)
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/help.py", line 83, in invoke_subcommand
    |     subcmd[0](args, usage)
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/wic", line 220, in wic_create_subcommand
    |     native_sysroot, options)
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/engine.py", line 189, in wic_create
    |     plugin.do_create()
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/imager/direct.py", line 86, in do_create
    |     self.create()
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/imager/direct.py", line 196, in create
    |     self._image.prepare(self)
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/imager/direct.py", line 362, in prepare
    |     imager.kernel_dir, imager.native_sysroot)
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/partition.py", line 167, in prepare
    |     kernel_dir, native_sysroot)
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/source/bootimg-efi.py", line 198, in do_configure_partition
    |     cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params)
    |   File "/home/pokybuild/yocto-worker/genericx86/build/scripts/lib/wic/plugins/source/bootimg-efi.py", line 88, in do_configure_grubefi
    |     if initrds:
    | UnboundLocalError: local variable 'initrds' referenced before assignment
    | WARNING: exit code 1 from a shell command.
    | ERROR: Function failed: do_image_wic (log file is located at /home/pokybuild/yocto-worker/genericx86/build/build/tmp/work/genericx86-poky-linux/core-image-minimal-initramfs/1.0-r0/temp/log.do_image_wic.23700)
    
    
    https://autobuilder.yoctoproject.org/typhoon/#/builders/48/builds/712
    https://autobuilder.yoctoproject.org/typhoon/#/builders/37/builds/717
    https://autobuilder.yoctoproject.org/typhoon/#/builders/43/builds/712
    https://autobuilder.yoctoproject.org/typhoon/#/builders/49/builds/711
    https://autobuilder.yoctoproject.org/typhoon/#/builders/58/builds/699
    
    wic selftests don't even work:
    https://autobuilder.yoctoproject.org/typhoon/#/builders/56/builds/526
    
    
    Richard
chee.yang.lee@intel.com June 19, 2019, 6:41 p.m.
This is a system generated Comment: Patch 162170 was automatically marked as superseded by patch 162314.