[OE-core] [meta-oe][poky][PATCH] systemd: fix build systemd-resolved with musl

Nicola Lunghi nick83ola at gmail.com
Tue Jul 17 10:48:42 UTC 2018


From: Nicola Lunghi <nicola.lunghi at jci.com>

systemd-resolved build was broken with musl because musl was
missing the nss.h header and some symbol (NETDB_INTERNAL and
NETDB_SUCCESS)

Add a patch to define those symbol to fix the build

Signed-off-by: Nicola Lunghi <nicola.lunghi at jci.com>
---
 ...systemd-resolved-fix-build-with-musl.patch | 67 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_237.bb      |  2 +-
 2 files changed, 68 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-core/systemd/systemd/0037-systemd-resolved-fix-build-with-musl.patch

diff --git a/meta/recipes-core/systemd/systemd/0037-systemd-resolved-fix-build-with-musl.patch b/meta/recipes-core/systemd/systemd/0037-systemd-resolved-fix-build-with-musl.patch
new file mode 100644
index 0000000000..dc64214e18
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0037-systemd-resolved-fix-build-with-musl.patch
@@ -0,0 +1,67 @@
+From 7ebcea5054d11f28c9a6601c6613bcef741df576 Mon Sep 17 00:00:00 2001
+From: Nicola Lunghi <nicola.lunghi at jci.com>
+Date: Mon, 16 Jul 2018 17:32:55 +0000
+Subject: [PATCH] systemd-resolve: fix build with musl
+
+musl doesn't provide nss.h and the symbol
+NETDB_INTERNAL and NETDB_SUCCESS.
+define those symbol to permit compilation of systemd-resolved
+
+Signed-off-by: Nicola Lunghi <nicola.lunghi at jci.com>
+---
+ src/basic/nss-util.h          | 19 +++++++++++++++++++
+ src/nss-resolve/nss-resolve.c |  7 ++++++-
+ 2 files changed, 25 insertions(+), 1 deletion(-)
+
+diff --git a/src/basic/nss-util.h b/src/basic/nss-util.h
+index 4fc676395..111834d62 100644
+--- a/src/basic/nss-util.h
++++ b/src/basic/nss-util.h
+@@ -22,7 +22,26 @@
+ 
+ #include <grp.h>
+ #include <netdb.h>
++#ifdef __GLIBC__
+ #include <nss.h>
++#else
++#include <stdint.h>
++enum nss_status {
++    NSS_STATUS_TRYAGAIN = -2,
++    NSS_STATUS_UNAVAIL,
++    NSS_STATUS_NOTFOUND,
++    NSS_STATUS_SUCCESS,
++    NSS_STATUS_RETURN
++};
++/* Data structure used for the 'gethostbyname4_r' function.  */
++struct gaih_addrtuple {
++    struct gaih_addrtuple *next;
++    char *name;
++    int family;
++    uint32_t addr[4];
++    uint32_t scopeid;
++};
++#endif
+ #include <pwd.h>
+ #include <resolv.h>
+ 
+diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c
+index fe6ce4cbb..67ce1d9ea 100644
+--- a/src/nss-resolve/nss-resolve.c
++++ b/src/nss-resolve/nss-resolve.c
+@@ -20,7 +20,12 @@
+ 
+ #include <errno.h>
+ #include <netdb.h>
+-#include <nss.h>
++#ifndef NETDB_INTERNAL
++#define NETDB_INTERNAL (-1)
++#endif
++#ifndef NETDB_SUCCESS
++#define NETDB_SUCCESS (0)
++#endif
+ #include <stdlib.h>
+ #include <string.h>
+ 
+-- 
+2.17.1
+
diff --git a/meta/recipes-core/systemd/systemd_237.bb b/meta/recipes-core/systemd/systemd_237.bb
index bd6dcef637..0a832733fc 100644
--- a/meta/recipes-core/systemd/systemd_237.bb
+++ b/meta/recipes-core/systemd/systemd_237.bb
@@ -55,6 +55,7 @@ SRC_URI += "file://touchscreen.rules \
            file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch \
            file://0035-Define-glibc-compatible-basename-for-non-glibc-syste.patch \
            file://0036-time-util-fix-build-with-gcc8-Werror-format-truncati.patch \
+           file://0037-systemd-resolved-fix-build-with-musl.patch \
            "
 SRC_URI_append_qemuall = " file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch"
 
@@ -101,7 +102,6 @@ PACKAGECONFIG_remove_libc-musl = " \
     localed \
     myhostname \
     nss \
-    resolved \
     selinux \
     smack \
     sysusers \
-- 
2.17.1




More information about the Openembedded-core mailing list