sysupdate: address review feedback on component/reboot guard

Move the --reboot/--component= rejection into parse_argv() alongside the
other cross-option checks, and tighten TEST-72 to assert the specific
guard message rather than merely a non-zero exit.
This commit is contained in:
Armaan Sandhu
2026-06-19 19:52:24 +01:00
committed by Luca Boccassi
parent 095e677436
commit 19e40a6de9
2 changed files with 6 additions and 7 deletions
+3 -4
View File
@@ -1555,10 +1555,6 @@ static int verb_update_impl(int argc, char **argv, UpdateActionFlags action_flag
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"The --instances-max argument must be >= 2 while updating");
if (arg_reboot && arg_component)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"The --reboot switch may not be combined with --component=, as automatic reboots only apply to the booted OS version.");
if (arg_reboot) {
/* If automatic reboot on completion is requested, let's first determine the currently booted image */
@@ -2023,6 +2019,9 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
if ((arg_image || arg_root) && arg_reboot)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The --reboot switch may not be combined with --root= or --image=.");
if (arg_reboot && arg_component)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The --reboot switch may not be combined with --component=, as automatic reboots only apply to the booted OS version.");
if (arg_definitions && arg_component)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The --definitions= and --component= switches may not be combined.");
+3 -3
View File
@@ -584,9 +584,9 @@ mkdir /run/sysupdate.d
# version against the booted OS version (IMAGE_VERSION= from os-release), which is
# unrelated to component versions. Selecting a component must therefore be refused
# rather than silently performing a bogus comparison.
(! "$SYSUPDATE" --component=some-component pending)
(! "$SYSUPDATE" --component=some-component reboot)
(! "$SYSUPDATE" --component=some-component update --reboot)
(! "$SYSUPDATE" --component=some-component pending) |& grep -F 'may not be combined' >/dev/null
(! "$SYSUPDATE" --component=some-component reboot) |& grep -F 'may not be combined' >/dev/null
(! "$SYSUPDATE" --component=some-component update --reboot) |& grep -F 'may not be combined' >/dev/null
# Clean up regression test
rmdir /run/sysupdate.d