Verified Commit 8089fc51 authored by Karel Koci's avatar Karel Koci 🤘

pkgupdate: fix --no-reboot causing reboot

In rewrite to argp the --no-reboot and --reboot-required options were
mangled together and that meant that reboot was happening always when
reboot was disabled. How unfortunate.
parent b9ac3ebd
Pipeline #47369 passed with stage
in 8 minutes and 36 seconds
......@@ -58,6 +58,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
break;
case OPT_NO_IMMEDIATE_REBOOT:
opts->no_immediate_reboot = true;
system_reboot_disable();
break;
case OPT_OUT_OF_ROOT:
opts->no_replan = true;
......@@ -73,8 +74,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
opts->reexec = true;
break;
case OPT_REBOOT_FINISHED:
opts->no_immediate_reboot = true;
system_reboot_disable();
opts->reboot_finished = true;
break;
case ARGP_KEY_ARG:
if (!opts->config) {
......
......@@ -33,6 +33,7 @@ struct opts {
bool no_immediate_reboot; // --no-immediate-reboot
const char *config; // CONFIG
bool reexec; // --reexec
bool reboot_finished; // --reboot-finished
};
extern struct argp argp_parser;
......
......@@ -119,6 +119,7 @@ int main(int argc, char *argv[]) {
.no_immediate_reboot = false,
.config = NULL,
.reexec = false,
.reboot_finished = false,
};
argp_parse (&argp_parser, argc, argv, 0, 0, &opts);
......@@ -205,12 +206,12 @@ int main(int argc, char *argv[]) {
err = interpreter_call(interpreter, "updater.pre_cleanup", NULL, "");
ASSERT_MSG(!err, "%s", err);
bool reboot_delayed;
ASSERT(interpreter_collect_results(interpreter, "bb", &reboot_delayed, &opts.no_immediate_reboot) == -1);
ASSERT(interpreter_collect_results(interpreter, "bb", &reboot_delayed, &opts.reboot_finished) == -1);
if (reboot_delayed) {
const char *hook_path = aprintf("%s%s", root_dir(), hook_reboot_delayed);
exec_hook(hook_path, "Executing reboot_required hook");
}
err = interpreter_call(interpreter, "updater.cleanup", NULL, "bb", opts.no_immediate_reboot);
err = interpreter_call(interpreter, "updater.cleanup", NULL, "bb", opts.reboot_finished);
ASSERT_MSG(!err, "%s", err);
if (opts.task_log) {
FILE *log = fopen(opts.task_log, "a");
......@@ -230,7 +231,7 @@ CLEANUP:
interpreter_destroy(interpreter);
events_destroy(events);
arg_backup_clear();
if (opts.no_immediate_reboot)
if (opts.reboot_finished)
system_reboot(false);
if (trans_ok) {
update_state(LS_EXIT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment