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-19 22:34:34 +0000
commit5cdf3006e830bf8e72fd004282f01287a9b80cbf (patch)
tree370e83102036b310d559230092c1f51b244c03bd
parenta773a0f524f3c3d13e7a65c56d184a85c931aede (diff)
downloadopenembedded-core-contrib-5cdf3006e830bf8e72fd004282f01287a9b80cbf.tar.gz
openembedded-core-contrib-5cdf3006e830bf8e72fd004282f01287a9b80cbf.tar.bz2
openembedded-core-contrib-5cdf3006e830bf8e72fd004282f01287a9b80cbf.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
+}