From f7665b7f6c05e2bb4d98fdde775117e77046d5d9 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 19 Mar 2023 23:43:16 +0900 Subject: [PATCH] kernel-install: make inspect command optionally take kernel image If the kernel image is provided, then we can inspect the kernel image and may determine the layout based on the kernel image type. --- man/kernel-install.xml | 3 ++- src/kernel-install/kernel-install.c | 12 +++++++++--- src/kernel-install/test-kernel-install.sh | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/man/kernel-install.xml b/man/kernel-install.xml index 4f71d67e2f0..06a95480e6b 100644 --- a/man/kernel-install.xml +++ b/man/kernel-install.xml @@ -40,6 +40,7 @@ kernel-install OPTIONS inspect + KERNEL-IMAGE @@ -158,7 +159,7 @@ - inspect + inspect [KERNEL-IMAGE] Shows the various paths and parameters configured or auto-detected. In particular shows the values of the various $KERNEL_INSTALL_* environment variables listed diff --git a/src/kernel-install/kernel-install.c b/src/kernel-install/kernel-install.c index de744fe1c40..5dde1eb2891 100644 --- a/src/kernel-install/kernel-install.c +++ b/src/kernel-install/kernel-install.c @@ -866,7 +866,7 @@ static int context_build_arguments(Context *c) { return log_oom(); } else if (c->action == ACTION_INSPECT) { - r = strv_extend(&a, "[KERNEL_IMAGE]"); + r = strv_extend(&a, c->kernel ?: "[KERNEL_IMAGE]"); if (r < 0) return log_oom(); @@ -1043,6 +1043,12 @@ static int verb_inspect(int argc, char *argv[], void *userdata) { c->action = ACTION_INSPECT; + if (argc >= 2) { + r = context_set_kernel(c, argv[1]); + if (r < 0) + return r; + } + r = context_prepare_execution(c); if (r < 0) return r; @@ -1093,7 +1099,7 @@ static int help(void) { "\nUsage:\n" " %1$s [OPTIONS...] add KERNEL-VERSION KERNEL-IMAGE [INITRD-FILE...]\n" " %1$s [OPTIONS...] remove KERNEL-VERSION\n" - " %1$s [OPTIONS...] inspect\n" + " %1$s [OPTIONS...] inspect [KERNEL-IMAGE]\n" "\nOptions:\n" " -h --help Show this help\n" " --version Show package version\n" @@ -1149,7 +1155,7 @@ static int run(int argc, char* argv[]) { static const Verb verbs[] = { { "add", 3, VERB_ANY, 0, verb_add }, { "remove", 2, 2, 0, verb_remove }, - { "inspect", 1, 1, VERB_DEFAULT, verb_inspect }, + { "inspect", 1, 2, VERB_DEFAULT, verb_inspect }, {} }; _cleanup_(context_done) Context c = { diff --git a/src/kernel-install/test-kernel-install.sh b/src/kernel-install/test-kernel-install.sh index 4be87713597..654137b068a 100755 --- a/src/kernel-install/test-kernel-install.sh +++ b/src/kernel-install/test-kernel-install.sh @@ -63,6 +63,7 @@ grep -qE 'image' "$BOOT_ROOT/the-token/1.1.1/linux" grep -qE 'initrd' "$BOOT_ROOT/the-token/1.1.1/initrd" "$kernel_install" inspect +"$kernel_install" inspect "$D/sources/linux" "$kernel_install" -v remove 1.1.1 test ! -e "$entry" -- 2.47.3