Browse Source

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 <daniel@makrotopia.org>
lilik-openwrt-22.03
Daniel Golle 3 years ago
parent
commit
2edbc4c805
No known key found for this signature in database GPG Key ID: 5A8F39C31C3217CA
2 changed files with 38 additions and 22 deletions
  1. +1
    -1
      utils/auc/Makefile
  2. +37
    -21
      utils/auc/src/auc.c

+ 1
- 1
utils/auc/Makefile View File

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=auc PKG_NAME:=auc
PKG_VERSION:=0.2.2
PKG_VERSION:=0.2.3
PKG_RELEASE:=$(AUTORELEASE) PKG_RELEASE:=$(AUTORELEASE)
PKG_LICENSE:=GPL-3.0 PKG_LICENSE:=GPL-3.0


+ 37
- 21
utils/auc/src/auc.c View File

@ -443,7 +443,9 @@ static int openwrt_release_verrevcmp(const char *ver1, const char *ver2)
char mver1[16], mver2[16]; char mver1[16], mver2[16];
strncpy(mver1, ver1, sizeof(mver1) - 1); strncpy(mver1, ver1, sizeof(mver1) - 1);
mver1[sizeof(mver1) - 1] = '\0';
strncpy(mver2, ver2, sizeof(mver2) - 1); strncpy(mver2, ver2, sizeof(mver2) - 1);
mver2[sizeof(mver2) - 1] = '\0';
release_replace_rc(mver1); release_replace_rc(mver1);
release_replace_rc(mver2); release_replace_rc(mver2);
@ -1544,6 +1546,31 @@ static inline bool status_delay(const char *status)
!strcmp(API_STATUS_STARTED, 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 <branch>] [-B <ver>] [-c] %s[-f] [-h] [-r] [-y]\n",
#ifdef AUC_DEBUG
"[-d] "
#else
""
#endif
);
fprintf(stdout, " -b <branch>\tuse specific release branch\n");
fprintf(stdout, " -B <ver>\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 <fstype>\toverride filesystem type\n");
fprintf(stdout, " -y\t\tdon't wait for user confirmation\n");
}
/* this main function is too big... todo: split */ /* this main function is too big... todo: split */
int main(int args, char *argv[]) { int main(int args, char *argv[]) {
static struct blob_buf checkbuf, infobuf, reqbuf, imgbuf, upgbuf; static struct blob_buf checkbuf, infobuf, reqbuf, imgbuf, upgbuf;
@ -1570,25 +1597,7 @@ int main(int args, char *argv[]) {
while (argc<args) { while (argc<args) {
if (!strncmp(argv[argc], "-h", 3) || if (!strncmp(argv[argc], "-h", 3) ||
!strncmp(argv[argc], "--help", 7)) { !strncmp(argv[argc], "--help", 7)) {
fprintf(stdout, "%s: Attended sysUpgrade CLI client\n", argv[0]);
fprintf(stdout, "Usage: auc [-b <branch>] [-B <ver>] [-c] %s[-f] [-h] [-r] [-y]\n",
#ifdef AUC_DEBUG
"[-d] "
#else
""
#endif
);
fprintf(stdout, " -b <branch>\tuse specific release branch\n");
fprintf(stdout, " -B <ver>\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 <fstype>\toverride filesystem type\n");
fprintf(stdout, " -y\t\tdon't wait for user confirmation\n");
usage(argv[0]);
return 0; return 0;
} }
@ -1680,7 +1689,7 @@ int main(int args, char *argv[]) {
rootfs_type, target_fstype); rootfs_type, target_fstype);
if (request_branches(!(target_branch || target_version))) { if (request_branches(!(target_branch || target_version))) {
rc=-ENETUNREACH;
rc=-ENODATA;
goto freeboard; goto freeboard;
} }
@ -1692,7 +1701,7 @@ int main(int args, char *argv[]) {
fprintf(stdout, "Available: %s %s\n", branch->version_number, branch->version_code); 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) if (revcmp < 0)
upg_check |= PKG_UPGRADE; upg_check |= PKG_UPGRADE;
else if (revcmp > 0) else if (revcmp > 0)
@ -1702,6 +1711,7 @@ int main(int args, char *argv[]) {
goto freebranches; goto freebranches;
if (release_only && !(upg_check & PKG_UPGRADE)) { if (release_only && !(upg_check & PKG_UPGRADE)) {
fprintf(stderr, "Nothing to be updated. Use '-f' to force.\n");
rc=0; rc=0;
goto freebranches; goto freebranches;
} }
@ -1724,6 +1734,12 @@ int main(int args, char *argv[]) {
goto freebranches; 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) if (check_only)
goto freebranches; goto freebranches;


Loading…
Cancel
Save