richardphibel / rpms / systemd

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