Re: [OE-core] [master][kirkstone][PATCH] efivar: add musl libc compatibility
Greetings, I’m here to flag that this patch has not yet landed to kirkstone-nut, is there any reason why? Davide > Il giorno 24 mag 2022, alle ore 10:04, Davide Gardenal > ha scritto: > > Backport patch to get efivar working with musl. > > Upstream issue: > https://github.com/rhboot/efivar/issues/202 > > After commit meta-oe/1582f81805ee3114bc1a44bd5cf52d21f96702ca > fwupd gives an error when trying to build with musl because > efivar is not compatible. This fixes the issue. > > Signed-off-by: Davide Gardenal > --- > .../efisecdb-fix-build-with-musl-libc.patch | 184 ++ > meta/recipes-bsp/efivar/efivar_38.bb | 3 +- > 2 files changed, 185 insertions(+), 2 deletions(-) > create mode 100644 > meta/recipes-bsp/efivar/efivar/efisecdb-fix-build-with-musl-libc.patch > > diff --git > a/meta/recipes-bsp/efivar/efivar/efisecdb-fix-build-with-musl-libc.patch > b/meta/recipes-bsp/efivar/efivar/efisecdb-fix-build-with-musl-libc.patch > new file mode 100644 > index 00..ec5b285a06 > --- /dev/null > +++ b/meta/recipes-bsp/efivar/efivar/efisecdb-fix-build-with-musl-libc.patch > @@ -0,0 +1,184 @@ > +From cece3ffd5be2f8641eb694513f2b73e5eb97ffd3 Mon Sep 17 00:00:00 2001 > +From: Natanael Copa > +Date: Fri, 28 Jan 2022 12:13:30 +0100 > +Subject: [PATCH] efisecdb: fix build with musl libc > + > +Refactor code to use POSIX atexit(3) instead of the GNU specific > +on_exit(3). > + > +Resolves: #197 > +Resolves: #202 > +Signed-off-by: Natanael Copa > + > +Upstream-Status: Backport > +https://github.com/rhboot/efivar/commit/cece3ffd5be2f8641eb694513f2b73e5eb97ffd3 > + > +Signed-off-by: Davide Gardenal > +--- > + src/compiler.h | 2 -- > + src/efisecdb.c | 68 +++--- > + 2 files changed, 26 insertions(+), 44 deletions(-) > + > +diff --git a/src/compiler.h b/src/compiler.h > +index e2f18f0b..d95fb014 100644 > +--- a/src/compiler.h > b/src/compiler.h > +@@ -7,8 +7,6 @@ > + #ifndef COMPILER_H_ > + #define COMPILER_H_ > + > +-#include > +- > + /* GCC version checking borrowed from glibc. */ > + #if defined(__GNUC__) && defined(__GNUC_MINOR__) > + # define GNUC_PREREQ(maj,min) \ > +diff --git a/src/efisecdb.c b/src/efisecdb.c > +index f8823737..6bd5ad90 100644 > +--- a/src/efisecdb.c > b/src/efisecdb.c > +@@ -25,6 +25,10 @@ > + extern char *optarg; > + extern int optind, opterr, optopt; > + > ++static efi_secdb_t *secdb = NULL; > ++static list_t infiles; > ++static list_t actions; > ++ > + struct hash_param { > + char *name; > + efi_secdb_type_t algorithm; > +@@ -187,12 +191,11 @@ add_action(list_t *list, action_type_t action_type, > const efi_guid_t *owner, > + } > + > + static void > +-free_actions(int status UNUSED, void *actionsp) > ++free_actions(void) > + { > +-list_t *actions = (list_t *)actionsp; > + list_t *pos, *tmp; > + > +-for_each_action_safe(pos, tmp, actions) { > ++for_each_action_safe(pos, tmp, ) { > + action_t *action = list_entry(pos, action_t, list); > + > + list_del(>list); > +@@ -202,12 +205,11 @@ free_actions(int status UNUSED, void *actionsp) > + } > + > + static void > +-free_infiles(int status UNUSED, void *infilesp) > ++free_infiles(void) > + { > +-list_t *infiles = (list_t *)infilesp; > + list_t *pos, *tmp; > + > +-for_each_ptr_safe(pos, tmp, infiles) { > ++for_each_ptr_safe(pos, tmp, ) { > + ptrlist_t *entry = list_entry(pos, ptrlist_t, list); > + > + list_del(>list); > +@@ -216,27 +218,12 @@ free_infiles(int status UNUSED, void *infilesp) > + } > + > + static void > +-maybe_free_secdb(int status UNUSED, void *voidp) > ++maybe_free_secdb(void) > + { > +-efi_secdb_t **secdbp = (efi_secdb_t **)voidp; > +- > +-if (secdbp == NULL || *secdbp == NULL) > ++if (secdb == NULL) > + return; > + > +-efi_secdb_free(*secdbp); > +-} > +- > +-static void > +-maybe_do_unlink(int status, void *filep) > +-{ > +-char **file = (char **)filep; > +- > +-if (status == 0) > +-return; > +-if (file == NULL || *file == NULL) > +-return; > +- > +-unlink(*file); > ++efi_secdb_free(secdb); > + } > + > + static void > +@@ -323,15 +310,6 @@ parse_input_files(list_t *infiles, char **outfile, > efi_secdb_t **secdb, > + return status; > + } > + > +-/* > +- * These need to be static globals so that they're not on main's stack when > +- * on_exit() fires. > +- */ > +-static efi_secdb_t *secdb = NULL; > +-static list_t infiles; > +-static list_t actions; > +-static char *outfile = NULL; > +- > + int > + main(int argc, char *argv[]) > + { > +@@ -351,6 +329,7 @@ main(int argc, char *argv[]) > + bool do_sort_data = false; > + bool sort_descending = false; > + int status = 0; > ++char *outfile = NULL; > + > + const char sopts[] = ":aAc:dfg:h:i:Lo:rs:t:v?"; > + const struct option lopts[] = { > +@@ -376,10 +355,9 @@ main(int argc, char *argv[]) > +
[OE-core] [master][kirkstone][PATCH] efivar: add musl libc compatibility
Backport patch to get efivar working with musl. Upstream issue: https://github.com/rhboot/efivar/issues/202 After commit meta-oe/1582f81805ee3114bc1a44bd5cf52d21f96702ca fwupd gives an error when trying to build with musl because efivar is not compatible. This fixes the issue. Signed-off-by: Davide Gardenal --- .../efisecdb-fix-build-with-musl-libc.patch | 184 ++ meta/recipes-bsp/efivar/efivar_38.bb | 3 +- 2 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-bsp/efivar/efivar/efisecdb-fix-build-with-musl-libc.patch diff --git a/meta/recipes-bsp/efivar/efivar/efisecdb-fix-build-with-musl-libc.patch b/meta/recipes-bsp/efivar/efivar/efisecdb-fix-build-with-musl-libc.patch new file mode 100644 index 00..ec5b285a06 --- /dev/null +++ b/meta/recipes-bsp/efivar/efivar/efisecdb-fix-build-with-musl-libc.patch @@ -0,0 +1,184 @@ +From cece3ffd5be2f8641eb694513f2b73e5eb97ffd3 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Fri, 28 Jan 2022 12:13:30 +0100 +Subject: [PATCH] efisecdb: fix build with musl libc + +Refactor code to use POSIX atexit(3) instead of the GNU specific +on_exit(3). + +Resolves: #197 +Resolves: #202 +Signed-off-by: Natanael Copa + +Upstream-Status: Backport +https://github.com/rhboot/efivar/commit/cece3ffd5be2f8641eb694513f2b73e5eb97ffd3 + +Signed-off-by: Davide Gardenal +--- + src/compiler.h | 2 -- + src/efisecdb.c | 68 +++--- + 2 files changed, 26 insertions(+), 44 deletions(-) + +diff --git a/src/compiler.h b/src/compiler.h +index e2f18f0b..d95fb014 100644 +--- a/src/compiler.h b/src/compiler.h +@@ -7,8 +7,6 @@ + #ifndef COMPILER_H_ + #define COMPILER_H_ + +-#include +- + /* GCC version checking borrowed from glibc. */ + #if defined(__GNUC__) && defined(__GNUC_MINOR__) + # define GNUC_PREREQ(maj,min) \ +diff --git a/src/efisecdb.c b/src/efisecdb.c +index f8823737..6bd5ad90 100644 +--- a/src/efisecdb.c b/src/efisecdb.c +@@ -25,6 +25,10 @@ + extern char *optarg; + extern int optind, opterr, optopt; + ++static efi_secdb_t *secdb = NULL; ++static list_t infiles; ++static list_t actions; ++ + struct hash_param { + char *name; + efi_secdb_type_t algorithm; +@@ -187,12 +191,11 @@ add_action(list_t *list, action_type_t action_type, const efi_guid_t *owner, + } + + static void +-free_actions(int status UNUSED, void *actionsp) ++free_actions(void) + { +- list_t *actions = (list_t *)actionsp; + list_t *pos, *tmp; + +- for_each_action_safe(pos, tmp, actions) { ++ for_each_action_safe(pos, tmp, ) { + action_t *action = list_entry(pos, action_t, list); + + list_del(>list); +@@ -202,12 +205,11 @@ free_actions(int status UNUSED, void *actionsp) + } + + static void +-free_infiles(int status UNUSED, void *infilesp) ++free_infiles(void) + { +- list_t *infiles = (list_t *)infilesp; + list_t *pos, *tmp; + +- for_each_ptr_safe(pos, tmp, infiles) { ++ for_each_ptr_safe(pos, tmp, ) { + ptrlist_t *entry = list_entry(pos, ptrlist_t, list); + + list_del(>list); +@@ -216,27 +218,12 @@ free_infiles(int status UNUSED, void *infilesp) + } + + static void +-maybe_free_secdb(int status UNUSED, void *voidp) ++maybe_free_secdb(void) + { +- efi_secdb_t **secdbp = (efi_secdb_t **)voidp; +- +- if (secdbp == NULL || *secdbp == NULL) ++ if (secdb == NULL) + return; + +- efi_secdb_free(*secdbp); +-} +- +-static void +-maybe_do_unlink(int status, void *filep) +-{ +- char **file = (char **)filep; +- +- if (status == 0) +- return; +- if (file == NULL || *file == NULL) +- return; +- +- unlink(*file); ++ efi_secdb_free(secdb); + } + + static void +@@ -323,15 +310,6 @@ parse_input_files(list_t *infiles, char **outfile, efi_secdb_t **secdb, + return status; + } + +-/* +- * These need to be static globals so that they're not on main's stack when +- * on_exit() fires. +- */ +-static efi_secdb_t *secdb = NULL; +-static list_t infiles; +-static list_t actions; +-static char *outfile = NULL; +- + int + main(int argc, char *argv[]) + { +@@ -351,6 +329,7 @@ main(int argc, char *argv[]) + bool do_sort_data = false; + bool sort_descending = false; + int status = 0; ++ char *outfile = NULL; + + const char sopts[] = ":aAc:dfg:h:i:Lo:rs:t:v?"; + const struct option lopts[] = { +@@ -376,10 +355,9 @@ main(int argc, char *argv[]) + INIT_LIST_HEAD(); + INIT_LIST_HEAD(); + +- on_exit(free_actions, ); +- on_exit(free_infiles, ); +- on_exit(maybe_free_secdb, ); +- on_exit(maybe_do_unlink, ); ++ atexit(free_actions); ++ atexit(free_infiles); ++ atexit(maybe_free_secdb); + + /* +* parse the command line. +@@ -587,24 +565,30 @@ main(int argc, char *argv[]) + outfd = open(outfile, flags, 0600); + if