netbase: add entry to /etc/hosts according to /etc/hostname
cover netbase: add entry to /etc/hosts according to /etc/hostname
The following changes since commit 6bf94ad3b6a3f1202e86b500bfce205d0bda977e:
u-boot: Upgrade 2018.07 -> 2018.11 (2018-11-23 23:35:20 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib ChenQi/netbase-hosts
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/netbase-hosts
Chen Qi (1):
netbase: add entry to /etc/hosts according to /etc/hostname
meta/recipes-core/netbase/netbase_5.4.bb | 9 +++++++++ 1 file changed, 9 insertions(+)
Signature · 1 line
1.9.1
PATCH 1/1 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.
--- meta/recipes-core/netbase/netbase_5.4.bb | 9 +++++++++ 1 file changed, 9 insertions(+)
meta/recipes-core/netbase/netbase_5.4.bb +9 -0
@@ -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 +}
Signature · 1 line
1.9.1
What if the hostname entry already exists? $sysconfdir instead of hard-coding etc.
I can't help but think a better solution would be to simply move /etc/hosts to base-files, so it can be updated at the same time as hostname.
Ross
Quoted 39 lines · Chen Qi
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/hostsaccording to/etc/hostname. We do this viapkg_postinstbecause hostname is set in base-files recipe.Signed-off-by Chen Qi <[email protected]>--- meta/recipes-core/netbase/netbase_5.4.bb | 9 +++++++++ 1 file changed, 9 insertions(+)meta/recipes-core/netbase/netbase_5.4.bb +9
-1@@ -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 +} --1.9.1
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Quoted 6 lines · Ross
What if the hostname entry already exists? $sysconfdir instead of hard-coding etc.
I can't help but think a better solution would be to simply move
/etc/hoststo base-files, so it can be updated at the same time as hostname.
I'm torn on this as netbase is a much better fit for the hosts file and moving it would be a migration pain :(
Your other points stand though...
Cheers,
Richard