diff options
| author | Anibal Limon <anibal@limonsoftware.com> | 2025-07-29 16:21:47 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2025-07-31 13:34:50 -0400 |
| commit | b66d2ca088cddd6fd3d7cdfe1c7bbe4b420ba53d (patch) | |
| tree | 7a7210f68eb0e05e29cf1baa830fb668d656c472 | |
| parent | 9b034e3defd4aa1108d7a6b4dcca600d4352b132 (diff) | |
| download | meta-virtualization-b66d2ca088cddd6fd3d7cdfe1c7bbe4b420ba53d.tar.gz | |
scripts: wic plugin bootimg-biosxen drop helper to reuse bootimg_pcbios
- 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.
Signed-off-by: Anibal Limon <anibal@limonsoftware.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
| -rw-r--r-- | scripts/lib/wic/plugins/source/bootimg_biosxen.py (renamed from scripts/lib/wic/plugins/source/bootimg-biosxen.py) | 71 |
1 files changed, 12 insertions, 59 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-biosxen.py b/scripts/lib/wic/plugins/source/bootimg_biosxen.py index f3b5540c..e5f545e0 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 | |||
| 34 | import types | 34 | import types |
| 35 | 35 | ||
| 36 | from wic import WicError | 36 | from wic import WicError |
| 37 | import wic.pluginbase | ||
| 38 | from importlib.machinery import SourceFileLoader | ||
| 39 | from wic.misc import (exec_cmd, get_bitbake_var) | 37 | from wic.misc import (exec_cmd, get_bitbake_var) |
| 38 | from wic.plugins.source.bootimg_pcbios import BootimgPcbiosPlugin | ||
| 40 | 39 | ||
| 41 | logger = logging.getLogger('wic') | 40 | logger = logging.getLogger('wic') |
| 42 | 41 | ||
| 43 | class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin): | 42 | class BootimgBiosXenPlugin(BootimgPcbiosPlugin): |
| 44 | """ | 43 | """ |
| 45 | Create MBR boot partition including files for Xen | 44 | Create MBR boot partition including files for Xen |
| 46 | 45 | ||
| 47 | """ | 46 | """ |
| 48 | 47 | ||
| 49 | name = 'bootimg_biosxen' | 48 | name = 'bootimg_biosxen' |
| 50 | __PCBIOS_MODULE_NAME = "bootimg_pcbios" | ||
| 51 | __imgBiosObj = None | ||
| 52 | |||
| 53 | @classmethod | ||
| 54 | def __init__(cls): | ||
| 55 | """ | ||
| 56 | Constructor (init) | ||
| 57 | """ | ||
| 58 | # original comment from bootimg-biosplusefi.py : | ||
| 59 | # "XXX For some reasons, __init__ constructor is never called. | ||
| 60 | # Something to do with how pluginbase works?" | ||
| 61 | cls.__instanciateBIOSClass() | ||
| 62 | |||
| 63 | @classmethod | ||
| 64 | def __instanciateBIOSClass(cls): | ||
| 65 | """ | ||
| 66 | |||
| 67 | """ | ||
| 68 | # Import bootimg-pcbios (class name "BootimgPcbiosPlugin") | ||
| 69 | modulePath = os.path.join(os.path.dirname(wic.pluginbase.__file__), | ||
| 70 | "plugins", "source", | ||
| 71 | cls.__PCBIOS_MODULE_NAME + ".py") | ||
| 72 | loader = SourceFileLoader(cls.__PCBIOS_MODULE_NAME, modulePath) | ||
| 73 | mod = types.ModuleType(loader.name) | ||
| 74 | loader.exec_module(mod) | ||
| 75 | cls.__imgBiosObj = mod.BootimgPcbiosPlugin() | ||
| 76 | |||
| 77 | @classmethod | ||
| 78 | def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, | ||
| 79 | bootimg_dir, kernel_dir, native_sysroot): | ||
| 80 | """ | ||
| 81 | Called after all partitions have been prepared and assembled into a | ||
| 82 | disk image. | ||
| 83 | """ | ||
| 84 | if not cls.__imgBiosObj: | ||
| 85 | cls.__instanciateBIOSClass() | ||
| 86 | |||
| 87 | cls.__imgBiosObj.do_install_disk(disk, disk_name, creator, workdir, | ||
| 88 | oe_builddir, bootimg_dir, kernel_dir, | ||
| 89 | native_sysroot) | ||
| 90 | 49 | ||
| 91 | @classmethod | 50 | @classmethod |
| 92 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, | 51 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, |
| @@ -95,9 +54,6 @@ class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin): | |||
| 95 | """ | 54 | """ |
| 96 | Called before do_prepare_partition(), creates syslinux config | 55 | Called before do_prepare_partition(), creates syslinux config |
| 97 | """ | 56 | """ |
| 98 | if not cls.__imgBiosObj: | ||
| 99 | cls.__instanciateBIOSClass() | ||
| 100 | |||
| 101 | bootloader = creator.ks.bootloader | 57 | bootloader = creator.ks.bootloader |
| 102 | 58 | ||
| 103 | if not bootloader.configfile: | 59 | if not bootloader.configfile: |
| @@ -158,10 +114,10 @@ class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin): | |||
| 158 | cfg.close() | 114 | cfg.close() |
| 159 | 115 | ||
| 160 | else: | 116 | else: |
| 161 | cls.__imgBiosObj.do_configure_partition(part, source_params, | 117 | super().do_configure_partition(part, source_params, |
| 162 | creator, cr_workdir, | 118 | creator, cr_workdir, |
| 163 | oe_builddir, bootimg_dir, | 119 | oe_builddir, bootimg_dir, |
| 164 | kernel_dir, native_sysroot) | 120 | kernel_dir, native_sysroot) |
| 165 | 121 | ||
| 166 | @classmethod | 122 | @classmethod |
| 167 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, | 123 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, |
| @@ -171,10 +127,7 @@ class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin): | |||
| 171 | Called to do the actual content population for a partition i.e. it | 127 | Called to do the actual content population for a partition i.e. it |
| 172 | 'prepares' the partition to be incorporated into the image. | 128 | 'prepares' the partition to be incorporated into the image. |
| 173 | """ | 129 | """ |
| 174 | if not cls.__imgBiosObj: | 130 | bootimg_dir = super()._get_bootimg_dir(bootimg_dir, 'syslinux') |
| 175 | cls.__instanciateBIOSClass() | ||
| 176 | |||
| 177 | bootimg_dir = cls.__imgBiosObj._get_bootimg_dir(bootimg_dir, 'syslinux') | ||
| 178 | hdddir = "%s/hdd/boot" % cr_workdir | 131 | hdddir = "%s/hdd/boot" % cr_workdir |
| 179 | 132 | ||
| 180 | # machine-deduction logic originally from isoimage-isohybrid.py | 133 | # machine-deduction logic originally from isoimage-isohybrid.py |
| @@ -205,8 +158,8 @@ class BootimgBiosXenPlugin(wic.pluginbase.SourcePlugin): | |||
| 205 | for install_cmd in cmds: | 158 | for install_cmd in cmds: |
| 206 | exec_cmd(install_cmd) | 159 | exec_cmd(install_cmd) |
| 207 | 160 | ||
| 208 | cls.__imgBiosObj.do_prepare_partition(part, source_params, | 161 | super().do_prepare_partition(part, source_params, |
| 209 | creator, cr_workdir, | 162 | creator, cr_workdir, |
| 210 | oe_builddir, bootimg_dir, | 163 | oe_builddir, bootimg_dir, |
| 211 | kernel_dir, rootfs_dir, | 164 | kernel_dir, rootfs_dir, |
| 212 | native_sysroot) | 165 | native_sysroot) |
