diff options
| author | Eric Fahlgren | 2025-06-05 17:16:39 +0000 |
|---|---|---|
| committer | Robert Marko | 2025-06-22 08:03:24 +0000 |
| commit | 9389775ceb4702c82bd62b79cf17b0359c63e527 (patch) | |
| tree | acb67f7e05cdffb85019dde35ba5babba5ded8d6 | |
| parent | ed0d01e4360b4a81687380e0d83ddc18bb3f4c0b (diff) | |
| download | rpcd-9389775ceb4702c82bd62b79cf17b0359c63e527.tar.gz | |
rpc-sys: update packagelist call to handle apk abiversion tag
Handle the custom tag containing ABI version information and apply it
to the list of package names.
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Link: https://github.com/openwrt/rpcd/pull/12
Signed-off-by: Robert Marko <robimarko@gmail.com>
| -rw-r--r-- | sys.c | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -205,17 +205,18 @@ rpc_sys_packagelist(struct ubus_context *ctx, struct ubus_object *obj, struct blob_attr *tb[__RPC_PACKAGELIST_MAX]; bool all = false; struct blob_buf buf = { 0 }; - char line[256], pkg[128], ver[128]; + char line[256], abi[128], pkg[128], ver[128]; void *tbl; struct stat statbuf; const char **world = NULL; char *world_mmap = NULL; size_t world_mmap_size = 0; + char *token = NULL; /* * Status file fields, /usr/lib/opkg/status vs /lib/apk/db/installed * opkg apk - * PACKAGE_ABIVERSION "ABIVersion" no equivalent - see BUG, below + * PACKAGE_ABIVERSION "ABIVersion" "g:openwrt:abiversion=" * PACKAGE_AUTOINSTALLED "Auto-Installed" package listed in 'world', not a db field * PACKAGE_NAME "Package" "P" * PACKAGE_STATUS "Status" package listed in db, not a status value @@ -290,7 +291,7 @@ rpc_sys_packagelist(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(&buf, 0); tbl = blobmsg_open_table(&buf, "packages"); - pkg[0] = ver[0] = '\0'; + abi[0] = pkg[0] = ver[0] = '\0'; while (fgets(line, sizeof(line), f)) { switch (line[0]) { @@ -302,18 +303,27 @@ rpc_sys_packagelist(struct ubus_context *ctx, struct ubus_object *obj, if (sscanf(line, "V: %127s", ver) != 1) ver[0] = '\0'; break; + case 'g': + /* this is a custom tag, defined in include/package-pack.mk */ + token = strtok(line+2, " =\n"); + while (token) { + if (strcmp(token, "openwrt:abiversion") == 0) { + token = strtok(NULL, " =\n"); + if (token) + strlcpy(abi, token, sizeof(abi)); + break; + } + token = strtok(NULL, " =\n"); + } + break; default: if (is_blank(line)) { if (pkg[0] && ver[0] && is_all_or_world(pkg, world)) { - /* BUG: There's no ABI version info in any of - * the apk files, so some of the returned file - * names contain ABI-versioning. - * - * If you had that information, you'd apply it here. - */ + if (abi[0]) + pkg[strlen(pkg)-strlen(abi)] = '\0'; blobmsg_add_string(&buf, pkg, ver); } - pkg[0] = ver[0] = '\0'; + abi[0] = pkg[0] = ver[0] = '\0'; } break; } |