systemd: Fix build on musl
PATCH 1/1 systemd: Fix build on musl
Add needed patches for portability across glibc/musl enable systemd on musl too
Disable utmp,ldconfig,nss,resolved,localed for musl which is not supported on musl
Signed-off-by Khem Raj <[email protected]>
--- ...PATH_WTMPX-and-_PATH_UTMPX-if-not-defined.patch | 43 ++ ...llback-parse_printf_format-implementation.patch | 433 +++++++++++++++++++++ ...asic-missing.h-check-for-missing-strndupa.patch | 104 +++++ ...if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch | 157 ++++++++ ...issing.h-check-for-missing-__compar_fn_t-.patch | 47 +++ .../systemd/0006-Include-netinet-if_ether.h.patch | 86 ++++ ...-check-for-missing-canonicalize_file_name.patch | 63 +++ .../systemd/0008-Do-not-enable-nss-tests.patch | 35 ++ ...xdecoct.c-Include-missing.h-form-strndupa.patch | 27 ++ ....c-Disable-tests-for-missing-typedefs-in-.patch | 49 +++ .../0011-don-t-use-glibc-specific-qsort_r.patch | 105 +++++ ...ass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch | 99 +++++ ...fn_t-is-glibc-specific-use-raw-signature-.patch | 31 ++ meta/recipes-core/systemd/systemd_234.bb | 28 +- 14 files changed, 1300 insertions(+), 7 deletions(-) create mode 100644 meta/recipes-core/systemd/systemd/0001-Define-_PATH_WTMPX-and-_PATH_UTMPX-if-not-defined.patch create mode 100644 meta/recipes-core/systemd/systemd/0001-add-fallback-parse_printf_format-implementation.patch create mode 100644 meta/recipes-core/systemd/systemd/0002-src-basic-missing.h-check-for-missing-strndupa.patch create mode 100644 meta/recipes-core/systemd/systemd/0003-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch create mode 100644 meta/recipes-core/systemd/systemd/0004-src-basic-missing.h-check-for-missing-__compar_fn_t-.patch create mode 100644 meta/recipes-core/systemd/systemd/0006-Include-netinet-if_ether.h.patch create mode 100644 meta/recipes-core/systemd/systemd/0007-check-for-missing-canonicalize_file_name.patch create mode 100644 meta/recipes-core/systemd/systemd/0008-Do-not-enable-nss-tests.patch create mode 100644 meta/recipes-core/systemd/systemd/0009-test-hexdecoct.c-Include-missing.h-form-strndupa.patch create mode 100644 meta/recipes-core/systemd/systemd/0010-test-sizeof.c-Disable-tests-for-missing-typedefs-in-.patch create mode 100644 meta/recipes-core/systemd/systemd/0011-don-t-use-glibc-specific-qsort_r.patch create mode 100644 meta/recipes-core/systemd/systemd/0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch create mode 100644 meta/recipes-core/systemd/systemd/0013-comparison_fn_t-is-glibc-specific-use-raw-signature-.patch
meta/recipes-core/systemd/systemd/0001-Define-_PATH_WTMPX-and-_PATH_UTMPX-if-not-defined.patch new file +43 -0
@@ -0,0 +1,43 @@ +From 3ca5326485cb19e775af6de615c17be66e44e472 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 24 Oct 2017 23:08:24 -0700 +Subject: [PATCH] Define _PATH_WTMPX and _PATH_UTMPX if not defined + +Musl needs these defines + +Signed-off-by: Khem Raj <[email protected]> +--- +Upstream-Status: Pending + + src/shared/utmp-wtmp.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c +index 9750dcd81..bd55d74a1 100644 +--- a/src/shared/utmp-wtmp.c ++++ b/src/shared/utmp-wtmp.c +@@ -27,6 +27,7 @@ + #include <sys/time.h> + #include <sys/utsname.h> + #include <unistd.h> ++#include <utmp.h> + #include <utmpx.h> + + #include "alloc-util.h" +@@ -41,6 +42,13 @@ + #include "util.h" + #include "utmp-wtmp.h" + ++#if defined _PATH_UTMP && !defined _PATH_UTMPX ++# define _PATH_UTMPX _PATH_UTMP ++#endif ++#if defined _PATH_WTMP && !defined _PATH_WTMPX ++# define _PATH_WTMPX _PATH_WTMP ++#endif ++ + int utmp_get_runlevel(int *runlevel, int *previous) { + struct utmpx *found, lookup = { .ut_type = RUN_LVL }; + int r; +-- +2.14.3 +
meta/recipes-core/systemd/systemd/0001-add-fallback-parse_printf_format-implementation.patch new file +433 -0
433 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0002-src-basic-missing.h-check-for-missing-strndupa.patch new file +104 -0
104 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0003-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch new file +157 -0
157 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0004-src-basic-missing.h-check-for-missing-__compar_fn_t-.patch new file +47 -0
47 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0006-Include-netinet-if_ether.h.patch new file +86 -0
86 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0007-check-for-missing-canonicalize_file_name.patch new file +63 -0
63 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0008-Do-not-enable-nss-tests.patch new file +35 -0
@@ -0,0 +1,35 @@ +From 48e7c0f5b2f5d777a16ac5584dc4f50f1dfa832c Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 23 Oct 2017 12:27:53 -0700 +Subject: [PATCH 08/12] Do not enable nss tests + +Signed-off-by: Khem Raj <[email protected]> +--- +Upstream-Status: Pending + + Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.am b/Makefile.am +index 3cc8f3451..df20a9a11 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -5290,6 +5290,7 @@ EXTRA_DIST += \ + src/timesync/timesyncd.conf.in + + # ------------------------------------------------------------------------------ ++if ENABLE_NSS_SYSTEMD + test_nss_SOURCES = \ + src/test/test-nss.c + +@@ -5302,7 +5303,6 @@ manual_tests += \ + test-nss + + # ------------------------------------------------------------------------------ +-if ENABLE_NSS_SYSTEMD + libnss_systemd_la_SOURCES = \ + src/nss-systemd/nss-systemd.sym \ + src/nss-systemd/nss-systemd.c +-- +2.14.2 +
meta/recipes-core/systemd/systemd/0009-test-hexdecoct.c-Include-missing.h-form-strndupa.patch new file +27 -0
@@ -0,0 +1,27 @@ +From 75f4e7f167de533a160ee1af2a03fba4c5a5ffc6 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 23 Oct 2017 12:33:22 -0700 +Subject: [PATCH 09/12] test-hexdecoct.c: Include missing.h form strndupa + +Signed-off-by: Khem Raj <[email protected]> +--- +Upstream-Status: Pending + + src/test/test-hexdecoct.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/test/test-hexdecoct.c b/src/test/test-hexdecoct.c +index fcae427e7..5eb5e2ed7 100644 +--- a/src/test/test-hexdecoct.c ++++ b/src/test/test-hexdecoct.c +@@ -21,6 +21,7 @@ + #include "hexdecoct.h" + #include "macro.h" + #include "string-util.h" ++#include "missing.h" + + static void test_hexchar(void) { + assert_se(hexchar(0xa) == 'a'); +-- +2.14.2 +
meta/recipes-core/systemd/systemd/0010-test-sizeof.c-Disable-tests-for-missing-typedefs-in-.patch new file +49 -0
49 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0011-don-t-use-glibc-specific-qsort_r.patch new file +105 -0
105 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch new file +99 -0
99 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0013-comparison_fn_t-is-glibc-specific-use-raw-signature-.patch new file +31 -0
@@ -0,0 +1,31 @@ +From 4b6733544beb662a0f77310302fae1fb7b76d167 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sat, 12 Sep 2015 18:53:31 +0000 +Subject: [PATCH 13/13] comparison_fn_t is glibc specific, use raw signature in + function pointer + +make it work with musl where comparison_fn_t is not provided + +Signed-off-by: Khem Raj <[email protected]> +--- +Upstream-Status: Pending + + src/basic/util.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/basic/util.h b/src/basic/util.h +index c7da6c39b..87f62b891 100644 +--- a/src/basic/util.h ++++ b/src/basic/util.h +@@ -98,7 +98,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, + * Normal qsort requires base to be nonnull. Here were require + * that only if nmemb > 0. + */ +-static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_fn_t compar) { ++static inline void qsort_safe(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { + if (nmemb <= 1) + return; + +-- +2.14.2 +
meta/recipes-core/systemd/systemd_234.bb +21 -7
@@ -10,7 +10,7 @@ SECTION = "base/shell" inherit useradd pkgconfig autotools perlnative update-rc.d update-alternatives qemu systemd ptest gettext bash-completion manpages -SRC_URI += " \ +SRC_URI = "git://github.com/systemd/systemd.git;protocol=git \ file://touchscreen.rules \ file://00-create-volatile.conf \ file://init \
@@ -27,6 +27,19 @@ SRC_URI += " \ file://0017-remove-duplicate-include-uchar.h.patch \ file://0018-check-for-uchar.h-in-configure.patch \ file://0019-socket-util-don-t-fail-if-libc-doesn-t-support-IDN.patch \ + file://0001-add-fallback-parse_printf_format-implementation.patch \ + file://0002-src-basic-missing.h-check-for-missing-strndupa.patch \ + file://0003-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not-.patch \ + file://0004-src-basic-missing.h-check-for-missing-__compar_fn_t-.patch \ + file://0006-Include-netinet-if_ether.h.patch \ + file://0007-check-for-missing-canonicalize_file_name.patch \ + file://0008-Do-not-enable-nss-tests.patch \ + file://0009-test-hexdecoct.c-Include-missing.h-form-strndupa.patch \ + file://0010-test-sizeof.c-Disable-tests-for-missing-typedefs-in-.patch \ + file://0011-don-t-use-glibc-specific-qsort_r.patch \ + file://0012-don-t-pass-AT_SYMLINK_NOFOLLOW-flag-to-faccessat.patch \ + file://0013-comparison_fn_t-is-glibc-specific-use-raw-signature-.patch \ + file://0001-Define-_PATH_WTMPX-and-_PATH_UTMPX-if-not-defined.patch \ " SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"
@@ -47,7 +60,8 @@ PACKAGECONFIG ??= "xz \ vconsole \ quotacheck \ hostnamed \ - ${@bb.utils.contains('TCLIBC', 'glibc', 'myhostname sysusers', '', d)} \ + ${@bb.utils.contains('TCLIBC', 'glibc', 'myhostname sysusers utmp', '', d)} \ + nss \ hibernate \ timedated \ timesyncd \
@@ -56,13 +70,16 @@ PACKAGECONFIG ??= "xz \ smack \ logind \ firstboot \ - utmp \ polkit \ resolved \ networkd \ " PACKAGECONFIG_remove_libc-musl = "selinux" PACKAGECONFIG_remove_libc-musl = "smack" +PACKAGECONFIG_remove_libc-musl = "resolved" +PACKAGECONFIG_remove_libc-musl = "nss" +PACKAGECONFIG_remove_libc-musl = "localed" +PACKAGECONFIG_remove_libc-musl = "ldconfig" # Use the upstream systemd [email protected] and rely on # systemd-getty-generator instead of using the OE-core specific
@@ -83,6 +100,7 @@ PACKAGECONFIG[vconsole] = "--enable-vconsole,--disable-vconsole,,${PN}-vconsole- PACKAGECONFIG[quotacheck] = "--enable-quotacheck,--disable-quotacheck" PACKAGECONFIG[hostnamed] = "--enable-hostnamed,--disable-hostnamed" PACKAGECONFIG[myhostname] = "--enable-myhostname,--disable-myhostname" +PACKAGECONFIG[nss] = "--enable-nss-systemd,--disable-nss-systemd" PACKAGECONFIG[rfkill] = "--enable-rfkill,--disable-rfkill" PACKAGECONFIG[hibernate] = "--enable-hibernate,--disable-hibernate" PACKAGECONFIG[timedated] = "--enable-timedated,--disable-timedated"
@@ -615,8 +633,4 @@ pkg_prerm_udev-hwdb () { python () { if not bb.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): raise bb.parse.SkipPackage("'systemd' not in DISTRO_FEATURES") - - import re - if re.match('.*musl*', d.getVar('TARGET_OS')) != None: - raise bb.parse.SkipPackage("Not _yet_ supported on musl based targets") }
Signature · 1 line
2.14.3