autoupdater: allow skipping the versioncheck

This commit introduces a new cli flag "--no-versioncheck"
This commit is contained in:
lemoer 2018-05-12 03:56:25 +02:00
parent 6c38a5dd63
commit 750c8671cd
2 changed files with 9 additions and 1 deletions

View File

@ -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"
" <mirror> ... 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;

View File

@ -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;