[OE-core] [PATCH 3/4] systemd: add myhostname to nsswitch.conf

Christopher Larson kergoth at gmail.com
Thu Nov 12 23:41:30 UTC 2015


From: Christopher Larson <chris_larson at mentor.com>

We don't need nss-myhostname on systemd systems, because systemd already
provides myhostname, but we weren't configuring nsswitch to use it. Being able
to resolve the hostname is useful for a number of different applications, so
enable it using the same postinst/prerm bits which are in nss-myhostname.

Signed-off-by: Christopher Larson <chris_larson at mentor.com>
---
 meta/recipes-core/systemd/systemd_225.bb | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/meta/recipes-core/systemd/systemd_225.bb b/meta/recipes-core/systemd/systemd_225.bb
index 18c2448..20515f5 100644
--- a/meta/recipes-core/systemd/systemd_225.bb
+++ b/meta/recipes-core/systemd/systemd_225.bb
@@ -397,6 +397,18 @@ ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl"
 ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
 ALTERNATIVE_PRIORITY[runlevel] ?= "300"
 
+pkg_postinst_${PN} () {
+	sed -e '/^hosts:/s/\s*\<myhostname\>//' \
+		-e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2 myhostname \3\4\5/' \
+		-i $D${sysconfdir}/nsswitch.conf
+}
+
+pkg_prerm_${PN} () {
+	sed -e '/^hosts:/s/\s*\<myhostname\>//' \
+		-e '/^hosts:/s/\s*myhostname//' \
+		-i $D${sysconfdir}/nsswitch.conf
+}
+
 pkg_postinst_udev-hwdb () {
 	if test -n "$D"; then
 		${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
-- 
2.2.1




More information about the Openembedded-core mailing list