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.
This commit is contained in:
Christian Kellner 2020-01-10 14:32:45 +01:00 committed by Lars Karlitski
parent 42a4176a9f
commit b50193f289
2 changed files with 7 additions and 1 deletions

View file

@ -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)

View file

@ -76,6 +76,7 @@
{
"name": "org.osbuild.qemu",
"options": {
"bootloader": {"type": "grub2"},
"format": "qcow2",
"filename": "base.qcow2",
"ptuuid": "29579f67-d390-43e7-bd96-dc8f5461171e",