Integration for GrubCC and SystemdBoot#1113
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for multiple bootloaders, specifically adding a new GrubCC option alongside the default Grub. It updates the saved state, component installation, update, and status mechanisms to dynamically detect and filter metadata based on the active bootloader, including handling state files stored in the ESP for GrubCC. The review feedback identifies a potential mount leak where the was_mounted flag is not reset upon unmounting, several instances of unnecessary double referencing, and opportunities to make the code more idiomatic by simplifying OnceLock usage and removing redundant iterator adapters.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
2ffcc16 to
e8da148
Compare
77321d0 to
fb028b8
Compare
aa72462 to
e7bf29d
Compare
Now that we are going to support multiple bootloaders, we need a way to keep track of which one we're operating on Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Generate metadata for only a particular bootloader, either Grub or GrubCC Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Add `is_bootloader_supported` function to figure out if bootloader is supported by the component or not. Skip installs and metadata generation for the component if it does not support the bootloader Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
For grub we store the statefile in `/sysroot/boot/bootupd.json`. For grub-cc, and in future systemd-boot, we won't have a `/boot`, so we now store the state pre bootloader. Grub2: Statefile is still in `/sysroot/boot/bootupd.json` GrubCC: Statefile is stored in all the ESPs Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Store the sysroot_path in StateLockGuard which we require for mounting the ESP. Also, prevent mounting ESP at a tempdir, instead just mount it at `/boot` which is what the BLS spec suggest Fix issue with composefs systems where lsblk would fail to find the backing device for "/" due to it being mounted as a virtual filesystem. Instead we now use `/sysroot` or `/boot` to find the baking device Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
For `bootupd generate-update-metadata` we now generate metadata for all
found bootloaders. The final json will look like
```json
{
"timestamp": "2026-06-10T09:52:58.107743026Z",
"version": "grub-cc-1:2.12-59.fc45,grub2-1:2.12-58.fc44,shim-16.1-5",
"versions": [
{ "name": "grub-cc", "rpm_evr": "1:2.12-59.fc45" },
{ "name": "grub2", "rpm_evr": "1:2.12-58.fc44" },
{ "name": "shim", "rpm_evr": "16.1-5" }
]
}
```
This allows us to have multiple bootloaders in a single image and
install/update based on preference.
During install/update, we check to bootloader and filter out any and all
entries from the update metadata that do not match or are not required
for the bootloader
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Only allow Grub as the bootloader for powerpc and s390x Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
5a30e22 to
8de47d2
Compare
Create a new Dockerfile with base "fedora-bootc:44" for testing images with both grub and grub-cc present. Currently we don't have a bootc release that allows us to test with grub-cc, so we only test grub installations. This mainly tests backwards compatibility for the following cases - Only one bootloader present and no "default" in metadata - Two bootloaders present with grub as the "default" Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1c646b3 to
1106373
Compare
This works exactly like GrubCC We expect systemd-boot efi to be in `/usr/lib/efi/systemd-boot/<evr>/fedora/grubx64.cc` Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
We don't have e2e upgrade tests for now, but we can atleast test if the installations are working well Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
We generate the final filetree from `/usr/lib/efi` which worked well with only one bootloader, but now that we have three which are stored in the following places Grub2 - /usr/lib/efi/grub2/<evr>/EFI/fedora/grubx64.efi GrubCC - /usr/lib/efi/grub-cc/<evr>/EFI/fedora/grubx64.efi SystemdBoot - /usr/lib/efi/systemd-boot/<evr>/EFI/fedora/grubx64.efi The problem arises as all the distinct efi binaries have the same name (grubx64.efi - due to the particular name being baked into shim), we cannot blindly create a filesystem tree out of this as later values will override the previous ones. To mitigate this, introduce a param `skip_dirs` which will filter directories not required for the bootloader being installed Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
cd1e957 to
3a39aed
Compare
A utility cfg macro defined in build.rs so that we can deny EFI only bootloaders - GrubCC and SystemdBoot, on non-EFI systems at compile time Also, only allow setting default bootloaders for EFI systems Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Add Bootloader enum
Now that we are going to support multiple bootloaders, we need a way to
keep track of which one we're operating on
For
bootupd generate-update-metadatawe now generate metadata for allfound bootloaders. The final json will look like
{ "timestamp": "2026-06-10T09:52:58.107743026Z", "version": "grub-cc-1:2.12-59.fc45,grub2-1:2.12-58.fc44,shim-16.1-5", "versions": [ { "name": "grub-cc", "rpm_evr": "1:2.12-59.fc45" }, { "name": "grub2", "rpm_evr": "1:2.12-58.fc44" }, { "name": "shim", "rpm_evr": "16.1-5" } ] }This allows us to have multiple bootloaders in a single image and
install/update based on preference.
During install/update, we check to bootloader and filter out any and all
entries from the update metadata that do not match or are not required
for the bootloader
For grub we store the statefile in
/sysroot/boot/bootupd.json. Forgrub-cc, and in future systemd-boot, we won't have a
/boot, so we nowstore the state pre bootloader.
Grub2: Statefile is still in
/sysroot/boot/bootupd.jsonGrubCC: Statefile is stored in all the ESPs
Store the sysroot_path in StateLockGuard which we require for mounting
the ESP. Also, mount the ESP at
/bootwhich is what the BLS spec suggest