@@ -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()
@@ -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,
Signed-off-by: Vincent Davis Jr <vince@underview.tech> --- meta/lib/oeqa/selftest/cases/wic.py | 43 ++++++++++++++++++- .../lib/wic/plugins/source/bootimg_pcbios.py | 30 ++++++------- 2 files changed, 54 insertions(+), 19 deletions(-)