From 2edbc4c805d61d859f5e2af84293cdfb051f7f56 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 25 Aug 2021 21:20:39 +0100 Subject: [PATCH] auc: update to version 0.2.3 * use regular verrevcmp for branch names, fixes update indication * break out usage() from main() function * require '-f' in case installed package is missing in remote lists * don't use ENETUNREACH for unlrelated error Signed-off-by: Daniel Golle --- utils/auc/Makefile | 2 +- utils/auc/src/auc.c | 58 +++++++++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/utils/auc/Makefile b/utils/auc/Makefile index 7d5f883443..2160487652 100644 --- a/utils/auc/Makefile +++ b/utils/auc/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=auc -PKG_VERSION:=0.2.2 +PKG_VERSION:=0.2.3 PKG_RELEASE:=$(AUTORELEASE) PKG_LICENSE:=GPL-3.0 diff --git a/utils/auc/src/auc.c b/utils/auc/src/auc.c index 227cbfdb82..2b7a430c72 100644 --- a/utils/auc/src/auc.c +++ b/utils/auc/src/auc.c @@ -443,7 +443,9 @@ static int openwrt_release_verrevcmp(const char *ver1, const char *ver2) char mver1[16], mver2[16]; strncpy(mver1, ver1, sizeof(mver1) - 1); + mver1[sizeof(mver1) - 1] = '\0'; strncpy(mver2, ver2, sizeof(mver2) - 1); + mver2[sizeof(mver2) - 1] = '\0'; release_replace_rc(mver1); release_replace_rc(mver2); @@ -1544,6 +1546,31 @@ static inline bool status_delay(const char *status) !strcmp(API_STATUS_STARTED, status); } +static void usage(const char *arg0) +{ + fprintf(stdout, "%s: Attended sysUpgrade CLI client\n", arg0); + fprintf(stdout, "Usage: auc [-b ] [-B ] [-c] %s[-f] [-h] [-r] [-y]\n", +#ifdef AUC_DEBUG +"[-d] " +#else +"" +#endif + ); + fprintf(stdout, " -b \tuse specific release branch\n"); + fprintf(stdout, " -B \tuse specific release version\n"); + fprintf(stdout, " -c\t\tonly check if system is up-to-date\n"); +#ifdef AUC_DEBUG + fprintf(stdout, " -d\t\tenable debugging output\n"); +#endif + fprintf(stdout, " -f\t\tuse force\n"); + fprintf(stdout, " -h\t\toutput help\n"); + fprintf(stdout, " -r\t\tcheck only for release upgrades\n"); + fprintf(stdout, " -F \toverride filesystem type\n"); + fprintf(stdout, " -y\t\tdon't wait for user confirmation\n"); + +} + + /* this main function is too big... todo: split */ int main(int args, char *argv[]) { static struct blob_buf checkbuf, infobuf, reqbuf, imgbuf, upgbuf; @@ -1570,25 +1597,7 @@ int main(int args, char *argv[]) { while (argc] [-B ] [-c] %s[-f] [-h] [-r] [-y]\n", -#ifdef AUC_DEBUG -"[-d] " -#else -"" -#endif - ); - fprintf(stdout, " -b \tuse specific release branch\n"); - fprintf(stdout, " -B \tuse specific release version\n"); - fprintf(stdout, " -c\t\tonly check if system is up-to-date\n"); -#ifdef AUC_DEBUG - fprintf(stdout, " -d\t\tenable debugging output\n"); -#endif - fprintf(stdout, " -f\t\tuse force\n"); - fprintf(stdout, " -h\t\toutput help\n"); - fprintf(stdout, " -r\t\tcheck only for release upgrades\n"); - fprintf(stdout, " -F \toverride filesystem type\n"); - fprintf(stdout, " -y\t\tdon't wait for user confirmation\n"); + usage(argv[0]); return 0; } @@ -1680,7 +1689,7 @@ int main(int args, char *argv[]) { rootfs_type, target_fstype); if (request_branches(!(target_branch || target_version))) { - rc=-ENETUNREACH; + rc=-ENODATA; goto freeboard; } @@ -1692,7 +1701,7 @@ int main(int args, char *argv[]) { fprintf(stdout, "Available: %s %s\n", branch->version_number, branch->version_code); - revcmp = openwrt_release_verrevcmp(revision, branch->version_code); + revcmp = verrevcmp(revision, branch->version_code); if (revcmp < 0) upg_check |= PKG_UPGRADE; else if (revcmp > 0) @@ -1702,6 +1711,7 @@ int main(int args, char *argv[]) { goto freebranches; if (release_only && !(upg_check & PKG_UPGRADE)) { + fprintf(stderr, "Nothing to be updated. Use '-f' to force.\n"); rc=0; goto freebranches; } @@ -1724,6 +1734,12 @@ int main(int args, char *argv[]) { goto freebranches; }; + if (!force && (upg_check & PKG_NOT_FOUND)) { + fprintf(stderr, "Not all installed packages found in remote lists. Use '-f' to force.\n"); + rc=-ENOTRECOVERABLE; + goto freebranches; + }; + if (check_only) goto freebranches; -- 2.30.2