Browse Source

auc: fix several issues

* don't segfault if server reply is incomplete
 * always request 'generic' image on x86/generic and x86/64
 * make SNAPSHOT branches sticky, eg. stay on 21.02-SNAPSHOT and do
   not 'upgrade' to 21.02.0-rc2.
 * output requested server URL when debugging

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
lilik-openwrt-22.03
Daniel Golle 3 years ago
parent
commit
02bc1fc929
1 changed files with 31 additions and 9 deletions
  1. +31
    -9
      utils/auc/src/auc.c

+ 31
- 9
utils/auc/src/auc.c View File

@ -532,12 +532,6 @@ static void board_cb(struct ubus_request *req, int type, struct blob_attr *msg)
blobmsg_parse(board_policy, __BOARD_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[BOARD_BOARD_NAME]) {
fprintf(stderr, "No board name received\n");
rc=-ENODATA;
return;
}
board_name = strdup(blobmsg_get_string(tb[BOARD_BOARD_NAME]));
if (!tb[BOARD_RELEASE]) {
fprintf(stderr, "No release received\n");
@ -562,6 +556,21 @@ static void board_cb(struct ubus_request *req, int type, struct blob_attr *msg)
version = strdup(blobmsg_get_string(rel[RELEASE_VERSION]));
revision = strdup(blobmsg_get_string(rel[RELEASE_REVISION]));
if (!strcmp(target, "x86/64") || !strcmp(target, "x86/generic")) {
/*
* ugly work-around ahead:
* ignore board name on generic x86 targets, as image name is always 'generic'
*/
board_name = strdup("generic");
} else {
if (!tb[BOARD_BOARD_NAME]) {
fprintf(stderr, "No board name received\n");
rc=-ENODATA;
return;
}
board_name = strdup(blobmsg_get_string(tb[BOARD_BOARD_NAME]));
}
blobmsg_add_string(buf, "distro", distribution);
blobmsg_add_string(buf, "target", target);
blobmsg_add_string(buf, "version", version);
@ -856,6 +865,11 @@ static int server_request(const char *url, struct blob_buf *inbuf, struct blob_b
out_bytes = 0;
out_len = 0;
#ifdef AUC_DEBUG
if (debug)
fprintf(stderr, "Requesting URL: %s\n", url);
#endif
if (outbuf) {
jsb = malloc(sizeof(struct jsonblobber));
jsb->outbuf = outbuf;
@ -1191,8 +1205,16 @@ static struct branch *select_branch(char *name, char *select_version)
break;
}
} else {
if (!abr || (strcmp(br->version, abr->version) > 0))
abr = br;
/* if we are on a snapshot branch, stay there */
if (strcasestr(version, "snapshot")) {
if (strcasestr(br->version, "snapshot")) {
abr = br;
break;
}
} else {
if (!abr || (verrevcmp(br->version, abr->version) > 0))
abr = br;
}
}
}
@ -1393,7 +1415,7 @@ int main(int args, char *argv[]) {
char url[256];
char *sanetized_board_name, *image_name, *image_sha256, *tmp;
struct blob_attr *tbr[__REPLY_MAX];
struct blob_attr *tb[__TARGET_MAX];
struct blob_attr *tb[__TARGET_MAX] = {}; /* make sure tb is NULL initialized even if blobmsg_parse isn't called */
struct stat imgstat;
int check_only = 0;
int retry_delay = 0;


Loading…
Cancel
Save