From patchwork Mon Jul 21 01:09:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 67151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E441C83F22 for ; Mon, 21 Jul 2025 01:10:49 +0000 (UTC) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by mx.groups.io with SMTP id smtpd.web10.29978.1753060244536285953 for ; Sun, 20 Jul 2025 18:10:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=UtfbWBzT; spf=pass (domain: underview.tech, ip: 209.85.160.170, mailfrom: vince@underview.tech) Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-4ab60e97cf8so52115801cf.0 for ; Sun, 20 Jul 2025 18:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753060243; x=1753665043; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wePrwbWpDe/3VHFKUy9ZVcNKoCPFegsrOKZJh1k1xgI=; b=UtfbWBzTN0IPif/bElHHIsFBjumMmtXzU4MPAk9GQUz7vp6FgPT380wApMKBkiwgai z0qmZGDPc7qIi92vnSgC/YuxcC7pbDQ377hEsjj3gWKnn9HEbXk6BfqBZstAdFU+84uC DNZ96unICy6aPXEXH4fqQ+XVeTdcBuXdARVHCzddL8gdmDzwfbiPtuPyrQJBenchDpzj UfqppI2fi/GIspLx083NqTvODjlvhKmARbURJwz1hMc6+xXiV1zc0aNyjAzz/n12ytYm uUQpv7VO1Jrze+RNMsHP3bWCPwDis18Vm3PcXEY0KzV2n5wsJ1GAodB2U54r4NN1swYR PwLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753060243; x=1753665043; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wePrwbWpDe/3VHFKUy9ZVcNKoCPFegsrOKZJh1k1xgI=; b=i1a+Yo3ZYTmHVIpiGLEJUy0Mp87R6ilEZzEKO6ZqK0dGzTRSMmYsd0EGmsBFTZD+Qa JwSN6/WNbAChFi+bYWInU/rYH0u5eghGkQVv+Ej2LjzqpEzx42Hljo5fDkzyujVJ3Yrf FQC3leTwSH8IOAMMseMBRTC8iTVjAAbGuuTeFjm3D2aYi3ESW7IFenQZDAgVSuG//hUF nKOiptIlW91TT8jXqW2m+EOC5Yf9zGA8htB3526pRt87tj3jiyfHwo2fXOjbf+i03Hg4 r+gXcW9unL6BxCnSLknkVJK02gXGQDQsU8eCMiAo3AEnOmRUP0PHvgGQtmg/b9CNrYpb gB1A== X-Gm-Message-State: AOJu0YxuaY31KWkFEJyDRi4osdDbkHpUTBGAFw2CBZDRxJsH6PPOT62F jz1EZJGK63HeUiG2WDZ4rCDS+YbiTWvUPoUNyjJ37pzVCiHGldC4BQYIO47boh/utfxbv73XFoe K46/T X-Gm-Gg: ASbGnctwNnAQMk/nQR5D2/AWws9kES/VsSzte+do7+G03xdMXxfrzeWk43CQt4cp4X9 ZBVKVmJCQetAyr8eioUpFx4FQKtYx285DR/Bhf4QoIQQI4Dgc00PUPQ77fCy86PPDbsxPAbu8x/ zHOcjOm2NxZQ2E616x3ZmZwDsVbPEO5smz4fO9ZQ6YBYYzf65MRqIq8AWnjCSZgez//gH1Oop37 GEZBxSwED3zAkuavjM97k4/UYsYS+YCWLZRRQIlue8lJirhm3j2u8vlEO5rdAums55dxg97ubV0 xF9kvv2E1D2hWWm5oyYQ115+D3UzwWFVIyzRXpGlhCiaj74D8drwYsXVq1bNhMGsXAcc1nD+oBh tJiP0dTFXTtw= X-Google-Smtp-Source: AGHT+IFeeRHCIBsEhIphBTLwdVcQZoHxm8C9/nYDDm6TLwwDk7bP7JIgDTqTFEtucNefzd1LSJIiLA== X-Received: by 2002:a05:6214:2124:b0:6fa:fea5:4da0 with SMTP id 6a1803df08f44-704f6a4768dmr338611066d6.10.1753060242699; Sun, 20 Jul 2025 18:10:42 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7051ba9270csm33855256d6.86.2025.07.20.18.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:10:42 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 1/3] bootimg_pcbios: support grub legacy bios boot Date: Sun, 20 Jul 2025 21:09:37 -0400 Message-ID: <20250721010939.3561904-1-vince@underview.tech> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 21 Jul 2025 01:10:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220642 Due to the bootimg_biosplusefi source_params['loader'] had to be named source_params['loader-bios'] so not to create conflict in the wics plugin. Signed-off-by: Vincent Davis Jr --- .../lib/wic/plugins/source/bootimg_pcbios.py | 355 +++++++++++++++--- 1 file changed, 296 insertions(+), 59 deletions(-) diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 21f41e00bb..97687edc71 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, Intel Corporation. +# Copyright (c) 2014-2025, Intel Corporation. # # SPDX-License-Identifier: GPL-2.0-only # @@ -8,12 +8,15 @@ # # AUTHORS # Tom Zanussi +# Vincent Davis # import logging import os import re +import shutil +from glob import glob from wic import WicError from wic.engine import get_custom_config from wic.pluginbase import SourcePlugin @@ -24,11 +27,52 @@ logger = logging.getLogger('wic') class BootimgPcbiosPlugin(SourcePlugin): """ - Create MBR boot partition and install syslinux on it. + Creates boot partition bootable off of legacy BIOS firmare with + MBR/MSDOS as partition table format. Plugin will install caller + selected bootloader directly to resulting wic image. + + Supported Bootloaders: + * syslinux + * grub + + ****************** Wic Plugin Depends/Vars ****************** + WKS_FILE_DEPENDS = "grub-native grub" + WKS_FILE_DEPENDS = "syslinux-native syslinux" + + # Optional variables + GRUB_PREFIX_PATH = '/boot/grub2' # Default: /boot/grub + GRUB_MKIMAGE_FORMAT_PC = 'i386-pc' # Default: i386-pc + + WICVARS:append = "\ + GRUB_PREFIX_PATH \ + GRUB_MKIMAGE_FORMAT_PC \ + " + ****************** Wic Plugin Depends/Vars ****************** + + + **************** Example kickstart Legacy Bios Grub Boot **************** + part boot --label bios_boot --fstype ext4 --offset 1024 --fixed-size 78M + --source bootimg_pcbios --sourceparams="loader-bios=grub" --active + + part roots --label rootfs --fstype ext4 --source rootfs --use-uuid + bootloader --ptable msdos --source bootimg_pcbios + **************** Example kickstart Legacy Bios Grub Boot **************** + + + *************** Example kickstart Legacy Bios Syslinux Boot **************** + part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" + --ondisk sda --label boot --active --align 1024 + + part roots --label rootfs --fstype ext4 --source rootfs --use-uuid + bootloader --ptable msdos --source bootimg_pcbios + *************** Example kickstart Legacy Bios Syslinux Boot **************** """ name = 'bootimg_pcbios' + # Variable required for do_install_disk + loader = '' + @classmethod def _get_bootimg_dir(cls, bootimg_dir, dirname): """ @@ -48,63 +92,73 @@ class BootimgPcbiosPlugin(SourcePlugin): raise WicError("Couldn't find correct bootimg_dir, exiting") @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. In this case, we install the MBR. - """ - bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') - mbrfile = "%s/syslinux/" % bootimg_dir - if creator.ptable_format == 'msdos': - mbrfile += "mbr.bin" - elif creator.ptable_format == 'gpt': - mbrfile += "gptmbr.bin" - else: - raise WicError("Unsupported partition table: %s" % - creator.ptable_format) - - if not os.path.exists(mbrfile): - raise WicError("Couldn't find %s. If using the -e option, do you " - "have the right MACHINE set in local.conf? If not, " - "is the bootimg_dir path correct?" % mbrfile) - - full_path = creator._full_path(workdir, disk_name, "direct") - logger.debug("Installing MBR on disk %s as %s with size %s bytes", - disk_name, full_path, disk.min_size) - - dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) - exec_cmd(dd_cmd, native_sysroot) - - @classmethod - def do_configure_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - native_sysroot): - """ - Called before do_prepare_partition(), creates syslinux config - """ - hdddir = "%s/hdd/boot" % cr_workdir - - install_cmd = "install -d %s" % hdddir - exec_cmd(install_cmd) - + def _get_bootloader_config(cls, creator, loader): + custom_cfg = None bootloader = creator.ks.bootloader - 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) + "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_grub_cfg(cls, creator, cr_workdir): + hdddir = "%s/hdd" % cr_workdir + bootloader = creator.ks.bootloader + + grub_cfg = cls._get_bootloader_config(creator, 'grub') + + grub_prefix_path = get_bitbake_var('GRUB_PREFIX_PATH') + if not grub_prefix_path: + grub_prefix_path = '/boot/grub' + + grub_path = "%s/%s" %(hdddir, grub_prefix_path) + install_cmd = "install -d %s" % grub_path + exec_cmd(install_cmd) + + if not grub_cfg: + grub_conf = 'serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n' + grub_conf += 'set gfxmode=auto\n' + grub_conf += 'set gfxpayload=keep\n\n' + grub_conf += 'set default=0\n\n' + grub_conf += '# Boot automatically after 500 secs.\n' + grub_conf += 'set timeout=500\n\n' + grub_conf += 'menuentry \'rootfs\' {\n' + grub_conf += '\tsearch --no-floppy --set=root --label rootfs\n' + grub_conf += '\tprobe --set partuuid --part-uuid ($root)\n' + + kernel = "/boot/" + get_bitbake_var("KERNEL_IMAGETYPE") + grub_conf += '\tlinux %s root=PARTUUID=$partuuid %s\n}\n' % \ + (kernel, bootloader.append if bootloader.append else '') + + logger.debug("Writing grub config %s/grub.cfg", grub_path) + cfg = open("%s/grub.cfg" % grub_path, "w") + cfg.write(grub_conf) + cfg.close() + else: + logger.debug("Copying grub config to %s/grub.cfg", grub_path) + shutil.copy2(grub_cfg, "%s/grub.cfg" % grub_path) + + @classmethod + def _do_configure_syslinux_cfg(cls, creator, cr_workdir, bootimg_dir): + hdddir = "%s/hdd/boot" % cr_workdir + bootloader = creator.ks.bootloader - if not custom_cfg: + syslinux_cfg = cls._get_bootloader_config(creator, 'syslinux') + + install_cmd = "install -d %s" % hdddir + exec_cmd(install_cmd) + + if not syslinux_cfg: # Create syslinux configuration using parameters from wks file - splash = os.path.join(cr_workdir, "/hdd/boot/splash.jpg") + splash = os.path.join(hdddir, "/splash.jpg") if os.path.exists(splash): splashline = "menu background splash.jpg" else: @@ -128,21 +182,103 @@ class BootimgPcbiosPlugin(SourcePlugin): syslinux_conf += "APPEND label=boot root=%s %s\n" % \ (creator.rootdev, bootloader.append) - logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg", - cr_workdir) - cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w") - cfg.write(syslinux_conf) - cfg.close() + logger.debug("Writing syslinux config %s/syslinux.cfg", hdddir) + cfg = open("%s/syslinux.cfg" % hdddir, "w") + cfg.write(syslinux_conf) + cfg.close() + else: + logger.debug("Copying syslinux config to %s/syslinux.cfg", hdddir) + shutil.copy2(syslinux_cfg, "%s/syslinux.cfg" % hdddir) @classmethod - def do_prepare_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, - rootfs_dir, native_sysroot): + def do_configure_partition(cls, part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): """ - Called to do the actual content population for a partition i.e. it - 'prepares' the partition to be incorporated into the image. - In this case, prepare content for legacy bios boot partition. + Called before do_prepare_partition(), creates syslinux config + """ + + try: + if source_params['loader-bios'] == 'grub': + cls._do_configure_grub_cfg(creator, cr_workdir) + elif source_params['loader-bios'] == 'syslinux': + cls._do_configure_syslinux_cfg(creator, cr_workdir, bootimg_dir) + else: + raise WicError("unrecognized bootimg_pcbios loader: %s" % source_params['loader-bios']) + except KeyError: + raise WicError("bootimg_pcbios requires a loader, none specified") + + @classmethod + def _do_prepare_grub(cls, part, cr_workdir, oe_builddir, + kernel_dir, rootfs_dir, native_sysroot): """ + 1. Generate embed.cfg that'll later be embedded into core.img. + So, that core.img knows where to search for grub.cfg. + 2. Generate core.img or grub stage 1.5. + 3. Copy modules into partition. + 4. Create partition rootfs file. + """ + + hdddir = "%s/hdd" % cr_workdir + + copy_types = [ '*.mod', '*.o', '*.lst' ] + + builtin_modules = 'boot linux ext2 fat serial part_msdos part_gpt \ + normal multiboot probe biosdisk msdospart configfile search loadenv test' + + staging_libdir = get_bitbake_var('STAGING_LIBDIR') + + grub_format = get_bitbake_var('GRUB_MKIMAGE_FORMAT_PC') + if not grub_format: + grub_format = 'i386-pc' + + grub_prefix_path = get_bitbake_var('GRUB_PREFIX_PATH') + if not grub_prefix_path: + grub_prefix_path = '/boot/grub' + + grub_path = "%s/%s" %(hdddir, grub_prefix_path) + core_img = '%s/grub-bios-core.img' % (kernel_dir) + grub_mods_path = '%s/grub/%s' % (staging_libdir, grub_format) + + # Generate embedded grub config + embed_cfg_str = 'search.file %s/grub.cfg root\n' % (grub_prefix_path) + embed_cfg_str += 'set prefix=($root)%s\n' % (grub_prefix_path) + embed_cfg_str += 'configfile ($root)%s/grub.cfg\n' % (grub_prefix_path) + cfg = open('%s/embed.cfg' % (kernel_dir), 'w+') + cfg.write(embed_cfg_str) + cfg.close() + + # core.img doesn't get included into boot partition + # it's later dd onto the resulting wic image. + grub_mkimage = 'grub-mkimage \ + --prefix=%s \ + --format=%s \ + --config=%s/embed.cfg \ + --directory=%s \ + --output=%s %s' % \ + (grub_prefix_path, grub_format, kernel_dir, + grub_mods_path, core_img, builtin_modules) + exec_native_cmd(grub_mkimage, native_sysroot) + + # Copy grub modules + install_dir = '%s/%s/%s' % (hdddir, grub_prefix_path, grub_format) + os.makedirs(install_dir, exist_ok=True) + + for ctype in copy_types: + files = glob('%s/grub/%s/%s' % \ + (staging_libdir, grub_format, ctype)) + for file in files: + shutil.copy2(file, install_dir, follow_symlinks=True) + + # Create boot partition + logger.debug('Prepare partition using rootfs in %s', hdddir) + part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, + native_sysroot, False) + + @classmethod + def _do_prepare_syslinux(cls, part, cr_workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot): + bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') staging_kernel_dir = kernel_dir @@ -207,3 +343,104 @@ class BootimgPcbiosPlugin(SourcePlugin): part.size = int(bootimg_size) part.source_file = bootimg + + @classmethod + def do_prepare_partition(cls, part, source_params, creator, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): + """ + Called to do the actual content population for a partition i.e. it + 'prepares' the partition to be incorporated into the image. + In this case, prepare content for legacy bios boot partition. + """ + + loader = '' + + try: + if source_params['loader-bios'] == 'grub': + cls._do_prepare_grub(part, cr_workdir, oe_builddir, + kernel_dir, rootfs_dir, native_sysroot) + elif source_params['loader-bios'] == 'syslinux': + cls._do_prepare_syslinux(part, cr_workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot) + else: + raise WicError("unrecognized bootimg_pcbios loader: %s" % source_params['loader-bios']) + + loader = source_params['loader-bios'] + except KeyError: + raise WicError("bootimg_pcbios requires a loader, none specified") + + # Required by do_install_disk + cls.loader = loader + + @classmethod + def _do_install_grub(cls, creator, kernel_dir, + native_sysroot, full_path): + core_img = '%s/grub-bios-core.img' % (kernel_dir) + + staging_libdir = get_bitbake_var('STAGING_LIBDIR') + + grub_format = get_bitbake_var('GRUB_MKIMAGE_FORMAT_PC') + if not grub_format: + grub_format = 'i386-pc' + + boot_img = '%s/grub/%s/boot.img' %(staging_libdir, grub_format) + if not os.path.exists(boot_img): + raise WicError("Couldn't find %s. Did you include " + "do_image_wic[depends] += \"grub:do_populate_sysroot\" " + "in your image recipe" % boot_img) + + # Install boot.img or grub stage 1 + dd_cmd = "dd if=%s of=%s conv=notrunc bs=1 seek=0 count=440" % (boot_img, full_path) + exec_cmd(dd_cmd, native_sysroot) + + if creator.ptable_format == 'msdos': + # Install core.img or grub stage 1.5 + dd_cmd = "dd if=%s of=%s conv=notrunc bs=1 seek=512" % (core_img, full_path) + exec_cmd(dd_cmd, native_sysroot) + elif creator.ptable_format == 'gpt': + logger.debug('Update core.img stored on bios boot partition') + else: + raise WicError("Unsupported partition table: %s" % + creator.ptable_format) + + @classmethod + def _do_install_syslinux(cls, creator, bootimg_dir, + native_sysroot, full_path): + + bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux') + + mbrfile = "%s/syslinux/" % bootimg_dir + if creator.ptable_format == 'msdos': + mbrfile += "mbr.bin" + elif creator.ptable_format == 'gpt': + mbrfile += "gptmbr.bin" + else: + raise WicError("Unsupported partition table: %s" % + creator.ptable_format) + + if not os.path.exists(mbrfile): + raise WicError("Couldn't find %s. If using the -e option, do you " + "have the right MACHINE set in local.conf? If not, " + "is the bootimg_dir path correct?" % mbrfile) + + dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) + exec_cmd(dd_cmd, native_sysroot) + + @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. In this case, we install the MBR. + """ + full_path = creator._full_path(workdir, disk_name, "direct") + logger.debug("Installing MBR on disk %s as %s with size %s bytes", + disk_name, full_path, disk.min_size) + + if cls.loader == 'grub': + cls._do_install_grub(creator, kernel_dir, + native_sysroot, full_path) + elif cls.loader == 'syslinux': + cls._do_install_syslinux(creator, bootimg_dir, + native_sysroot, full_path) From patchwork Mon Jul 21 01:09:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 67152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 274A5C83F22 for ; Mon, 21 Jul 2025 01:10:59 +0000 (UTC) Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by mx.groups.io with SMTP id smtpd.web10.29981.1753060256574203563 for ; Sun, 20 Jul 2025 18:10:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=duCdBDcI; spf=pass (domain: underview.tech, ip: 209.85.219.42, mailfrom: vince@underview.tech) Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-6f8aa9e6ffdso40175646d6.3 for ; Sun, 20 Jul 2025 18:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753060255; x=1753665055; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RVyXIqnaRLTKZPu721o7FJUReWE4Ybj0ippXF9PwIqY=; b=duCdBDcIOt4IvcwC/QAieV7rLeuXUuLe9XU90FeDfERRrQzjmXm7H79/FJRbRapwmV F6eEPJN/Vcy3KFw99TgQYTrzwJzPIsS7bIRoJzN4zmyceeMPmWZXc0+pOX5g1pyVtLYc MVs1WPVyDmIMB0i6DDAJ1iw2TyaqW/vQg2hWQWpy8sOUOBzR7iBioL//yy8qisYhAvpD 5ClDtmYKQecvGK2sE184nBO+wAul6786Pw8CVsjw70SvbQcaYe66udEPQwGCwPjggfKc mr6VmUbO/iiaTZziI/EGOaqLvHflr23jzPZobVAHZuAkXMdZGdOk5r+Tzh4z461CSFgH KFXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753060255; x=1753665055; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RVyXIqnaRLTKZPu721o7FJUReWE4Ybj0ippXF9PwIqY=; b=XueFVtEsUEGCwq9AlTQ1nSzng410ph/cqqo3jcFqj4GEIivX7hZCRCuATaTpluUEvq opgdJ7tB8s1zlZk+D7l9sc7TnEIBq4zcXNMzvtJSQlT/7Xtt7VnW8kv18ty1Fr5LOMQQ ACJG5mnOvHY4pxjfRiRAO5X57EC18rS0YeirODNeEIzFRkCXkLp7fdma//jNHZudDnmc s9bQUWraTzN3LJwNesGnfZzC333FKjaERqkI6+Bzt3n5GQ4c/vhFkJBTKrE4zrBZmaB0 m+ejQ8nLIobsZQ6eJKpAVjAAvPkUM8diOaNWq6M6pjsoq9LfjeHR8PhqKHYPa7rj6N7H yA8A== X-Gm-Message-State: AOJu0YyQtgXytfWO7nkhYs58BcqTwmJE7xya17j3q5BPteDOIvpCxgEv wD+wgkg3EAeTmzWEIoBnWoMc85bJkKRTizhU8p4OOY73KtEFL2cKb/WPWvW9bucekmxSypkCM9X H7pf3 X-Gm-Gg: ASbGncvREQMhpWN89LVcyZVRo9MFv086maot7tYl1eOsYxg0/qRWlGP7cYeD55o5ojX Ym6urSY95GA116ntbYaSJ8cPSZYxELm73pwrblSLOomoUsToZ/MXrAkuI51J1vX+RWnLLQbXwUn 0zr/M3ixTT/cC2Wpq6tItNNvesn986g3gf7F//wL1t3VDiR+jxtt5Sl+Z5fIv/DKjOwzBOycsRB 7dXMKs51Wnbl56mVM0XUCjOwcuO4pV9sZkI0Mkgnd3OEp56Di00OJMwYq3Cw4C2xQc3Dv+TbhC4 njb6YzQYW7NGQeSiURmHdrylVY4KUDNCuuKCxvLpc+7lMuqIjznv0a3THNwAvV2FraUuHhkId8T nCztKIBmKgjhdO8ktURCE3A== X-Google-Smtp-Source: AGHT+IFAbFR+p0XH1tMtldbYCf9iw5mL57iDjMnfVDdPKU23zBBLpy1rpC7IIRbC04a3ek3sZosBHw== X-Received: by 2002:a05:6214:33c5:b0:704:a42e:167e with SMTP id 6a1803df08f44-704f4aab794mr266942256d6.28.1753060255155; Sun, 20 Jul 2025 18:10:55 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7051ba9270csm33855256d6.86.2025.07.20.18.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:10:54 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 2/3] wks: add loader-bios to bootimg_pcbios source_params Date: Sun, 20 Jul 2025 21:09:38 -0400 Message-ID: <20250721010939.3561904-2-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721010939.3561904-1-vince@underview.tech> References: <20250721010939.3561904-1-vince@underview.tech> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 21 Jul 2025 01:10:59 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220643 source_params['loader-bios'] is required for newer updates to bootimg_pcbios wics plugin. Signed-off-by: Vincent Davis Jr --- meta-selftest/recipes-test/images/wic-image-minimal.wks | 2 +- meta-selftest/wic/overlayfs_etc.wks.in | 2 +- meta-selftest/wic/test_biosplusefi_plugin.wks | 2 +- meta-selftest/wic/test_rawcopy_plugin.wks.in | 2 +- scripts/lib/wic/canned-wks/common.wks.inc | 2 +- scripts/lib/wic/canned-wks/directdisk-gpt.wks | 2 +- scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks | 2 +- scripts/lib/wic/help.py | 4 ++-- scripts/lib/wic/plugins/source/bootimg_biosplusefi.py | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/meta-selftest/recipes-test/images/wic-image-minimal.wks b/meta-selftest/recipes-test/images/wic-image-minimal.wks index 4186b16517..b0471b59ed 100644 --- a/meta-selftest/recipes-test/images/wic-image-minimal.wks +++ b/meta-selftest/recipes-test/images/wic-image-minimal.wks @@ -2,7 +2,7 @@ # long-description: This image contains boot partition and 3 rootfs partitions # created from core-image-minimal and wic-image-minimal image recipes. -part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 +part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" --ondisk sda --label boot --active --align 1024 part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid part /media --source rootfs --rootfs-dir=wic-image-minimal --ondisk sda --fstype=ext4 --label uuid-test --align 1024 --use-uuid --fsuuid 2c71ef06-a81d-4735-9d3a-379b69c6bdba part /mnt --source rootfs --rootfs-dir=wic-image-minimal --ondisk sda --fstype=ext4 --label core --align 1024 diff --git a/meta-selftest/wic/overlayfs_etc.wks.in b/meta-selftest/wic/overlayfs_etc.wks.in index 8375d73a9c..89f2771e49 100644 --- a/meta-selftest/wic/overlayfs_etc.wks.in +++ b/meta-selftest/wic/overlayfs_etc.wks.in @@ -1,4 +1,4 @@ -part /boot --active --source bootimg_biosplusefi --ondisk sda --sourceparams="loader=grub-efi" --align 1024 +part /boot --active --source bootimg_biosplusefi --ondisk sda --sourceparams="loader=grub-efi,loader-bios=syslinux" --align 1024 part / --source rootfs --ondisk sda --fstype=${OVERLAYFS_ROOTFS_TYPE} --use-uuid --align 1024 part --ondisk sda --fstype=ext4 --size=5 --align 1024 bootloader --ptable gpt --timeout=1 --append="rootfstype=${OVERLAYFS_ROOTFS_TYPE} console=ttyS0,115200 console=tty0 ${OVERLAYFS_INIT_OPTION}" diff --git a/meta-selftest/wic/test_biosplusefi_plugin.wks b/meta-selftest/wic/test_biosplusefi_plugin.wks index 4be6643a6f..ef31ad20c4 100644 --- a/meta-selftest/wic/test_biosplusefi_plugin.wks +++ b/meta-selftest/wic/test_biosplusefi_plugin.wks @@ -1,6 +1,6 @@ # short-description: This file is used in oe-selftest wic module to test biosplusefi plugin -part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi" --active --align 1024 --use-uuid +part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi,loader-bios=syslinux" --active --align 1024 --use-uuid part / --source rootfs --fstype=ext4 --align 1024 --use-uuid bootloader --timeout=0 --append="console=ttyS0,115200n8" diff --git a/meta-selftest/wic/test_rawcopy_plugin.wks.in b/meta-selftest/wic/test_rawcopy_plugin.wks.in index ba324d9980..cb25acf0c6 100644 --- a/meta-selftest/wic/test_rawcopy_plugin.wks.in +++ b/meta-selftest/wic/test_rawcopy_plugin.wks.in @@ -1,6 +1,6 @@ # short-description: This file is used in oe-selftest wic module to test rawcopy plugin -part /boot --active --source bootimg_pcbios +part /boot --active --source bootimg_pcbios --sourceparams="loader-bios=syslinux" part / --source rawcopy --sourceparams="file=${IMAGE_LINK_NAME_CORE_IMAGE_MINIMAL}.ext4" --use-uuid bootloader --timeout=0 --append="console=ttyS0,115200n8" diff --git a/scripts/lib/wic/canned-wks/common.wks.inc b/scripts/lib/wic/canned-wks/common.wks.inc index 4a440ddafe..673bd15725 100644 --- a/scripts/lib/wic/canned-wks/common.wks.inc +++ b/scripts/lib/wic/canned-wks/common.wks.inc @@ -1,3 +1,3 @@ # This file is included into 3 canned wks files from this directory -part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 +part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" --ondisk sda --label boot --active --align 1024 part / --source rootfs --use-uuid --fstype=ext4 --label platform --align 1024 diff --git a/scripts/lib/wic/canned-wks/directdisk-gpt.wks b/scripts/lib/wic/canned-wks/directdisk-gpt.wks index cb640056f1..07040d316c 100644 --- a/scripts/lib/wic/canned-wks/directdisk-gpt.wks +++ b/scripts/lib/wic/canned-wks/directdisk-gpt.wks @@ -3,7 +3,7 @@ # can directly dd to boot media. -part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 +part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" --ondisk sda --label boot --active --align 1024 part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid bootloader --ptable gpt --timeout=0 --append="rootwait rootfstype=ext4 video=vesafb vga=0x318 console=tty0 console=ttyS0,115200n8" diff --git a/scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks b/scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks index 4fd1999ffb..fb51a22283 100644 --- a/scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks +++ b/scripts/lib/wic/canned-wks/directdisk-multi-rootfs.wks @@ -15,7 +15,7 @@ # # - or any combinations of -r and --rootfs command line options -part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 +part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" --ondisk sda --label boot --active --align 1024 part / --source rootfs --rootfs-dir=rootfs1 --ondisk sda --fstype=ext4 --label platform --align 1024 part /rescue --source rootfs --rootfs-dir=rootfs2 --ondisk sda --fstype=ext4 --label secondary --align 1024 diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py index 2e3061f343..5b170594bb 100644 --- a/scripts/lib/wic/help.py +++ b/scripts/lib/wic/help.py @@ -544,7 +544,7 @@ DESCRIPTION the --source param given to that partition. For example, if the partition is set up like this: - part /boot --source bootimg_pcbios ... + part /boot --source bootimg_pcbios --sourceparams="loader-bios=syslinux" ... then the methods defined as class members of the plugin having the matching bootimg_pcbios .name class member would be used. @@ -794,7 +794,7 @@ DESCRIPTION Here is a content of test.wks: - part /boot --source bootimg_pcbios --ondisk sda --label boot --active --align 1024 + part /boot --source bootimg_pcbios --sourceparams="loader-bios=grub" --ondisk sda --label boot --active --align 1024 part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 bootloader --timeout=0 --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0" diff --git a/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py b/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py index 4279ddded8..2687217ad2 100644 --- a/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py +++ b/scripts/lib/wic/plugins/source/bootimg_biosplusefi.py @@ -71,7 +71,7 @@ class BootimgBiosPlusEFIPlugin(SourcePlugin): plugin, as long they does not cause issue in the other plugin. Example wic configuration: - part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi"\\ + part /boot --source bootimg_biosplusefi --sourceparams="loader=grub-efi,loader-bios=syslinux" \\ --ondisk sda --label os_boot --active --align 1024 --use-uuid """ From patchwork Mon Jul 21 01:09:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Davis Jr X-Patchwork-Id: 67153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EE16C83F1A for ; Mon, 21 Jul 2025 01:11:09 +0000 (UTC) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by mx.groups.io with SMTP id smtpd.web10.29983.1753060260556396954 for ; Sun, 20 Jul 2025 18:11:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@underview.tech header.s=google header.b=LF7mya0h; spf=pass (domain: underview.tech, ip: 209.85.222.178, mailfrom: vince@underview.tech) Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7e1f3b95449so474899885a.1 for ; Sun, 20 Jul 2025 18:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=underview.tech; s=google; t=1753060259; x=1753665059; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wpd+nWif2RdQ7M3Cc1jU8ZfzXx4xJSEINEXvyV0nXOg=; b=LF7mya0hhDJWo5hPxehvf+5UlfsmBJZdwO83LB2ZMbW/FQjz4cKqtQnpVUcrNaChbx GX9+d5MVbfEQA7u5bn3jXD4TFwjXfUGKAJsFUjA3tuDT9jQp6f2NUK3ys2g9A1kqzCrZ RCqWPz1/WhCm47tO+QoiNgfin/pQ1KY7Ro8dRsFN+UmJ1HMxsQHzdo3p0nDiBwNng2PG n7KZlHyWTxxXHN+0/TVqhqMRhdOYI4MC5SRVDVQBqpq+HfOiZFSwy6c8E0VME16ibP25 hRCfqj9pY93usbK3VGnYNLe2jESnq9amvH+T5MpBsHmZmNgkBp4iA5g8s7pXlboXvJvj t82Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753060259; x=1753665059; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wpd+nWif2RdQ7M3Cc1jU8ZfzXx4xJSEINEXvyV0nXOg=; b=aLpoXTHschJ67NBpchiC2hpXHbZbRTR7DGD/XxPeMM80SRMM6V4TQtgMhmoLrpV98g gwwhZkWJhXmSoxVffr/MOketvu412UWfox6EuRmdr5td97jti192FgDzZLGo7ubVzaon 8v/DIDVCLVzyQRTEMKjM1asPA92RiagQh7P2Ehrr0r5gzc1PzihdGdpIpQsdSYhmuTBy pLBnWmHk27ZLAsydodamDNFVyNQ9amrA16J2FnCCpV+JHxMROJJyjhUJrGj0ValCsvUl ZvqJNMXRI0kc1dyad/lbUMcvWM7XefIdbl7bl+UCb/e/Czlr7Gl1zq+YC+GCUDeubrX9 Gr7w== X-Gm-Message-State: AOJu0YypAu6dfW2Dhz/pESv7mQW8LtjWZEta2WlV5clyQx2kzms66U+O z0TXr9892bk1OY5VKQfFkISMdAT21yp2ZvG8mJWvOKh+31UHytqJgG2l9aG2ShT1FrJEydSzA+k GyXMS X-Gm-Gg: ASbGnctC2Kt7Q72tmUE/c2t4ROzpqNzjCLuaE+SDkmOMZ/kDgPnl+JwOmdsziQbEnCW QevmKxTm2NvKNSeW8zJnNvv3qox+ab/DUW2AhlaMbGZXMF0zF1KN5cwV9GeyDJPKx0umbe00kbR Fn7gEDhz01OFDwQYn0AP79ceCNMvdSf5T+nKw/xS1oHRab97gFWWQjQ3yP0ZK5k8h2FcGzc+fs6 EBnAQaIjxxcA4z4jLpCTBV4nr6x58xPzlRGHzaApX5jFCs6U5/DMJqfQqXwnkDktUEe8V/1zS0F klYnIe6NBeeJ2Yu/YM2xzeLiSe4f49kdpmxc34SQWNwPHNnL1v74je598+iIur5q3DC0E8HZV0P 7WY7vNVnjU0o= X-Google-Smtp-Source: AGHT+IFyb+jWLCwMXjNN4h43/ppb7tJdA2FzFut4EIiquNqCBNBQpGz09OPFIVZ/ju5ixWJAnUOfRw== X-Received: by 2002:a05:620a:390d:b0:7d9:bde3:79a1 with SMTP id af79cd13be357-7e355548f01mr1604518585a.4.1753060259003; Sun, 20 Jul 2025 18:10:59 -0700 (PDT) Received: from vince-server.. ([2601:406:4d01:1820::b05c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-7051ba9270csm33855256d6.86.2025.07.20.18.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 18:10:58 -0700 (PDT) From: Vincent Davis Jr To: openembedded-core@lists.openembedded.org Cc: Vincent Davis Jr Subject: [PATCH 3/3] oe-selftest: add test_bootimg_pcbios_grub_install Date: Sun, 20 Jul 2025 21:09:39 -0400 Message-ID: <20250721010939.3561904-3-vince@underview.tech> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250721010939.3561904-1-vince@underview.tech> References: <20250721010939.3561904-1-vince@underview.tech> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 21 Jul 2025 01:11:09 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/220644 Signed-off-by: Vincent Davis Jr --- meta/lib/oeqa/selftest/cases/wic.py | 43 ++++++++++++++++++- .../lib/wic/plugins/source/bootimg_pcbios.py | 30 ++++++------- 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 680f99d381..91d9d31da1 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -215,6 +215,47 @@ class Wic(WicTestCase): found, "The kernel image '{}' was not found in the boot partition".format(kimgtype) ) + @skipIfNotArch(['x86_64']) + def test_bootimg_pcbios_grub_install(self): + """ + Test the installation of the grub modules + config + into the boot directory in the wic plugin. + """ + + # create a temporary file for the WKS content + with NamedTemporaryFile("w", suffix=".wks") as wks: + wks.write( + 'part --source bootimg_pcbios --sourceparams="loader-bios=grub" ' + '--offset 1024 --fixed-size 78M --label boot --active\n' + 'bootloader --ptable msdos --source bootimg_pcbios\n' + ) + wks.flush() + # create a temporary directory to extract the disk image to + with TemporaryDirectory() as tmpdir: + img = "core-image-minimal" + config = 'DEPENDS:pn-%s += "grub-native grub"' % (img) + + self.append_config(config) + bitbake(img) + self.remove_config(config) + + cmd = "wic create %s -e %s -o %s" % (wks.name, img, self.resultdir) + runCmd(cmd) + + wksname = os.path.splitext(os.path.basename(wks.name))[0] + out = glob(os.path.join(self.resultdir, "%s-*.direct" % wksname)) + self.assertEqual(1, len(out)) + + sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools') + + # Check if grub.cfg is installed + result = runCmd("wic ls %s:1/boot/grub -n %s" % (out[0], sysroot)) + self.assertIn('grub', result.output) + + # Check if normal.mod is installed + result = runCmd("wic ls %s:1/boot/grub/i386-pc -n %s" % (out[0], sysroot)) + self.assertIn('normal', result.output) + def test_build_image_name(self): """Test wic create wictestdisk --image-name=core-image-minimal""" cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir @@ -1405,7 +1446,7 @@ run_wic_cmd() { img = 'core-image-minimal' with NamedTemporaryFile("w", suffix=".wks") as wks: - wks.writelines(['part /boot --active --source bootimg_biosplusefi --sourceparams="loader=grub-efi"\n', + wks.writelines(['part /boot --active --source bootimg_biosplusefi --sourceparams="loader=grub-efi,loader-bios=syslinux"\n', 'part / --source rootfs --fstype=ext4 --align 1024 --use-uuid\n'\ 'bootloader --timeout=0 --append="console=ttyS0,115200n8"\n']) wks.flush() diff --git a/scripts/lib/wic/plugins/source/bootimg_pcbios.py b/scripts/lib/wic/plugins/source/bootimg_pcbios.py index 97687edc71..2582ce1164 100644 --- a/scripts/lib/wic/plugins/source/bootimg_pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg_pcbios.py @@ -113,7 +113,7 @@ class BootimgPcbiosPlugin(SourcePlugin): hdddir = "%s/hdd" % cr_workdir bootloader = creator.ks.bootloader - grub_cfg = cls._get_bootloader_config(creator, 'grub') + grub_conf = cls._get_bootloader_config(creator, 'grub') grub_prefix_path = get_bitbake_var('GRUB_PREFIX_PATH') if not grub_prefix_path: @@ -123,7 +123,7 @@ class BootimgPcbiosPlugin(SourcePlugin): install_cmd = "install -d %s" % grub_path exec_cmd(install_cmd) - if not grub_cfg: + if not grub_conf: grub_conf = 'serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n' grub_conf += 'set gfxmode=auto\n' grub_conf += 'set gfxpayload=keep\n\n' @@ -138,25 +138,22 @@ class BootimgPcbiosPlugin(SourcePlugin): grub_conf += '\tlinux %s root=PARTUUID=$partuuid %s\n}\n' % \ (kernel, bootloader.append if bootloader.append else '') - logger.debug("Writing grub config %s/grub.cfg", grub_path) - cfg = open("%s/grub.cfg" % grub_path, "w") - cfg.write(grub_conf) - cfg.close() - else: - logger.debug("Copying grub config to %s/grub.cfg", grub_path) - shutil.copy2(grub_cfg, "%s/grub.cfg" % grub_path) + logger.debug("Writing grub config %s/grub.cfg", grub_path) + cfg = open("%s/grub.cfg" % grub_path, "w") + cfg.write(grub_conf) + cfg.close() @classmethod def _do_configure_syslinux_cfg(cls, creator, cr_workdir, bootimg_dir): hdddir = "%s/hdd/boot" % cr_workdir bootloader = creator.ks.bootloader - syslinux_cfg = cls._get_bootloader_config(creator, 'syslinux') + syslinux_conf = cls._get_bootloader_config(creator, 'syslinux') install_cmd = "install -d %s" % hdddir exec_cmd(install_cmd) - if not syslinux_cfg: + if not syslinux_conf: # Create syslinux configuration using parameters from wks file splash = os.path.join(hdddir, "/splash.jpg") if os.path.exists(splash): @@ -182,13 +179,10 @@ class BootimgPcbiosPlugin(SourcePlugin): syslinux_conf += "APPEND label=boot root=%s %s\n" % \ (creator.rootdev, bootloader.append) - logger.debug("Writing syslinux config %s/syslinux.cfg", hdddir) - cfg = open("%s/syslinux.cfg" % hdddir, "w") - cfg.write(syslinux_conf) - cfg.close() - else: - logger.debug("Copying syslinux config to %s/syslinux.cfg", hdddir) - shutil.copy2(syslinux_cfg, "%s/syslinux.cfg" % hdddir) + logger.debug("Writing syslinux config %s/syslinux.cfg", hdddir) + cfg = open("%s/syslinux.cfg" % hdddir, "w") + cfg.write(syslinux_conf) + cfg.close() @classmethod def do_configure_partition(cls, part, source_params, creator, cr_workdir,