]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
bootimg_pcbios: seperate bootloader config creation
authorVincent Davis Jr <vince@underview.tech>
Thu, 14 Aug 2025 04:25:46 +0000 (00:25 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 14 Aug 2025 09:30:39 +0000 (10:30 +0100)
Most bootloaders that will be included in this
wics plugin will require a configuration file
to define kernel params, execute custom
modules, or enable the ability to select
one of multiple boot entries.

Create a seperate generic function to facilitate
finding if a bootloader config file passed through
bootloader --configfile flag. So, that other functions
that are used to create/install a bootloader boot
configuration file can leverage the function.

Signed-off-by: Vincent Davis Jr. <vince@underview.tech>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/plugins/source/bootimg_pcbios.py

index 9ad301b008c68ee3b5ec9d85c11f56474f4a4663..47fd4b941542dcdd1a0f0c7869b246de12e9b259 100644 (file)
@@ -72,6 +72,22 @@ class BootimgPcbiosPlugin(SourcePlugin):
                                  oe_builddir, bootimg_dir, kernel_dir,
                                  rootfs_dir, native_sysroot)
 
+    @classmethod
+    def _get_bootloader_config(cls, bootloader, loader):
+        custom_cfg = None
+
+        if bootloader.configfile:
+            custom_cfg = get_custom_config(bootloader.configfile)
+            if custom_cfg:
+                logger.debug("Using custom configuration file %s "
+                             "for %s.cfg", bootloader.configfile,
+                             loader)
+                return custom_cfg
+            else:
+                raise WicError("configfile is specified but failed to "
+                               "get it from %s." % bootloader.configfile)
+        return custom_cfg
+
     @classmethod
     def _do_configure_syslinux(cls, part, source_params, creator, cr_workdir,
                                oe_builddir, bootimg_dir, kernel_dir,
@@ -86,20 +102,9 @@ class BootimgPcbiosPlugin(SourcePlugin):
         exec_cmd(install_cmd)
 
         bootloader = creator.ks.bootloader
+        syslinux_conf = cls._get_bootloader_config(bootloader, 'syslinux')
 
-        custom_cfg = None
-        if bootloader.configfile:
-            custom_cfg = get_custom_config(bootloader.configfile)
-            if custom_cfg:
-                # Use a custom configuration for grub
-                syslinux_conf = custom_cfg
-                logger.debug("Using custom configuration file %s "
-                             "for syslinux.cfg", bootloader.configfile)
-            else:
-                raise WicError("configfile is specified but failed to "
-                               "get it from %s." % bootloader.configfile)
-
-        if not custom_cfg:
+        if not syslinux_conf:
             # Create syslinux configuration using parameters from wks file
             splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg")
             if os.path.exists(splash):