kernel-install: introduce --make-entry-directory= option

For consistency with bootctl. However, unlike the same option for
bootctl, defaults to 'auto' for backward compatibility.
This commit is contained in:
Yu Watanabe 2023-03-26 14:57:10 +09:00
parent 4cff5e92a9
commit b79621aa99
2 changed files with 34 additions and 1 deletions

View file

@ -189,6 +189,19 @@
<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>

View 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;