From 750c8671cdbcdb6fdda39094276c7e4420da15f7 Mon Sep 17 00:00:00 2001 From: lemoer Date: Sat, 12 May 2018 03:56:25 +0200 Subject: [PATCH] autoupdater: allow skipping the versioncheck This commit introduces a new cli flag "--no-versioncheck" --- 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..78fdc7a 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" + " --no-versioncheck Skip version check and allow downgrades therefore.\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_NO_VERSIONCHECK = 255, }; 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}, + {"no-versioncheck", no_argument, NULL, OPTION_NO_VERSIONCHECK}, {"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_NO_VERSIONCHECK: + settings->no_versioncheck = 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->no_versioncheck) { 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..5959364 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 no_versioncheck; const char *branch; unsigned long good_signatures; char *old_version;