Skip to content

Commit

Permalink
stages/grub2: add new uefi.unified option
Browse files Browse the repository at this point in the history
Fedora 34 and thus RHEL 9 have adopted the unified grub config
scheme[1], where the main config is always placed in the same
location across all platforms, i.e. `boot/grub2`, and a stub
config that redirects to the main config is placed into the ESP.
osbuild has always done that in the case of hybrid boot, but not
for pure EFI systems. The new `uefi.unified` config option can
be used to select that new unified scheme even for the case of
pure EFI systems (aarch64 or non-hybrid boot).

Add a simple test for the grub stage.

[1] https://fedoraproject.org/wiki/Changes/UnifyGrubConfig
  • Loading branch information
gicmo committed Aug 23, 2021
1 parent f3f3904 commit da8f45e
Show file tree
Hide file tree
Showing 6 changed files with 1,444 additions and 3 deletions.
17 changes: 14 additions & 3 deletions stages/org.osbuild.grub2
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ If UEFI support is enabled via `uefi: {"vendor": "<vendor>"}` this stage will
also write the `grub.cfg` to `boot/efi/EFI/<vendor>/grub.cfg`. EFI binaries
and accompanying data can be installed from the built root via `uefi.install`.
Both UEFI and Legacy can be specified at the same time.
Both UEFI and Legacy can be specified at the same time (hybrid boot).
If `uefi.unified` is specified or hybrid boot is enabled, the main grub config
will be written to `boot/grub2/grub.cfg` and a redirect config will be placed
in the EFI directory.
If the `saved_entry` option is present it will result in an entry in the
`grubenv` file of the same name. The grub config file contains logic so
Expand Down Expand Up @@ -148,6 +152,11 @@ SCHEMA = """
"description": "Install EFI binaries and data from the build root",
"type": "boolean",
"default": false
},
"unified": {
"description": "Main grub config in 'boot/grub2/grub.cfg'",
"type": "boolean",
"default": false
}
}
},
Expand Down Expand Up @@ -337,7 +346,8 @@ class GrubConfig:

def write_redirect(self, tree, path):
"""Write a grub config pointing to the other cfg"""
print("hybrid boot support enabled. Writing alias grub config")
print("hybrid boot or unified grub config enabled. "
"Writing alias grub config")

# configuration options for the template
config = {
Expand Down Expand Up @@ -436,14 +446,15 @@ def main(tree, options):
# or a shim one that redirects to the canonical one in
# /boot/grub2 in case of hybrid boot (see above)
vendor = uefi["vendor"]
unified = uefi.get("unified", False)

# EFI binaries and accompanying data can be installed from
# the build root instead of using an rpm package
if uefi.get('install', False):
copy_efi_data(tree, vendor)

grubcfg = f"boot/efi/EFI/{vendor}/grub.cfg"
if hybrid:
if hybrid or unified:
config.write_redirect(tree, grubcfg)
else:
config.path = grubcfg
Expand Down
Loading

0 comments on commit da8f45e

Please sign in to comment.