diff mbox series

[v2] uki.bbclass: allow overriding the embedded os-release

Message ID 20261129222605.2163613-1-ricardo.salveti@oss.qualcomm.com
State New
Headers show
Series [v2] uki.bbclass: allow overriding the embedded os-release | expand

Commit Message

Ricardo Salveti Nov. 29, 2026, 10:26 p.m. UTC
uki.bbclass copies the os-release file from the recipe sysroot into the
UKI (its .osrel section), and there is no way to use a different file:
the class always passes --os-release to ukify, which takes precedence
over UKI_CONFIG_FILE.

systemd-boot boots the UKIs placed in /EFI/Linux on the EFI system
partition without any loader entry file; the Boot Loader Specification
calls these "Type #2" entries [1]. It reads the os-release embedded in
each UKI to name it in the menu and to order them: UKIs of the same OS
are sorted by their version fields (VERSION, VERSION_ID, IMAGE_VERSION
or BUILD_ID), newest first, and by file name only when those are equal,
and the first one boots by default. A layer that installs several such
UKIs and sets their order through the file names therefore needs to
embed an os-release without the version fields, while the rootfs keeps
the full one.

Add UKI_OS_RELEASE, the os-release file embedded in the UKI. It
defaults to the os-release from the recipe sysroot, so nothing changes
unless a layer sets it.

[1] https://uapi-group.org/specifications/specs/boot_loader_specification/#type-2-efi-unified-kernel-images

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Ricardo Salveti <ricardo.salveti@oss.qualcomm.com>
---
 meta/classes-recipe/uki.bbclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/uki.bbclass b/meta/classes-recipe/uki.bbclass
index bcccf824c7..faad496f1b 100644
--- a/meta/classes-recipe/uki.bbclass
+++ b/meta/classes-recipe/uki.bbclass
@@ -80,6 +80,7 @@  UKI_CONFIG_FILE ?= "${UNPACKDIR}/uki.conf"
 UKI_FILENAME ?= "uki.efi"
 UKI_KERNEL_FILENAME ?= "${KERNEL_IMAGETYPE}"
 UKI_CMDLINE ?= "rootwait root=LABEL=root"
+UKI_OS_RELEASE ?= "${RECIPE_SYSROOT}${prefix}/lib/os-release"
 KERNEL_DEVICETREE ??= ""
 UKI_DEVICETREE ?= "${KERNEL_DEVICETREE}"
 # secure boot keys and cert, needs sbsign-tools-native (meta-secure-core)
@@ -171,8 +172,10 @@  python do_uki() {
         (d.getVar("RECIPE_SYSROOT_NATIVE"), d.getVar("prefix"))
 
     # version
-    ukify_cmd += " --os-release=@%s%s/lib/os-release" % \
-        (d.getVar("RECIPE_SYSROOT"), d.getVar("prefix"))
+    os_release = d.getVar('UKI_OS_RELEASE')
+    if not os_release or not os.path.exists(os_release):
+        bb.fatal("ERROR: cannot find os-release %s" % (os_release))
+    ukify_cmd += " --os-release=@%s" % (os_release)
 
     # TODO: tpm2 measure for secure boot, depends on systemd-native and TPM tooling
     # needed in systemd > 254 to fulfill ConditionSecurity=measured-uki