From 123ddf66aee4d93f2b532e42084ccf8190516d4a Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 13 Nov 2017 00:39:30 +0100 Subject: [PATCH] auc: small improvements Detect if calling rpc-sys packagelist fails due to the method not being provided by rpcd. Mark package as experimental. Signed-off-by: Daniel Golle --- utils/auc/Makefile | 4 ++-- utils/auc/src/auc.c | 31 +++++++++---------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/utils/auc/Makefile b/utils/auc/Makefile index 731b34be8b..dcbf92c96d 100644 --- a/utils/auc/Makefile +++ b/utils/auc/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=auc -PKG_VERSION:=0.0.1 +PKG_VERSION:=0.0.2 PKG_RELEASE=1 PKG_LICENSE:=GPL-3.0 @@ -15,7 +15,7 @@ include $(INCLUDE_DIR)/cmake.mk define Package/auc SECTION:=base CATEGORY:=Base system - TITLE:=attended sysupgrade (CLI version) + TITLE:=Attended sysUpgrade CLI (EXPERIMENTAL) DEPENDS:=+attendedsysupgrade-common +libblobmsg-json +libubox +libubus \ +libuci +libuclient +rpcd-mod-rpcsys endef diff --git a/utils/auc/src/auc.c b/utils/auc/src/auc.c index e7a3c8a7d1..7c344e894a 100644 --- a/utils/auc/src/auc.c +++ b/utils/auc/src/auc.c @@ -683,17 +683,15 @@ int main(int args, char *argv[]) { blobmsg_buf_init(&imgbuf); blobmsg_buf_init(&upgbuf); - if (!ubus_lookup_id(ctx, "system", &id)) { - ubus_invoke(ctx, id, "board", NULL, board_cb, &checkbuf, 3000); - } else { + if (ubus_lookup_id(ctx, "system", &id) || + ubus_invoke(ctx, id, "board", NULL, board_cb, &checkbuf, 3000)) { fprintf(stderr, "cannot request board info from procd\n"); rc=-1; goto freebufs; } - if (!ubus_lookup_id(ctx, "rpc-sys", &id)) { - ubus_invoke(ctx, id, "packagelist", NULL, pkglist_cb, &checkbuf, 3000); - } else { + if (ubus_lookup_id(ctx, "rpc-sys", &id) || + ubus_invoke(ctx, id, "packagelist", NULL, pkglist_cb, &checkbuf, 3000)) { fprintf(stderr, "cannot request packagelist from rpcd\n"); rc=-1; goto freeboard; @@ -741,10 +739,7 @@ int main(int args, char *argv[]) { } if (retry || queuepos) { - if (imgbuf.buf) - free(imgbuf.buf); - - memset(&imgbuf, '\0', sizeof(imgbuf)); + blob_buf_free(&imgbuf); blobmsg_buf_init(&imgbuf); sleep(3); } @@ -828,19 +823,11 @@ freeboard: free(version); free(revision); - freebufs: - if (checkbuf.buf) - free(checkbuf.buf); - - if (reqbuf.buf) - free(reqbuf.buf); - - if (imgbuf.buf) - free(imgbuf.buf); - - if (upgbuf.buf) - free(upgbuf.buf); + blob_buf_free(&checkbuf); + blob_buf_free(&reqbuf); + blob_buf_free(&imgbuf); + blob_buf_free(&upgbuf); freessl: if (ssl_ctx) -- 2.30.2