auc: update to version 0.1.8
authorDaniel Golle <daniel@makrotopia.org>
Wed, 30 Jun 2021 00:38:50 +0000 (01:38 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Wed, 30 Jun 2021 00:40:37 +0000 (01:40 +0100)
This fixes support for x86, auc now selects the right combined image
depending on the system being booted in EFI mode or not.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
utils/auc/Makefile
utils/auc/src/auc.c

index 58e026a8d807490cfd94c2e0dce1a4ab334186bb..406cb4cf2dbfc5e8d200c1e72405c2bc8e98746f 100644 (file)
@@ -5,7 +5,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=auc
-PKG_VERSION:=0.1.7
+PKG_VERSION:=0.1.8
 PKG_RELEASE:=$(AUTORELEASE)
 PKG_LICENSE:=GPL-3.0
 
index ebda3eed8cd17d7d70ed934f62f87dba1b037573..ea144e4ffdc43186624f2e86121b480b049df0f8 100644 (file)
@@ -1356,7 +1356,24 @@ static int req_add_selected_packages(struct blob_buf *req)
        return 0;
 }
 
-static int select_image(struct blob_attr *images, char **image_name, char **image_sha256)
+#if defined(__amd64__) || defined(__i386__)
+static int system_is_efi(void)
+{
+       const char efidname[] = "/sys/firmware/efi/efivars";
+       int fd = open(efidname, O_DIRECTORY | O_PATH);
+
+       if (fd != -1) {
+               close(fd);
+               return 1;
+       } else {
+               return 0;
+       }
+}
+#else
+static inline int system_is_efi(void) { return 0; }
+#endif
+
+static int get_image_by_type(struct blob_attr *images, const char *typestr, char **image_name, char **image_sha256)
 {
        struct blob_attr *tb[__IMAGES_MAX];
        struct blob_attr *cur;
@@ -1370,7 +1387,7 @@ static int select_image(struct blob_attr *images, char **image_name, char **imag
                    !tb[IMAGES_SHA256])
                        continue;
 
-               if (!strcmp(blobmsg_get_string(tb[IMAGES_TYPE]), "sysupgrade")) {
+               if (!strcmp(blobmsg_get_string(tb[IMAGES_TYPE]), typestr)) {
                        *image_name = strdup(blobmsg_get_string(tb[IMAGES_NAME]));
                        *image_sha256 = strdup(blobmsg_get_string(tb[IMAGES_SHA256]));
                        ret = 0;
@@ -1381,6 +1398,27 @@ static int select_image(struct blob_attr *images, char **image_name, char **imag
        return ret;
 }
 
+static int select_image(struct blob_attr *images, char **image_name, char **image_sha256)
+{
+       const char *combined_type;
+       int ret;
+
+       if (system_is_efi())
+               combined_type = "combined-efi";
+       else
+               combined_type = "combined";
+
+       DPRINTF("images: %s\n", blobmsg_format_json_indent(images, true, 0));
+
+       ret = get_image_by_type(images, "sysupgrade", image_name, image_sha256);
+       if (!ret)
+               return 0;
+
+       ret = get_image_by_type(images, combined_type, image_name, image_sha256);
+
+       return ret;
+}
+
 static bool validate_sha256(char *filename, char *sha256str)
 {
        char *cmd = calloc(strlen(SHA256SUM) + 1 + strlen(filename) + 1, sizeof(char));