From 1204cb82f9af803c4045527576bb9f317b9a20b6 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 30 Jun 2021 01:38:50 +0100 Subject: [PATCH] auc: update to version 0.1.8 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 --- utils/auc/Makefile | 2 +- utils/auc/src/auc.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/utils/auc/Makefile b/utils/auc/Makefile index 58e026a8d8..406cb4cf2d 100644 --- a/utils/auc/Makefile +++ b/utils/auc/Makefile @@ -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 diff --git a/utils/auc/src/auc.c b/utils/auc/src/auc.c index ebda3eed8c..ea144e4ffd 100644 --- a/utils/auc/src/auc.c +++ b/utils/auc/src/auc.c @@ -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));