Verified Commit 0e6fb8db authored by Karel Koci's avatar Karel Koci 🤘

pkgupdate: do not replan in combination of reinstall-all

--reinstall-all and replan together causes infinite reinstall loop. This
solves it simply by just not replanning in case of reinstall.

This also adds handlers for missed argument options.
parent 02e9d383
Pipeline #47287 passed with stage
in 3 minutes and 39 seconds
......@@ -12,7 +12,6 @@ enum option_val_prg {
OPT_REINSTALL_ALL,
OPT_ASK_APPROVAL,
OPT_APPROVE,
OPT_TASKLOG,
OPT_NO_REPLAN,
OPT_NO_IMMEDIATE_REBOOT,
OPT_OUT_OF_ROOT,
......@@ -24,12 +23,14 @@ enum option_val_prg {
static struct argp_option options[] = {
{"batch", OPT_BATCH_VAL, NULL, 0, "Run without user confirmation.", 0},
{"reinstall-all", OPT_REINSTALL_ALL, NULL, 0, "Reinstall packages that are already installed in latest version.", 0},
{"reinstall-all", OPT_REINSTALL_ALL, NULL, 0, "Reinstall packages that are already installed in latest version. This implies --no-replan to break reinstall-replan loop.", 0},
{"ask-approval", OPT_ASK_APPROVAL, "FILE", 0, "Require user's approval to proceed (abort if --approve with appropriate ID is not present, plan of action is put into the FILE if approval is needed)", 1},
{"approve", OPT_APPROVE, "HASH", 0, "Approve actions with given HASH (multiple allowed).", 1},
{"no-replan", OPT_NO_REPLAN, NULL, 0, "Don't replan. Install everyting at once. Use this if updater you are running isn't from packages it installs.", 2},
{"no-immediate-reboot", OPT_NO_IMMEDIATE_REBOOT, NULL, 0, "Don't reboot immediately. Just ignore immediate reboots. This is usable if you are not running on target machine.", 2},
{"out-of-root", OPT_OUT_OF_ROOT, NULL, 0, "We are running updater out of root filesystem. This implies --no-replan and --no-immediate-reboot and is suggested to be used with --root option.", 2},
{"task-log", OPT_TASK_LOG, "FILE", 0, "Append list of executed tasks into a log file.", 2},
{"state-log", OPT_STATE_LOG, NULL, 0, "Dump state to files in /tmp/updater-state directory", 2},
{"task-log", OPT_TASK_LOG, "FILE", 0, "Append list of executed tasks into a log file.", 3},
{"state-log", OPT_STATE_LOG, NULL, 0, "Dump state to files in /tmp/updater-state directory", 3},
// Following options are internal
{"reexec", OPT_REEXEC, NULL, OPTION_HIDDEN, "", 0},
{"reboot-finished", OPT_REBOOT_FINISHED, NULL, OPTION_HIDDEN, "", 0},
......@@ -52,6 +53,16 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
opts->approve = realloc(opts->approve, (++opts->approve_cnt) * sizeof *opts->approve);
opts->approve[opts->approve_cnt - 1] = arg;
break;
case OPT_NO_REPLAN:
opts->no_replan = true;
break;
case OPT_NO_IMMEDIATE_REBOOT:
opts->no_immediate_reboot = true;
break;
case OPT_OUT_OF_ROOT:
opts->no_replan = true;
opts->no_immediate_reboot = true;
break;
case OPT_TASK_LOG:
opts->task_log = arg;
break;
......
......@@ -134,7 +134,7 @@ int main(int argc, char *argv[]) {
bool trans_ok = true;
size_t result_count;
// Set some configuration
if (opts.no_replan) {
if (opts.no_replan || opts.reinstall_all) {
err = interpreter_call(interpreter, "updater.disable_replan", NULL, "");
ASSERT_MSG(!err, "%s", err);
}
......
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