From 8fcf7d5c45c31f81eabe2634dd52dd15c65c290d Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Sun, 22 Dec 2019 16:29:05 +0100 Subject: [PATCH] assembler/qemu: explicit bootloader selection Make the bootloader selection explicit by introducing a new option called `bootloader`, which is an object, containing the `type` and options belonging to the bootloader. For now only boot-loader that is supported is "grub2". --- assemblers/org.osbuild.qemu | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/assemblers/org.osbuild.qemu b/assemblers/org.osbuild.qemu index 2aa653c6..4763fc11 100755 --- a/assemblers/org.osbuild.qemu +++ b/assemblers/org.osbuild.qemu @@ -338,7 +338,7 @@ def partition_table_from_options(options) -> PartitionTable: return PartitionTable(pttype, ptuuid, parts) -def install_grub2(image: str, pt: PartitionTable): +def install_grub2(image: str, pt: PartitionTable, options): """Install grub2 to image""" grub2_core = "/var/tmp/grub2-core.img" @@ -410,6 +410,7 @@ def main(tree, output_dir, options, loop_client): fmt = options["format"] filename = options["filename"] size = options["size"] + bootloader = options.get("bootloader", {"type": "grub2"}) # sfdisk works on sectors of 512 bytes and ignores excess space - be explicit about this if size % 512 != 0: @@ -427,9 +428,9 @@ def main(tree, output_dir, options, loop_client): pt = partition_table_from_options(options) pt.write_to(image) - # Create the level-2 bootloader - if pt.label == "dos": - install_grub2(image, pt) + # Install the bootloader + if bootloader["type"] == "grub2": + install_grub2(image, pt, bootloader) # Now assemble the filesystem hierarchy and copy the tree into the image with contextlib.ExitStack() as cm: