]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: teach bot loader spec entry generator to generate entries with "tries"
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Jun 2018 15:35:53 +0000 (17:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 19 Oct 2018 20:34:50 +0000 (22:34 +0200)
This makes two changes:

1. When called for "remove" any drop-ins with "+" suffix are removed
   too, so that the logic works for entries with boot counting enabled
   too and we don't lose track of configuration snippets created that
   way.

2. When called for "add" we optionally generate a "+" suffix, based on
   the data in /etc/kernel/tries if it exists.

   This basically means after "echo 5 > /etc/kernel/tries" any installed
   kernels will automatically set up for 5 boot tries before older
   kernels will be tried.

src/kernel-install/90-loaderentry.install

index a271cdb8a03ecd2b0753c86c5914a74b8aa5a4bd..39ec8a69c66ba0828480a8f3657a98b7c92bb441 100644 (file)
@@ -19,10 +19,11 @@ MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID
 
 BOOT_DIR="/$MACHINE_ID/$KERNEL_VERSION"
 BOOT_ROOT=${BOOT_DIR_ABS%$BOOT_DIR}
-LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
 
 if [[ $COMMAND == remove ]]; then
-    exec rm -f "$LOADER_ENTRY"
+    rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
+    rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION+"*".conf"
+    exit 0
 fi
 
 if ! [[ $COMMAND == add ]]; then
@@ -63,6 +64,17 @@ if ! [[ ${BOOT_OPTIONS[*]} ]]; then
     exit 1
 fi
 
+if [[ -f /etc/kernel/tries ]]; then
+    read -r TRIES </etc/kernel/tries
+    if ! [[ "$TRIES" =~ ^[0-9]+$ ]] ; then
+        echo "/etc/kernel/tries does not contain an integer." >&2
+        exit 1
+    fi
+    LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION+$TRIES.conf"
+else
+    LOADER_ENTRY="$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf"
+fi
+
 cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS/linux" &&
    chown root:root "$BOOT_DIR_ABS/linux" &&
    chmod 0644 "$BOOT_DIR_ABS/linux" || {