kernel-install: handle uki installs automatically

Detect image type using "bootctl kernel-identify $kernel",
store result in KERNEL_INSTALL_IMAGE_TYPE.

Extend layout autodetection to check the kernel image type
and pick layout=uki for UKIs.

Resolves: #25822
This commit is contained in:
Gerd Hoffmann
2023-03-07 08:14:46 +01:00
parent 642617f431
commit 3d5f0bfe4e
2 changed files with 23 additions and 6 deletions
+10 -2
View File
@@ -250,10 +250,18 @@ if [ -z "$ENTRY_TOKEN" ]; then
echo "No entry-token candidate matched, using \"$ENTRY_TOKEN\" from machine-id"
fi
if [ -z "$layout" ]; then
export KERNEL_INSTALL_IMAGE_TYPE=""
if [ -f "$1" ]; then
KERNEL_INSTALL_IMAGE_TYPE="$(bootctl kernel-identify "$1" 2>/dev/null || echo "unknown")"
fi
if [ "$layout" = "auto" ] || [ -z "$layout" ]; then
# No layout configured by the administrator. Let's try to figure it out
# automatically from metadata already contained in $BOOT_ROOT.
if [ -e "$BOOT_ROOT/loader/entries.srel" ]; then
if [ "$KERNEL_INSTALL_IMAGE_TYPE" = "uki" ]; then
layout="uki"
log_verbose "Kernel image is UKI, using layout=$layout"
elif [ -e "$BOOT_ROOT/loader/entries.srel" ]; then
read -r ENTRIES_SREL <"$BOOT_ROOT/loader/entries.srel"
if [ "$ENTRIES_SREL" = "type1" ]; then
# The loader/entries.srel file clearly indicates that the installed