meta-virtualization.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* Re: [meta-virtualization] [PATCH] scripts: wic plugin bootimg-biosxen drop helper to reuse bootimg-pcbios
       [not found] <183C6D1717CD05B3.32718@lists.yoctoproject.org>
@ 2025-05-04 20:37 ` Anibal Limon
  2025-05-20  2:52   ` Bruce Ashfield
  0 siblings, 1 reply; 2+ messages in thread
From: Anibal Limon @ 2025-05-04 20:37 UTC (permalink / raw)
  To: anibal; +Cc: meta-virtualization, bruce.ashfield, christopher.clark6

[-- Attachment #1: Type: text/plain, Size: 6831 bytes --]

Hi,

This requires a patch previously sent to OE-Core to allow import wic source
plugins.

https://lists.openembedded.org/g/openembedded-core/message/197471

Regards!,
Anibal

On Sun, May 4, 2025 at 2:32 PM Anibal Limon via lists.yoctoproject.org
<anibal=limonsoftware.com@lists.yoctoproject.org> wrote:

> With wic plugins source rename on OE-Core now can be imported.
>
> Drop the custom helper to find BootimgPcbiosPlugin plus adapt the code
> removing all custom calls and references.
> Finally rename bootimg-biosxen to allow be imported.
>
> Tested with xen-image-minimal and testimage.
>
> Signed-off-by: Anibal Limon <anibal@limonsoftware.com>
> ---
>  ...{bootimg-biosxen.py => bootimg_biosxen.py} | 71 ++++---------------
>  1 file changed, 12 insertions(+), 59 deletions(-)
>  rename scripts/lib/wic/plugins/source/{bootimg-biosxen.py =>
> bootimg_biosxen.py} (69%)
>
> diff --git a/scripts/lib/wic/plugins/source/bootimg-biosxen.py
> b/scripts/lib/wic/plugins/source/bootimg_biosxen.py
> similarity index 69%
> rename from scripts/lib/wic/plugins/source/bootimg-biosxen.py
> rename to scripts/lib/wic/plugins/source/bootimg_biosxen.py
> index f00747db..5242ee4f 100644
> --- a/scripts/lib/wic/plugins/source/bootimg-biosxen.py
> +++ b/scripts/lib/wic/plugins/source/bootimg_biosxen.py
> @@ -34,59 +34,18 @@ import os
>  import types
>
>  from wic import WicError
> -import wic.pluginbase
> -from importlib.machinery import SourceFileLoader
>  from wic.misc import (exec_cmd, get_bitbake_var)
> +from wic.plugins.source.bootimg_pcbios import BootimgPcbiosPlugin
>
>  logger = logging.getLogger('wic')
>
> -class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin):
> +class BootimgBiosXenPlugin(BootimgPcbiosPlugin):
>      """
>      Create MBR boot partition including files for Xen
>
>      """
>
>      name = 'bootimg-biosxen'
> -    __PCBIOS_MODULE_NAME = "bootimg-pcbios"
> -    __imgBiosObj = None
> -
> -    @classmethod
> -    def __init__(cls):
> -        """
> -        Constructor (init)
> -        """
> -        # original comment from bootimg-biosplusefi.py :
> -        # "XXX For some reasons, __init__ constructor is never called.
> -        #  Something to do with how pluginbase works?"
> -        cls.__instanciateBIOSClass()
> -
> -    @classmethod
> -    def __instanciateBIOSClass(cls):
> -        """
> -
> -        """
> -        # Import bootimg-pcbios (class name "BootimgPcbiosPlugin")
> -        modulePath =
> os.path.join(os.path.dirname(wic.pluginbase.__file__),
> -                                  "plugins", "source",
> -                                  cls.__PCBIOS_MODULE_NAME + ".py")
> -        loader = SourceFileLoader(cls.__PCBIOS_MODULE_NAME, modulePath)
> -        mod = types.ModuleType(loader.name)
> -        loader.exec_module(mod)
> -        cls.__imgBiosObj = mod.BootimgPcbiosPlugin()
> -
> -    @classmethod
> -    def do_install_disk(cls, disk, disk_name, creator, workdir,
> oe_builddir,
> -                        bootimg_dir, kernel_dir, native_sysroot):
> -        """
> -        Called after all partitions have been prepared and assembled into
> a
> -        disk image.
> -        """
> -        if not cls.__imgBiosObj:
> -            cls.__instanciateBIOSClass()
> -
> -        cls.__imgBiosObj.do_install_disk(disk, disk_name, creator,
> workdir,
> -                                         oe_builddir, bootimg_dir,
> kernel_dir,
> -                                         native_sysroot)
>
>      @classmethod
>      def do_configure_partition(cls, part, source_params, creator,
> cr_workdir,
> @@ -95,9 +54,6 @@ class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin):
>          """
>          Called before do_prepare_partition(), creates syslinux config
>          """
> -        if not cls.__imgBiosObj:
> -            cls.__instanciateBIOSClass()
> -
>          bootloader = creator.ks.bootloader
>
>          if not bootloader.configfile:
> @@ -158,10 +114,10 @@ class
> BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin):
>              cfg.close()
>
>          else:
> -            cls.__imgBiosObj.do_configure_partition(part, source_params,
> -                                                    creator, cr_workdir,
> -                                                    oe_builddir,
> bootimg_dir,
> -                                                    kernel_dir,
> native_sysroot)
> +            super().do_configure_partition(part, source_params,
> +                                           creator, cr_workdir,
> +                                           oe_builddir, bootimg_dir,
> +                                           kernel_dir, native_sysroot)
>
>      @classmethod
>      def do_prepare_partition(cls, part, source_params, creator,
> cr_workdir,
> @@ -171,10 +127,7 @@ class
> BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin):
>          Called to do the actual content population for a partition i.e. it
>          'prepares' the partition to be incorporated into the image.
>          """
> -        if not cls.__imgBiosObj:
> -            cls.__instanciateBIOSClass()
> -
> -        bootimg_dir = cls.__imgBiosObj._get_bootimg_dir(bootimg_dir,
> 'syslinux')
> +        bootimg_dir = super()._get_bootimg_dir(bootimg_dir, 'syslinux')
>          hdddir = "%s/hdd/boot" % cr_workdir
>
>          # machine-deduction logic originally from isoimage-isohybrid.py
> @@ -205,8 +158,8 @@ class
> BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin):
>          for install_cmd in cmds:
>              exec_cmd(install_cmd)
>
> -        cls.__imgBiosObj.do_prepare_partition(part, source_params,
> -                                              creator, cr_workdir,
> -                                              oe_builddir, bootimg_dir,
> -                                              kernel_dir, rootfs_dir,
> -                                              native_sysroot)
> +        super().do_prepare_partition(part, source_params,
> +                                     creator, cr_workdir,
> +                                     oe_builddir, bootimg_dir,
> +                                     kernel_dir, rootfs_dir,
> +                                     native_sysroot)
> --
> 2.47.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#9240):
> https://lists.yoctoproject.org/g/meta-virtualization/message/9240
> Mute This Topic: https://lists.yoctoproject.org/mt/112618356/8181911
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [
> anibal@limonsoftware.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

[-- Attachment #2: Type: text/html, Size: 9155 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [meta-virtualization] [PATCH] scripts: wic plugin bootimg-biosxen drop helper to reuse bootimg-pcbios
  2025-05-04 20:37 ` [meta-virtualization] [PATCH] scripts: wic plugin bootimg-biosxen drop helper to reuse bootimg-pcbios Anibal Limon
@ 2025-05-20  2:52   ` Bruce Ashfield
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2025-05-20  2:52 UTC (permalink / raw)
  To: Anibal Limon; +Cc: meta-virtualization, christopher.clark6

In message: Re: [meta-virtualization] [PATCH] scripts: wic plugin bootimg-biosxen drop helper to reuse bootimg-pcbios
on 04/05/2025 Anibal Limon wrote:

> Hi,
> 
> This requires a patch previously sent to OE-Core to allow import wic source
> plugins.
> 
> https://lists.openembedded.org/g/openembedded-core/message/197471

It isn't efficient for me to keep checking if this has merged to
oe-core.

Please follow up to your patch once it does merge, and I'll get this
pulled in.

Bruce

> 
> Regards!,
> Anibal
> 
> On Sun, May 4, 2025 at 2:32 PM Anibal Limon via lists.yoctoproject.org <anibal=
> limonsoftware.com@lists.yoctoproject.org> wrote:
> 
>     With wic plugins source rename on OE-Core now can be imported.
> 
>     Drop the custom helper to find BootimgPcbiosPlugin plus adapt the code
>     removing all custom calls and references.
>     Finally rename bootimg-biosxen to allow be imported.
> 
>     Tested with xen-image-minimal and testimage.
> 
>     Signed-off-by: Anibal Limon <anibal@limonsoftware.com>
>     ---
>      ...{bootimg-biosxen.py => bootimg_biosxen.py} | 71 ++++---------------
>      1 file changed, 12 insertions(+), 59 deletions(-)
>      rename scripts/lib/wic/plugins/source/{bootimg-biosxen.py =>
>     bootimg_biosxen.py} (69%)
> 
>     diff --git a/scripts/lib/wic/plugins/source/bootimg-biosxen.py b/scripts/
>     lib/wic/plugins/source/bootimg_biosxen.py
>     similarity index 69%
>     rename from scripts/lib/wic/plugins/source/bootimg-biosxen.py
>     rename to scripts/lib/wic/plugins/source/bootimg_biosxen.py
>     index f00747db..5242ee4f 100644
>     --- a/scripts/lib/wic/plugins/source/bootimg-biosxen.py
>     +++ b/scripts/lib/wic/plugins/source/bootimg_biosxen.py
>     @@ -34,59 +34,18 @@ import os
>      import types
> 
>      from wic import WicError
>     -import wic.pluginbase
>     -from importlib.machinery import SourceFileLoader
>      from wic.misc import (exec_cmd, get_bitbake_var)
>     +from wic.plugins.source.bootimg_pcbios import BootimgPcbiosPlugin
> 
>      logger = logging.getLogger('wic')
> 
>     -class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin):
>     +class BootimgBiosXenPlugin(BootimgPcbiosPlugin):
>          """
>          Create MBR boot partition including files for Xen
> 
>          """
> 
>          name = 'bootimg-biosxen'
>     -    __PCBIOS_MODULE_NAME = "bootimg-pcbios"
>     -    __imgBiosObj = None
>     -
>     -    @classmethod
>     -    def __init__(cls):
>     -        """
>     -        Constructor (init)
>     -        """
>     -        # original comment from bootimg-biosplusefi.py :
>     -        # "XXX For some reasons, __init__ constructor is never called.
>     -        #  Something to do with how pluginbase works?"
>     -        cls.__instanciateBIOSClass()
>     -
>     -    @classmethod
>     -    def __instanciateBIOSClass(cls):
>     -        """
>     -
>     -        """
>     -        # Import bootimg-pcbios (class name "BootimgPcbiosPlugin")
>     -        modulePath = os.path.join(os.path.dirname
>     (wic.pluginbase.__file__),
>     -                                  "plugins", "source",
>     -                                  cls.__PCBIOS_MODULE_NAME + ".py")
>     -        loader = SourceFileLoader(cls.__PCBIOS_MODULE_NAME, modulePath)
>     -        mod = types.ModuleType(loader.name)
>     -        loader.exec_module(mod)
>     -        cls.__imgBiosObj = mod.BootimgPcbiosPlugin()
>     -
>     -    @classmethod
>     -    def do_install_disk(cls, disk, disk_name, creator, workdir,
>     oe_builddir,
>     -                        bootimg_dir, kernel_dir, native_sysroot):
>     -        """
>     -        Called after all partitions have been prepared and assembled into
>     a
>     -        disk image.
>     -        """
>     -        if not cls.__imgBiosObj:
>     -            cls.__instanciateBIOSClass()
>     -
>     -        cls.__imgBiosObj.do_install_disk(disk, disk_name, creator,
>     workdir,
>     -                                         oe_builddir, bootimg_dir,
>     kernel_dir,
>     -                                         native_sysroot)
> 
>          @classmethod
>          def do_configure_partition(cls, part, source_params, creator,
>     cr_workdir,
>     @@ -95,9 +54,6 @@ class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin):
>              """
>              Called before do_prepare_partition(), creates syslinux config
>              """
>     -        if not cls.__imgBiosObj:
>     -            cls.__instanciateBIOSClass()
>     -
>              bootloader = creator.ks.bootloader
> 
>              if not bootloader.configfile:
>     @@ -158,10 +114,10 @@ class BootimgBiosXenPlugin
>     (wic.pluginbase.SourcePlugin):
>                  cfg.close()
> 
>              else:
>     -            cls.__imgBiosObj.do_configure_partition(part, source_params,
>     -                                                    creator, cr_workdir,
>     -                                                    oe_builddir,
>     bootimg_dir,
>     -                                                    kernel_dir,
>     native_sysroot)
>     +            super().do_configure_partition(part, source_params,
>     +                                           creator, cr_workdir,
>     +                                           oe_builddir, bootimg_dir,
>     +                                           kernel_dir, native_sysroot)
> 
>          @classmethod
>          def do_prepare_partition(cls, part, source_params, creator,
>     cr_workdir,
>     @@ -171,10 +127,7 @@ class BootimgBiosXenPlugin
>     (wic.pluginbase.SourcePlugin):
>              Called to do the actual content population for a partition i.e. it
>              'prepares' the partition to be incorporated into the image.
>              """
>     -        if not cls.__imgBiosObj:
>     -            cls.__instanciateBIOSClass()
>     -
>     -        bootimg_dir = cls.__imgBiosObj._get_bootimg_dir(bootimg_dir,
>     'syslinux')
>     +        bootimg_dir = super()._get_bootimg_dir(bootimg_dir, 'syslinux')
>              hdddir = "%s/hdd/boot" % cr_workdir
> 
>              # machine-deduction logic originally from isoimage-isohybrid.py
>     @@ -205,8 +158,8 @@ class BootimgBiosXenPlugin
>     (wic.pluginbase.SourcePlugin):
>              for install_cmd in cmds:
>                  exec_cmd(install_cmd)
> 
>     -        cls.__imgBiosObj.do_prepare_partition(part, source_params,
>     -                                              creator, cr_workdir,
>     -                                              oe_builddir, bootimg_dir,
>     -                                              kernel_dir, rootfs_dir,
>     -                                              native_sysroot)
>     +        super().do_prepare_partition(part, source_params,
>     +                                     creator, cr_workdir,
>     +                                     oe_builddir, bootimg_dir,
>     +                                     kernel_dir, rootfs_dir,
>     +                                     native_sysroot)
>     --
>     2.47.2
> 
> 
>     -=-=-=-=-=-=-=-=-=-=-=-
>     Links: You receive all messages sent to this group.
>     View/Reply Online (#9240): https://lists.yoctoproject.org/g/
>     meta-virtualization/message/9240
>     Mute This Topic: https://lists.yoctoproject.org/mt/112618356/8181911
>     Group Owner: meta-virtualization+owner@lists.yoctoproject.org
>     Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [
>     anibal@limonsoftware.com]
>     -=-=-=-=-=-=-=-=-=-=-=-
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-20  2:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <183C6D1717CD05B3.32718@lists.yoctoproject.org>
2025-05-04 20:37 ` [meta-virtualization] [PATCH] scripts: wic plugin bootimg-biosxen drop helper to reuse bootimg-pcbios Anibal Limon
2025-05-20  2:52   ` Bruce Ashfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).