elogind: fix build on musl without basename compatibility decl

musl provided a compatibility basename declaration so applications
expecting GNU basename could still compile even though musl doesn't provide
GNU basename and only POSIX basename.

Prevent build failure when this is removed.
This commit is contained in:
oreo639 2024-01-27 01:25:29 -08:00
parent 0bd3211595
commit 984d973746
2 changed files with 43 additions and 1 deletions

View file

@ -0,0 +1,42 @@
Add missing include for POSIX basename, since systemd-logind expects basename in string.h
diff -rup src/basic/musl_missing.h.orig src/basic/musl_missing.h
--- a/src/basic/musl_missing.h
+++ b/src/basic/musl_missing.h
@@ -56,6 +54,10 @@ void elogind_set_program_name(const char
} ) )
#endif
+/* Poor man's basename */
+#define basename(path) \
+ (strrchr(path, '/') ? strrchr(path, '/')+1 : path)
+
/* getnameinfo(3) glibc extensions are undefined in musl libc */
#define NI_IDN 0
#define NI_IDN_USE_STD3_ASCII_RULES 0
From c8d96ff2b87b8dfb8d521d4c2e6fb57992dbf659 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 21 Dec 2022 16:13:23 +0100
Subject: [PATCH] tests: we don't actually use basename() anymore
---
src/shared/tests.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/shared/tests.c b/src/shared/tests.c
index 5a05daa643..9d8bbeea79 100644
--- a/src/shared/tests.c
+++ b/src/shared/tests.c
@@ -7,12 +7,6 @@
#include <sys/mount.h>
#include <sys/wait.h>
-/* When we include libgen.h because we need dirname() we immediately
- * undefine basename() since libgen.h defines it as a macro to the POSIX
- * version which is really broken. We prefer GNU basename(). */
-#include <libgen.h>
-#undef basename
-
#include "sd-bus.h"
#include "alloc-util.h"

View file

@ -1,7 +1,7 @@
# Template file for 'elogind'
pkgname=elogind
version=252.9
revision=1
revision=2
build_style=meson
configure_args="-Dcgroup-controller=elogind -Ddefault-hierarchy=legacy
-Ddefault-kill-user-processes=false -Dhalt-path=/usr/bin/halt