]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: make inspect command optionally take kernel image
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 19 Mar 2023 14:43:16 +0000 (23:43 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 5 Jun 2023 05:23:54 +0000 (14:23 +0900)
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
src/kernel-install/kernel-install.c
src/kernel-install/test-kernel-install.sh

index 4f71d67e2f0666703a6e72441e27bc3d411111dd..06a95480e6b82ae032f3e96c3bf93737df685311 100644 (file)
@@ -40,6 +40,7 @@
       <command>kernel-install</command>
       <arg choice="opt" rep="repeat">OPTIONS</arg>
       <arg choice="plain">inspect</arg>
+      <arg choice="opt"><replaceable>KERNEL-IMAGE</replaceable></arg>
     </cmdsynopsis>
   </refsynopsisdiv>
 
         </listitem>
       </varlistentry>
       <varlistentry>
-        <term><command>inspect</command></term>
+        <term><command>inspect [<replaceable>KERNEL-IMAGE</replaceable>]</command></term>
         <listitem>
           <para>Shows the various paths and parameters configured or auto-detected. In particular shows the
           values of the various <varname>$KERNEL_INSTALL_*</varname> environment variables listed
index de744fe1c40f2d9d4260fc99702b0d6f7b90dacc..5dde1eb28919d5bd2a942930158c03795dadd322 100644 (file)
@@ -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 = {
index 4be877135973cf47dfa9cb08207c8e3214f8432f..654137b068a6519bff4c950cf5e66803afe90b25 100755 (executable)
@@ -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"