[oe-commits] [openembedded-core] 03/03: netbase: add entry to /etc/hosts according to /etc/hostname

git at git.openembedded.org git at git.openembedded.org
Thu Jan 3 21:21:04 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 86b864cce41b5c4112802d65fb999a971ffa8fe8
Author: Chen Qi <Qi.Chen at windriver.com>
AuthorDate: Fri Nov 30 10:24:41 2018 +0800

    netbase: add entry to /etc/hosts according to /etc/hostname
    
    We default hostname to ${MACHINE}, but it's not in /etc/hosts,
    resulting in commands like `hostname -f' failing due to lack
    of entry.
    
    So add entry to /etc/hosts according to /etc/hostname. We do
    this via pkg_postinst because hostname is set in base-files
    recipe.
    
    Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/recipes-core/netbase/netbase_5.5.bb | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/meta/recipes-core/netbase/netbase_5.5.bb b/meta/recipes-core/netbase/netbase_5.5.bb
index 2061f86..8099de9 100644
--- a/meta/recipes-core/netbase/netbase_5.5.bb
+++ b/meta/recipes-core/netbase/netbase_5.5.bb
@@ -23,3 +23,14 @@ do_install () {
 }
 
 CONFFILES_${PN} = "${sysconfdir}/hosts"
+
+RDEPENDS_${PN} += "base-files"
+
+pkg_postinst_${PN} () {
+	if [ -s $D${sysconfdir}/hostname ]; then
+		hostname=`cat $D${sysconfdir}/hostname`
+		if ! grep -q "[[:space:]]$hostname[[:space:]]*" $D${sysconfdir}/hosts; then
+			echo "127.0.1.1 $hostname" >> $D${sysconfdir}/hosts
+		fi
+	fi
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list