kernel-install: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The note about invocation as 'installkernel' is kept as the footer. Verb and option column widths are kept separate, since the verb table is very wide. --help now goes through the pager, like other commands with --no-pager. A separate COMMAND block is included for installkernel, but it is only used for introspection data.
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "ansi-color.h"
|
||||
#include "argv-util.h"
|
||||
#include "boot-entry.h"
|
||||
@@ -22,7 +24,6 @@
|
||||
#include "find-esp.h"
|
||||
#include "format-table.h"
|
||||
#include "fs-util.h"
|
||||
#include "help-util.h"
|
||||
#include "id128-util.h"
|
||||
#include "image-policy.h"
|
||||
#include "kernel-config.h"
|
||||
@@ -30,7 +31,6 @@
|
||||
#include "loop-util.h"
|
||||
#include "main-func.h"
|
||||
#include "mount-util.h"
|
||||
#include "options.h"
|
||||
#include "parse-argument.h"
|
||||
#include "path-util.h"
|
||||
#include "recurse-dir.h"
|
||||
@@ -64,6 +64,17 @@ STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_entry_token, freep);
|
||||
|
||||
COMMAND(
|
||||
"kernel-install\0",
|
||||
"Add and remove kernel and initrd images to and from the boot partition.",
|
||||
.footer = "This program may also be invoked as 'installkernel':\n"
|
||||
" installkernel [OPTION…] VERSION VMLINUZ [MAP] [INSTALLATION-DIR]\n"
|
||||
"(The optional arguments are passed by kernel build system, but ignored.)",
|
||||
.man_pages = "kernel-install.8\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
.flags = COMMAND_HELP_SEPARATE, /* the verb table is very wide */
|
||||
);
|
||||
|
||||
typedef enum Action {
|
||||
ACTION_ADD,
|
||||
ACTION_REMOVE,
|
||||
@@ -1599,44 +1610,7 @@ static int verb_list(int argc, char *argv[], uintptr_t _data, void *userdata) {
|
||||
return table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *options = NULL, *verbs = NULL;
|
||||
int r;
|
||||
|
||||
r = verbs_get_help_table(&verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = option_parser_get_help_table(&options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Note: column widths are not synced, because the verbs table is very wide. */
|
||||
|
||||
help_cmdline("[OPTIONS…] COMMAND …");
|
||||
help_abstract("Add and remove kernel and initrd images to and from the boot partition.");
|
||||
|
||||
help_section("Commands");
|
||||
r = table_print_or_warn(verbs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
printf("\n"
|
||||
"This program may also be invoked as 'installkernel':\n"
|
||||
" installkernel [OPTIONS...] VERSION VMLINUZ [MAP] [INSTALLATION-DIR]\n"
|
||||
"(The optional arguments are passed by kernel build system, but ignored.)\n");
|
||||
|
||||
help_man_page_reference("kernel-install", "8");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VERB_COMMON_HELP(help);
|
||||
VERB_COMMON_HELP_AUTO_PROGRAM("kernel-install");
|
||||
|
||||
static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
assert(argc >= 0);
|
||||
@@ -1650,7 +1624,7 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help_full("kernel-install", /* footer_ansi_seq= */ NULL);
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
@@ -1735,6 +1709,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(arg_json_format_flags);
|
||||
}
|
||||
|
||||
if (arg_image && arg_root)
|
||||
@@ -1745,6 +1722,17 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Definition for the compat interface to populate introspection data.
|
||||
* Keep below the VERB definitions for the main command. */
|
||||
COMMAND(
|
||||
"installkernel\0",
|
||||
"Add and remove kernel and initrd images to and from the boot partition.",
|
||||
.argspec = "VERSION VMLINUZ [MAP] [INSTALLATION-DIR]\0",
|
||||
.footer = "This is a compat interface intended only to be called from kernel Makefiles.",
|
||||
.man_pages = "kernel-install.8\0",
|
||||
.pager_flags = &arg_pager_flags,
|
||||
);
|
||||
|
||||
static int run(int argc, char* argv[]) {
|
||||
int r;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ INTROSPECTABLE=(
|
||||
importctl
|
||||
iocost
|
||||
journalctl
|
||||
kernel-install
|
||||
localectl
|
||||
loginctl
|
||||
machinectl
|
||||
@@ -158,6 +159,11 @@ if command -v systemd-hwdb >/dev/null; then
|
||||
'.commands[0].verbs | map(.names[0]) | sort == ["help", "query", "update"]'
|
||||
fi
|
||||
|
||||
if command -v kernel-install >/dev/null; then
|
||||
kernel-install --introspect-cli | jq -e \
|
||||
'[.commands[].names[0]] | sort == ["installkernel", "kernel-install"]'
|
||||
fi
|
||||
|
||||
resolvectl --introspect-cli | jq -e \
|
||||
'[.commands[].names[0]] | sort == ["resolvconf", "resolvectl", "systemd-resolve"]'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user