Skip to contentSkip to conversation

scripts: wic plugin bootimg-biosxen drop helper to reuse bootimg_pcbios

PATCH Anibal Limon 2 participants 2 messages Jul 29, 2025 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Bruce,

After all related changes integrated into OE-Core, this patch can be landed now.

Let me know if there is any problem, I tested using xen-image-minimal.

Regards!,
Anibal

Quoted 169 lines · Anibal Limon via lists.yoctoproject.org

- With wic plugins rename on OE-Core now can be imported. See OE-Core revs,

afa1b5c9f6ed17c021e37a54d0d6abee50a60bf9
2de444fc3ef450f45f8f93403544e8f7461657b0
16c8251e5272510ad96613b8c6623550c5a72a34

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

---
 ...{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%)

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +2 -35
similarity index 69%
rename from scripts/lib/wic/plugins/source/bootimg-biosxen.py
rename to scripts/lib/wic/plugins/source/bootimg_biosxen.py
index f3b5540c..e5f545e0 100644
@@ -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

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -6
-        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,

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -3
@@ -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:
scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -3
-            cls.__imgBiosObj.do_configure_partition(part, source_params,
-                                                    creator, cr_workdir,
-                                                    oe_builddir,

bootimg_dir,
- kernel_dir,
native_sysroot)

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +4 -0
+            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,

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -0
@@ -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. """

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -4
-        if not cls.__imgBiosObj:
-            cls.__instanciateBIOSClass()
-
-        bootimg_dir = cls.__imgBiosObj._get_bootimg_dir(bootimg_dir,

'syslinux')

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +1 -0
+        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)

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +5 -6
-        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.39.5

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#9330):
https://lists.yoctoproject.org/g/meta-virtualization/message/9330
Mute This Topic: https://lists.yoctoproject.org/mt/114433805/8181911
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 6 lines · Anibal Limon via lists.yoctoproject.org

Hi Bruce,

After all related changes integrated into OE-Core, this patch can be landed now.

Thanks for watching and sending the update!

I'll test this shortly and I don't expect any issues.

Bruce

Quoted 181 lines

Let me know if there is any problem, I tested using xen-image-minimal.

Regards!,
Anibal

Quoted 156 lines · Anibal Limon via lists.yoctoproject.org

- With wic plugins rename on OE-Core now can be imported. See OE-Core revs,

afa1b5c9f6ed17c021e37a54d0d6abee50a60bf9
2de444fc3ef450f45f8f93403544e8f7461657b0
16c8251e5272510ad96613b8c6623550c5a72a34

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

---
 ...{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%)

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +2 -35
similarity index 69%
rename from scripts/lib/wic/plugins/source/bootimg-biosxen.py
rename to scripts/lib/wic/plugins/source/bootimg_biosxen.py
index f3b5540c..e5f545e0 100644
@@ -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

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -6
-        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,

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -3
@@ -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:
scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -3
-            cls.__imgBiosObj.do_configure_partition(part, source_params,
-                                                    creator, cr_workdir,
-                                                    oe_builddir,

bootimg_dir,
- kernel_dir,
native_sysroot)

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +4 -0
+            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,

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -0
@@ -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. """

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +0 -4
-        if not cls.__imgBiosObj:
-            cls.__instanciateBIOSClass()
-
-        bootimg_dir = cls.__imgBiosObj._get_bootimg_dir(bootimg_dir,

'syslinux')

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +1 -0
+        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)

scripts/lib/wic/plugins/source/bootimg_biosxen.py renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py +5 -6
-        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)
--
Quoted 6 lines

2.39.5

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#9331):
https://lists.yoctoproject.org/g/meta-virtualization/message/9331
Mute This Topic: https://lists.yoctoproject.org/mt/114433805/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II