From 4cff5e92a9e0e3e6c3634df7837a571b36934d7f Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 20 Mar 2023 02:55:56 +0900 Subject: kernel-install: add --esp-path= and --boot-path= options Then, kernel-install takes one more step for compatibility with bootctl. --- man/bootctl.xml | 16 ++-------------- man/kernel-install.xml | 3 +++ man/standard-options.xml | 21 +++++++++++++++++++++ src/kernel-install/kernel-install.c | 30 +++++++++++++++++++++++++++--- 4 files changed, 53 insertions(+), 17 deletions(-) diff --git a/man/bootctl.xml b/man/bootctl.xml index 5f98486343..25522b9e4e 100644 --- a/man/bootctl.xml +++ b/man/bootctl.xml @@ -269,20 +269,8 @@ The following options are understood: - - - Path to the EFI System Partition (ESP). If not specified, /efi/, - /boot/, and /boot/efi/ are checked in turn. It is - recommended to mount the ESP to /efi/, if possible. - - - - - Path to the Extended Boot Loader partition, as defined in the Boot Loader Specification. If not - specified, /boot/ is checked. It is recommended to mount the Extended Boot - Loader partition to /boot/, if possible. - + + diff --git a/man/kernel-install.xml b/man/kernel-install.xml index 06a95480e6..835eb36f18 100644 --- a/man/kernel-install.xml +++ b/man/kernel-install.xml @@ -186,6 +186,9 @@ The following options are understood: + + + diff --git a/man/standard-options.xml b/man/standard-options.xml index 71c84958ab..e72442e5a7 100644 --- a/man/standard-options.xml +++ b/man/standard-options.xml @@ -97,4 +97,25 @@ in the image are used. + + + + + Path to the EFI System Partition (ESP). If not specified, /efi/, + /boot/, and /boot/efi/ are checked in turn. It is + recommended to mount the ESP to /efi/, if possible. + + + + + + + + Path to the Extended Boot Loader partition, as defined in the + Boot Loader Specification. + If not specified, /boot/ is checked. It is recommended to mount the Extended Boot + Loader partition to /boot/, if possible. + + + diff --git a/src/kernel-install/kernel-install.c b/src/kernel-install/kernel-install.c index 396bfc6d44..631c054cfc 100644 --- a/src/kernel-install/kernel-install.c +++ b/src/kernel-install/kernel-install.c @@ -17,6 +17,7 @@ #include "kernel-image.h" #include "main-func.h" #include "mkdir.h" +#include "parse-argument.h" #include "path-util.h" #include "pretty-print.h" #include "rm-rf.h" @@ -28,6 +29,11 @@ #include "verbs.h" static bool arg_verbose = false; +static char *arg_esp_path = NULL; +static char *arg_xbootldr_path = NULL; + +STATIC_DESTRUCTOR_REGISTER(arg_esp_path, freep); +STATIC_DESTRUCTOR_REGISTER(arg_xbootldr_path, freep); typedef enum Action { ACTION_ADD, @@ -473,7 +479,7 @@ static int context_acquire_xbootldr(Context *c) { r = find_xbootldr_and_warn_at( /* rfd = */ c->rfd, - /* path = */ NULL, + /* path = */ arg_xbootldr_path, /* unprivileged_mode= */ -1, /* ret_path = */ &c->boot_root, /* ret_uuid = */ NULL, @@ -499,7 +505,7 @@ static int context_acquire_esp(Context *c) { r = find_esp_and_warn_at( /* rfd = */ c->rfd, - /* path = */ NULL, + /* path = */ arg_esp_path, /* unprivileged_mode= */ -1, /* ret_path = */ &c->boot_root, /* ret_part = */ NULL, @@ -1106,6 +1112,8 @@ static int help(void) { " -h --help Show this help\n" " --version Show package version\n" " -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" "\nSee the %4$s for details.\n", program_invocation_short_name, ansi_highlight(), @@ -1118,14 +1126,18 @@ static int help(void) { static int parse_argv(int argc, char *argv[]) { enum { ARG_VERSION = 0x100, + ARG_ESP_PATH, + ARG_BOOT_PATH, }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, ARG_VERSION }, { "verbose", no_argument, NULL, 'v' }, + { "esp-path", required_argument, NULL, ARG_ESP_PATH }, + { "boot-path", required_argument, NULL, ARG_BOOT_PATH }, {} }; - int t; + int t, r; assert(argc >= 0); assert(argv); @@ -1143,6 +1155,18 @@ static int parse_argv(int argc, char *argv[]) { arg_verbose = true; break; + case ARG_ESP_PATH: + r = parse_path_argument(optarg, /* suppress_root = */ false, &arg_esp_path); + if (r < 0) + return log_oom(); + break; + + case ARG_BOOT_PATH: + r = parse_path_argument(optarg, /* suppress_root = */ false, &arg_xbootldr_path); + if (r < 0) + return log_oom(); + break; + case '?': return -EINVAL; -- cgit v1.2.3