]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
netbase: add entry to /etc/hosts according to /etc/hostname
authorChen Qi <Qi.Chen@windriver.com>
Mon, 26 Nov 2018 06:56:38 +0000 (14:56 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 27 Nov 2018 22:12:27 +0000 (22:12 +0000)
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>
meta/recipes-core/netbase/netbase_5.4.bb

index 5ab0c58f8369457f445e9225f30681926d313272..384c43037816089e8e353a6228579bca6f22d90c 100644 (file)
@@ -23,3 +23,12 @@ do_install () {
 }
 
 CONFFILES_${PN} = "${sysconfdir}/hosts"
+
+RDEPENDS_${PN} += "base-files"
+
+pkg_postinst_${PN} () {
+       if [ -s $D/etc/hostname ]; then
+               hostname=`cat $D/etc/hostname`
+               echo "127.0.1.1 $hostname" >> $D/etc/hosts
+       fi
+}