From ed7ed7dcbaf012be9d207fae1b51cf88f7cdb9fb Mon Sep 17 00:00:00 2001 From: lemoer Date: Sun, 3 Jun 2018 12:13:50 +0200 Subject: [PATCH] autoupdater: allow skipping the version check (#187) this commit introduces a new cli flag "--force-version" --- admin/autoupdater/src/autoupdater.c | 9 ++++++++- admin/autoupdater/src/settings.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/admin/autoupdater/src/autoupdater.c b/admin/autoupdater/src/autoupdater.c index 177e5d7..04f80ed 100644 --- a/admin/autoupdater/src/autoupdater.c +++ b/admin/autoupdater/src/autoupdater.c @@ -86,6 +86,7 @@ static void usage(void) { " really flash a new firmware if one is available.\n\n" " --fallback Upgrade if and only if the upgrade timespan of the new\n" " version has passed for at least 24 hours.\n\n" + " --force-version Skip version check to allow downgrades.\n\n" " ... Override the mirror URLs given in the configuration. If\n" " specified, these are not shuffled.\n\n", stderr @@ -100,6 +101,7 @@ static void parse_args(int argc, char *argv[], struct settings *settings) { OPTION_HELP = 'h', OPTION_NO_ACTION = 'n', OPTION_FALLBACK = 256, + OPTION_FORCE_VERSION = 257, }; const struct option options[] = { @@ -107,6 +109,7 @@ static void parse_args(int argc, char *argv[], struct settings *settings) { {"force", no_argument, NULL, OPTION_FORCE}, {"fallback", no_argument, NULL, OPTION_FALLBACK}, {"no-action", no_argument, NULL, OPTION_NO_ACTION}, + {"force-version", no_argument, NULL, OPTION_FORCE_VERSION}, {"help", no_argument, NULL, OPTION_HELP}, }; @@ -136,6 +139,10 @@ static void parse_args(int argc, char *argv[], struct settings *settings) { settings->no_action = true; break; + case OPTION_FORCE_VERSION: + settings->force_version = true; + break; + default: usage(); exit(1); @@ -321,7 +328,7 @@ static bool autoupdate(const char *mirror, struct settings *s, int lock_fd) { } /* Check version and update probability */ - if (!newer_than(m->version, s->old_version)) { + if (!newer_than(m->version, s->old_version) && !s->force_version) { puts("No new firmware available."); ret = true; goto out; diff --git a/admin/autoupdater/src/settings.h b/admin/autoupdater/src/settings.h index 54b98f6..7ed68d1 100644 --- a/admin/autoupdater/src/settings.h +++ b/admin/autoupdater/src/settings.h @@ -33,6 +33,7 @@ struct settings { bool force; bool fallback; bool no_action; + bool force_version; const char *branch; unsigned long good_signatures; char *old_version;