[OE-core] [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname

Jacob Kroon jacob.kroon at gmail.com
Wed Dec 26 17:12:25 UTC 2018


On Wed, Dec 26, 2018 at 5:06 PM Jacob Kroon <jacob.kroon at gmail.com> wrote:
>
> On Fri, Nov 30, 2018 at 3:18 AM Chen Qi <Qi.Chen at windriver.com> wrote:
> >
> > 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>
> > ---
> >  meta/recipes-core/netbase/netbase_5.4.bb | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/meta/recipes-core/netbase/netbase_5.4.bb b/meta/recipes-core/netbase/netbase_5.4.bb
> > index 5ab0c58..da9255a 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
>
> Shouldn't that be "127.0.0.1" ?
>

I thought it was a typo, but apparently there are reasons for using 127.0.1.1:
https://serverfault.com/questions/363095/why-does-my-hostname-appear-with-the-address-127-0-1-1-rather-than-127-0-0-1-in

Sorry for the noise.

> > +               fi
> > +       fi
> > +}
> > --
> > 1.9.1
> >
> > --
> > _______________________________________________
> > Openembedded-core mailing list
> > Openembedded-core at lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/openembedded-core


More information about the Openembedded-core mailing list