]> code.ossystems Code Review - openembedded-core.git/commitdiff
systemd: add myhostname to nsswitch.conf
authorChristopher Larson <chris_larson@mentor.com>
Wed, 4 Nov 2015 20:57:45 +0000 (13:57 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 11 Jan 2016 23:23:15 +0000 (23:23 +0000)
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@mentor.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/recipes-core/systemd/systemd_228.bb

index 19b7b4218d6dc5c98fbf7b01f4ddcafd202e77a0..df8813ac420ca295b1475bba6660dbdfd7c4a5ff 100644 (file)
@@ -404,6 +404,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 \