]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: introduce --make-entry-directory= option
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 26 Mar 2023 05:57:10 +0000 (14:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 5 Jun 2023 05:23:54 +0000 (14:23 +0900)
For consistency with bootctl. However, unlike the same option for
bootctl, defaults to 'auto' for backward compatibility.

man/kernel-install.xml
src/kernel-install/kernel-install.c

index 835eb36f18701bc6d5850b084a0eafa23af5ed7c..2ee298fc16172edbb0c9d614f330872bb049dbf6 100644 (file)
       <xi:include href="standard-options.xml" xpointer="esp-path"/>
       <xi:include href="standard-options.xml" xpointer="boot-path"/>
 
+      <varlistentry>
+        <term><option>--make-entry-directory=yes|no|auto</option></term>
+        <listitem>
+          <para>Controls creation and deletion of the
+          <ulink url="https://uapi-group.org/specifications/specs/boot_loader_specification">Boot Loader Specification</ulink>
+          Type #1 entry directory on the file system containing resources such as kernel and initrd images
+          during <option>add</option> and <option>remove</option>, respectively. The directory is named after
+          the entry token, and is placed immediately below the boot root directory. When
+          <literal>auto</literal>, the directory is created or removed only when the install layout is
+          <literal>bls</literal>. Defaults to <literal>auto</literal>.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>-v</option></term>
         <term><option>--verbose</option></term>
index 631c054cfcacbc04987f5c301d468815d6abba2e..8db0fbd2f42a098b2cf78597fc7da388b5a08021 100644 (file)
@@ -31,6 +31,7 @@
 static bool arg_verbose = false;
 static char *arg_esp_path = NULL;
 static char *arg_xbootldr_path = NULL;
+static int arg_make_entry_directory = -1; /* tristate */
 
 STATIC_DESTRUCTOR_REGISTER(arg_esp_path, freep);
 STATIC_DESTRUCTOR_REGISTER(arg_xbootldr_path, freep);
@@ -762,7 +763,10 @@ static bool context_should_make_entry_dir(Context *c) {
         /* Compatibility with earlier versions that used the presence of $BOOT_ROOT/$ENTRY_TOKEN to signal to
          * 00-entry-directory to create $ENTRY_DIR to serve as the indication to use or to not use the BLS */
 
-        return c->layout == LAYOUT_BLS;
+        if (arg_make_entry_directory < 0)
+                return c->layout == LAYOUT_BLS;
+
+        return arg_make_entry_directory;
 }
 
 static int context_make_entry_dir(Context *c) {
@@ -1114,6 +1118,8 @@ static int help(void) {
                "  -v --verbose           Increase verbosity\n"
                "     --esp-path=PATH     Path to the EFI System Partition (ESP)\n"
                "     --boot-path=PATH    Path to the $BOOT partition\n"
+               "     --make-entry-directory=yes|no|auto\n"
+               "                         Create $BOOT/ENTRY-TOKEN/ directory\n"
                "\nSee the %4$s for details.\n",
                program_invocation_short_name,
                ansi_highlight(),
@@ -1128,6 +1134,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_VERSION = 0x100,
                 ARG_ESP_PATH,
                 ARG_BOOT_PATH,
+                ARG_MAKE_ENTRY_DIRECTORY,
         };
         static const struct option options[] = {
                 { "help",                 no_argument,       NULL, 'h'                      },
@@ -1135,6 +1142,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "verbose",              no_argument,       NULL, 'v'                      },
                 { "esp-path",             required_argument, NULL, ARG_ESP_PATH             },
                 { "boot-path",            required_argument, NULL, ARG_BOOT_PATH            },
+                { "make-entry-directory", required_argument, NULL, ARG_MAKE_ENTRY_DIRECTORY },
                 {}
         };
         int t, r;
@@ -1167,6 +1175,18 @@ static int parse_argv(int argc, char *argv[]) {
                                 return log_oom();
                         break;
 
+                case ARG_MAKE_ENTRY_DIRECTORY:
+                        if (streq(optarg, "auto"))
+                                arg_make_entry_directory = -1;
+                        else {
+                                r = parse_boolean_argument("--make-entry-directory=", optarg, NULL);
+                                if (r < 0)
+                                        return r;
+
+                                arg_make_entry_directory = r;
+                        }
+                        break;
+
                 case '?':
                         return -EINVAL;