]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: check for /loader/entries.srel file as explicit marker for standards... 22778/head
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Mar 2022 17:25:40 +0000 (18:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 21 Mar 2022 23:34:49 +0000 (00:34 +0100)
src/kernel-install/kernel-install

index 719abf2b81b465ba60977460488429cf78b0bb71..a09b998362195a788ef6b6f07cc2973847abb29d 100755 (executable)
@@ -155,10 +155,29 @@ done
 [ -z "$ENTRY_TOKEN" ] && ENTRY_TOKEN="$MACHINE_ID"
 
 if [ -z "$layout" ]; then
-    # Administrative decision: if not present, some scripts generate into /boot.
-    if [ -d "$BOOT_ROOT/$ENTRY_TOKEN" ]; 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
+        read -r ENTRIES_SREL <"$BOOT_ROOT/loader/entries.srel"
+        if [ "$ENTRIES_SREL" = "type1" ]; then
+            # The loader/entries.srel file clearly indicates that the installed
+            # boot loader implements the proper standard upstream boot loader
+            # spec for Type #1 entries. Let's default to that, then.
+            layout="bls"
+        else
+            # The loader/entries.srel file indicates some other spec is
+            # implemented and owns the /loader/entries/ directory. Since we
+            # have no idea what that means, let's stay away from it by default.
+            layout="other"
+        fi
+    elif [ -d "$BOOT_ROOT/$ENTRY_TOKEN" ]; then
+        # If the metadata in $BOOT_ROOT doesn't tell us anything, then check if
+        # the entry token directory already exists. If so, let's assume it's
+        # the standard boot loader spec, too.
         layout="bls"
     else
+        # There's no metadata in $BOOT_ROOT, and apparently no entry token
+        # directory installed? Then we really don't know anything.
         layout="other"
     fi
 fi