From 2640f5dcd03d93966244b1501c457b11d2fd3568 Mon Sep 17 00:00:00 2001 From: Thomas Perale Date: Wed, 6 Aug 2025 22:06:31 +0200 Subject: [PATCH] package/libapparmor: fix build w/ musl When building the libapparmor package with musl the following error would appear: ``` test_multi.c: In function 'main': test_multi.c:27:30: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration] 27 | printf("File: %s\n", basename(argv[1])); | ^~~~~~~~ test_multi.c:27:24: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat=] 27 | printf("File: %s\n", basename(argv[1])); | ~^ ~~~~~~~~~~~~~~~~~ | | | | | int | char * | %d make[3]: *** [Makefile:466: test_multi_multi-test_multi.o] Error 1 ``` This error can be reproduced with the following: ``` cat >.config < [Peter: drop unrelated AUTORECONF change] Signed-off-by: Peter Korsgaard --- ...e-a-portable-version-of-gnu-basename.patch | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 package/libapparmor/0001-libapparamor-define-a-portable-version-of-gnu-basename.patch diff --git a/package/libapparmor/0001-libapparamor-define-a-portable-version-of-gnu-basename.patch b/package/libapparmor/0001-libapparamor-define-a-portable-version-of-gnu-basename.patch new file mode 100644 index 0000000000..c068279853 --- /dev/null +++ b/package/libapparmor/0001-libapparamor-define-a-portable-version-of-gnu-basename.patch @@ -0,0 +1,44 @@ +From 7fb040bde69ebdfce48cf1a01c1a62fd4f8eef0a Mon Sep 17 00:00:00 2001 +From: Jules Maselbas +Date: Thu, 16 May 2024 12:01:00 +0200 +Subject: [PATCH] libapparamor: Define a portable version of gnu basename + +Since musl 1.2.5, basename(3) prototype is only provided in libgen.h +(as mandated by POSIX) and not in strings.h. Also there is a major +difference between the gnu basename and the one defined in libgen.h, +the latter modify the argument string making them incompatible. + +Fix this by defining a portable version of basename using strchr. + +Upstream: https://gitlab.com/apparmor/apparmor/-/commit/7fb040bde69ebdfce48cf1a01c1a62fd4f8eef0a +Signed-off-by: Thomas Perale +--- + libraries/libapparmor/testsuite/test_multi.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/libraries/libapparmor/testsuite/test_multi.c b/libraries/libapparmor/testsuite/test_multi.c +index 578629500..7f37966ec 100644 +--- a/libraries/libapparmor/testsuite/test_multi.c ++++ b/libraries/libapparmor/testsuite/test_multi.c +@@ -1,5 +1,3 @@ +-#define _GNU_SOURCE /* for glibc's basename version */ +- + #include + #include + #include +@@ -7,6 +5,12 @@ + + #include + ++static const char *basename(const char *path) ++{ ++ const char *p = strrchr(path, '/'); ++ return p ? p + 1 : path; ++} ++ + int print_results(aa_log_record *record); + + int main(int argc, char **argv) +-- +GitLab +