sys: packagelist: drop ABI version from package name
authorDaniel Golle <daniel@makrotopia.org>
Wed, 10 Mar 2021 22:45:51 +0000 (22:45 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 11 Mar 2021 00:17:58 +0000 (00:17 +0000)
Having the ABI version appended to the package name is not very helpful
when checking for updated versions of a package online or requesting
a new image for the device from an updater service. In both cases,
the ABI version could have been bumped meanwhile and that name is then
simply not found.
Resolve this by removing the appended ABI version in the output of the
rpc-sys packagelist call.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
sys.c

diff --git a/sys.c b/sys.c
index fecf66cb2e722ad2b1a227c1624488866a2cc3bd..69daa1b02aeb343646202265bd0316abd70f010c 100644 (file)
--- a/sys.c
+++ b/sys.c
@@ -228,6 +228,18 @@ procstr:
                        continue;
                }
 
+               /* If there is ABIVersion, remove that suffix */
+               if (!strcmp(var, "ABIVersion:")) {
+                       if (strlen(pkg) <= strlen(p1))
+                               continue;
+                       tmp = &pkg[strlen(pkg) - strlen(p1)];
+                       if (strncmp(p1, tmp, strlen(p1)))
+                               continue;
+
+                       *tmp = '\0';
+                       continue;
+               }
+
                if (!strcmp(var, "Version:")) {
                        strncpy(ver, p1, sizeof(ver));
                        continue;