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:
committed by
Luca Boccassi
parent
095e677436
commit
19e40a6de9
@@ -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.");
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user