naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
8d419f
From 8742d040aa5ef5e784c903d0c3efacba7d69ade2 Mon Sep 17 00:00:00 2001
8d419f
From: Lennart Poettering <lennart@poettering.net>
8d419f
Date: Thu, 10 Feb 2022 14:37:37 +0100
8d419f
Subject: [PATCH] kernel-install: add new "inspect" verb, showing paths and
8d419f
 parameters we discovered
8d419f
8d419f
(cherry picked from commit c73cf4184441d3cc37a5e2195938f07420ec38b7)
8d419f
8d419f
Related: #2065061
8d419f
---
8d419f
 src/kernel-install/kernel-install | 29 +++++++++++++++++++++++------
8d419f
 1 file changed, 23 insertions(+), 6 deletions(-)
8d419f
8d419f
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
8d419f
index c42c40592a..b8099bd12c 100755
8d419f
--- a/src/kernel-install/kernel-install
8d419f
+++ b/src/kernel-install/kernel-install
8d419f
@@ -25,6 +25,7 @@ usage()
8d419f
     echo "Usage:"
8d419f
     echo "  $0 [OPTIONS...] add KERNEL-VERSION KERNEL-IMAGE [INITRD-FILE ...]"
8d419f
     echo "  $0 [OPTIONS...] remove KERNEL-VERSION"
8d419f
+    echo "  $0 [OPTIONS...] inspect"
8d419f
     echo "Options:"
8d419f
     echo "  -h, --help     Print this help"
8d419f
     echo "  -v, --verbose  Increase verbosity"
8d419f
@@ -72,13 +73,17 @@ else
8d419f
     [ $# -ge 1 ] && shift
8d419f
 fi
8d419f
 
8d419f
-if [ $# -lt 1 ]; then
8d419f
-    echo "Error: not enough arguments" >&2
8d419f
-    exit 1
8d419f
-fi
8d419f
+if [ "$COMMAND" = "inspect" ]; then
8d419f
+    KERNEL_VERSION=""
8d419f
+else
8d419f
+    if [ $# -lt 1 ]; then
8d419f
+        echo "Error: not enough arguments" >&2
8d419f
+        exit 1
8d419f
+    fi
8d419f
 
8d419f
-KERNEL_VERSION="$1"
8d419f
-shift
8d419f
+    KERNEL_VERSION="$1"
8d419f
+    shift
8d419f
+fi
8d419f
 
8d419f
 layout=
8d419f
 initrd_generator=
8d419f
@@ -237,6 +242,18 @@ case "$COMMAND" in
8d419f
         fi
8d419f
         ;;
8d419f
 
8d419f
+    inspect)
8d419f
+        echo "KERNEL_INSTALL_MACHINE_ID: $KERNEL_INSTALL_MACHINE_ID"
8d419f
+        echo "KERNEL_INSTALL_ENTRY_TOKEN: $KERNEL_INSTALL_ENTRY_TOKEN"
8d419f
+        echo "KERNEL_INSTALL_BOOT_ROOT: $KERNEL_INSTALL_BOOT_ROOT"
8d419f
+        echo "KERNEL_INSTALL_LAYOUT: $KERNEL_INSTALL_LAYOUT"
8d419f
+        echo "KERNEL_INSTALL_INITRD_GENERATOR: $KERNEL_INSTALL_INITRD_GENERATOR"
8d419f
+        echo "ENTRY_DIR_ABS: $KERNEL_INSTALL_BOOT_ROOT/$ENTRY_TOKEN/\$KERNEL_VERSION"
8d419f
+
8d419f
+        # Assert that ENTRY_DIR_ABS actually matches what we are printing here
8d419f
+        [ "${ENTRY_DIR_ABS%/*}" = "$KERNEL_INSTALL_BOOT_ROOT/$ENTRY_TOKEN" ] || { echo "Assertion didn't pass." >&2; exit 1; }
8d419f
+
8d419f
+        ;;
8d419f
     *)
8d419f
         echo "Error: unknown command '$COMMAND'" >&2
8d419f
         exit 1