summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2018-11-30 10:24:41 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-27 22:55:05 +0000
commit3577e83dc08076fc4b1d671dbf5bb4fef75d4c34 (patch)
treeb00ce66bea9507cd0cb7f8494da4f91aab42a5e7
parentc708f3a2b6ed9521ac8269e56ee70d9edd0ef2df (diff)
downloadopenembedded-core-contrib-3577e83dc08076fc4b1d671dbf5bb4fef75d4c34.tar.gz
openembedded-core-contrib-3577e83dc08076fc4b1d671dbf5bb4fef75d4c34.tar.bz2
openembedded-core-contrib-3577e83dc08076fc4b1d671dbf5bb4fef75d4c34.zip
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@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/netbase/netbase_5.4.bb11
1 files changed, 11 insertions, 0 deletions
diff --git a/meta/recipes-core/netbase/netbase_5.4.bb b/meta/recipes-core/netbase/netbase_5.4.bb
index 5ab0c58f83..da9255a2bf 100644
--- a/meta/recipes-core/netbase/netbase_5.4.bb
+++ b/meta/recipes-core/netbase/netbase_5.4.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
+}