From ba76d38f37482cf16458c379bcda96179ff279ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 15 Aug 2026 12:27:33 +0200 Subject: [PATCH] firstboot: convert to VERB_COMMAND and add --introspect-cli MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The abstract is changed to use the imperative form ("Configure …" instead of "Configures …"), consistent with the other commands. --- src/firstboot/firstboot.c | 36 +++++++------------ .../units/TEST-74-AUX-UTILS.introspect-cli.sh | 1 + 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index a76b4c755e..504fc23ebd 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -5,6 +5,7 @@ #include "sd-bus.h" #include "sd-id128.h" +#include "sd-json.h" #include "sd-varlink.h" #include "alloc-util.h" @@ -26,10 +27,8 @@ #include "fd-util.h" #include "fileio.h" #include "firstboot-util.h" -#include "format-table.h" #include "fs-util.h" #include "glyph-util.h" -#include "help-util.h" #include "hostname-setup.h" #include "hostname-util.h" #include "image-policy.h" @@ -43,7 +42,6 @@ #include "main-func.h" #include "memory-util.h" #include "mount-util.h" -#include "options.h" #include "os-util.h" #include "parse-argument.h" #include "password-quality-util.h" @@ -60,6 +58,7 @@ #include "tmpfile-util.h" #include "user-util.h" #include "vconsole-util.h" +#include "verbs.h" static char *arg_root = NULL; static char *arg_image = NULL; @@ -110,6 +109,12 @@ STATIC_DESTRUCTOR_REGISTER(arg_kernel_cmdline, freep); STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep); STATIC_DESTRUCTOR_REGISTER(arg_label_context, mac_label_context_freep); +COMMAND( + "systemd-firstboot\0", + "Configure basic settings of the system.", + .man_pages = "systemd-firstboot.1\0", +); + static bool welcome_done = false; static void print_welcome(int rfd, sd_varlink **mute_console_link) { @@ -1378,26 +1383,6 @@ static int process_reset(int rfd) { return 0; } -static int help(void) { - _cleanup_(table_unrefp) Table *options = NULL; - int r; - - r = option_parser_get_help_table(&options); - if (r < 0) - return r; - - help_cmdline("[OPTIONS...]"); - help_abstract("Configures basic settings of the system."); - help_section("Options"); - - r = table_print_or_warn(options); - if (r < 0) - return r; - - help_man_page_reference("systemd-firstboot", "1"); - return 0; -} - static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); @@ -1409,7 +1394,7 @@ static int parse_argv(int argc, char *argv[]) { switch (c) { OPTION_COMMON_HELP: - return help(); + return command_print_help("systemd-firstboot"); OPTION_COMMON_VERSION: return version(); @@ -1628,6 +1613,9 @@ static int parse_argv(int argc, char *argv[]) { OPTION_LONG("reset", NULL, "Remove existing files"): arg_reset = true; break; + + OPTION_COMMON_INTROSPECT_CLI: + return introspect_cli(SD_JSON_FORMAT_OFF); } if (arg_delete_root_password && (arg_copy_root_password || arg_root_password || arg_prompt_root_password)) diff --git a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh index c132141fe6..2ba5f16620 100755 --- a/test/units/TEST-74-AUX-UTILS.introspect-cli.sh +++ b/test/units/TEST-74-AUX-UTILS.introspect-cli.sh @@ -16,6 +16,7 @@ INTROSPECTABLE=( systemd-ask-password systemd-backlight systemd-dissect + systemd-firstboot systemd-id128 systemd-notify systemd-veritysetup