From b50193f289a87da956dcf3cd6a18c10dcaef60c6 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 10 Jan 2020 14:32:45 +0100 Subject: [PATCH] assemblers/qemu: fix backward compat for grub2 With the introduction of the `bootloader` option, grub2 legacy installation setting changed. Before, grub2 legacy installation was dependent on the partition scheme, i.e. only when dos/mbr layout was used grub2 got installed. After the change the default is to install it unless `bootloader.type" is explicitly set, even if the partition layout is GPT. But a legacy grub2 installation on GPT requires a BIOS boot partition, so the new default is not right for the case of pure (non-hyrid) UEFI images. Therefore revert to the old behavior of only defaulting to grub2 legacy if the option is not explicitly set *and* the partition layout is "dos"/"mbr". Adapt the f30-qcow2-gpt sample, which is non-uefi grub2 legacy but with GPT and a bios boot partition, to explicitly request the grub2 bootloader. --- assemblers/org.osbuild.qemu | 7 ++++++- samples/f30-qcow2-gpt.json | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/assemblers/org.osbuild.qemu b/assemblers/org.osbuild.qemu index 728a6890..ab973c82 100755 --- a/assemblers/org.osbuild.qemu +++ b/assemblers/org.osbuild.qemu @@ -539,7 +539,7 @@ def main(tree, output_dir, options, loop_client): fmt = options["format"] filename = options["filename"] size = options["size"] - bootloader = options.get("bootloader", {"type": "grub2"}) + bootloader = options.get("bootloader", {"type": "none"}) # sfdisk works on sectors of 512 bytes and ignores excess space - be explicit about this if size % 512 != 0: @@ -557,6 +557,11 @@ def main(tree, output_dir, options, loop_client): pt = partition_table_from_options(options) pt.write_to(image) + # For backwards comparability assume that if bootloader is not + # set and partition scheme is dos (MBR) grub2 is being used + if bootloader["type"] == "none" and pt.label == "dos": + bootloader["type"] = "grub2" + # Install the bootloader if bootloader["type"] == "grub2": install_grub2(image, pt, bootloader) diff --git a/samples/f30-qcow2-gpt.json b/samples/f30-qcow2-gpt.json index 92f5c553..89161c78 100644 --- a/samples/f30-qcow2-gpt.json +++ b/samples/f30-qcow2-gpt.json @@ -76,6 +76,7 @@ { "name": "org.osbuild.qemu", "options": { + "bootloader": {"type": "grub2"}, "format": "qcow2", "filename": "base.qcow2", "ptuuid": "29579f67-d390-43e7-bd96-dc8f5461171e",