All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] netbase: add entry to /etc/hosts according to /etc/hostname
@ 2018-11-29  9:37 Chen Qi
  2018-11-29  9:37 ` [PATCH 1/1] " Chen Qi
  0 siblings, 1 reply; 8+ messages in thread
From: Chen Qi @ 2018-11-29  9:37 UTC (permalink / raw)
  To: openembedded-core

Changes in V2:
* use ${sysconfdir} instead of /etc
* check the existence of entry before adding it

The following changes since commit 41d89552620bfbc94031d314e6b3d0324f7a330e:

  bitbake: fetch2: Avoid warning about incorrect character escaping in regex (2018-11-27 22:15:34 +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 | 11 +++++++++++
 1 file changed, 11 insertions(+)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2018-11-29  9:37 [PATCH 0/1] netbase: add entry to /etc/hosts according to /etc/hostname Chen Qi
@ 2018-11-29  9:37 ` Chen Qi
  2018-12-14 21:45   ` Burton, Ross
  2018-12-26 16:06   ` Jacob Kroon
  0 siblings, 2 replies; 8+ messages in thread
From: Chen Qi @ 2018-11-29  9:37 UTC (permalink / raw)
  To: openembedded-core

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>
---
 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
+		fi
+	fi
+}
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2018-11-29  9:37 ` [PATCH 1/1] " Chen Qi
@ 2018-12-14 21:45   ` Burton, Ross
  2019-01-07 14:38     ` Richard Purdie
  2018-12-26 16:06   ` Jacob Kroon
  1 sibling, 1 reply; 8+ messages in thread
From: Burton, Ross @ 2018-12-14 21:45 UTC (permalink / raw)
  To: ChenQi; +Cc: OE-core

On Fri, 30 Nov 2018 at 02:18, Chen Qi <Qi.Chen@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.

RP and myself are still arguing over this so I thought I'd make my
argument on the list for debate.

Updating /etc/hosts is being done with a postinst in netbase simply
because /etc/hostname is contained in the base-files recipe. I
advocate just moving the creation of /etc/hosts to base-files along
with /etc/hostname, then base-files can write both files at the same
time.  There's already a dependency on base-files from netbase so
there will be no change in the rootfs, a file will just move between
packages.

Ross


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2018-11-29  9:37 ` [PATCH 1/1] " Chen Qi
  2018-12-14 21:45   ` Burton, Ross
@ 2018-12-26 16:06   ` Jacob Kroon
  2018-12-26 17:12     ` Jacob Kroon
  1 sibling, 1 reply; 8+ messages in thread
From: Jacob Kroon @ 2018-12-26 16:06 UTC (permalink / raw)
  To: Chen Qi; +Cc: openembedded-core

On Fri, Nov 30, 2018 at 3:18 AM Chen Qi <Qi.Chen@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@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" ?

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2018-12-26 16:06   ` Jacob Kroon
@ 2018-12-26 17:12     ` Jacob Kroon
  0 siblings, 0 replies; 8+ messages in thread
From: Jacob Kroon @ 2018-12-26 17:12 UTC (permalink / raw)
  To: Chen Qi; +Cc: openembedded-core

On Wed, Dec 26, 2018 at 5:06 PM Jacob Kroon <jacob.kroon@gmail.com> wrote:
>
> On Fri, Nov 30, 2018 at 3:18 AM Chen Qi <Qi.Chen@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@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@lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2018-12-14 21:45   ` Burton, Ross
@ 2019-01-07 14:38     ` Richard Purdie
  2019-01-08  1:57       ` ChenQi
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Purdie @ 2019-01-07 14:38 UTC (permalink / raw)
  To: Burton, Ross, ChenQi; +Cc: OE-core

On Fri, 2018-12-14 at 21:45 +0000, Burton, Ross wrote:
> On Fri, 30 Nov 2018 at 02:18, Chen Qi <Qi.Chen@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.
> 
> RP and myself are still arguing over this so I thought I'd make my
> argument on the list for debate.
> 
> Updating /etc/hosts is being done with a postinst in netbase simply
> because /etc/hostname is contained in the base-files recipe. I
> advocate just moving the creation of /etc/hosts to base-files along
> with /etc/hostname, then base-files can write both files at the same
> time.  There's already a dependency on base-files from netbase so
> there will be no change in the rootfs, a file will just move between
> packages.

Coming back to this after the holidays, I agree with Ross, we should
move /etc/hostname to base-files and keep this simple. I'd like to get
this fixed, could you update the patch please?

Cheers,

Richard



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2019-01-07 14:38     ` Richard Purdie
@ 2019-01-08  1:57       ` ChenQi
  0 siblings, 0 replies; 8+ messages in thread
From: ChenQi @ 2019-01-08  1:57 UTC (permalink / raw)
  To: Richard Purdie, Burton, Ross; +Cc: OE-core

On 01/07/2019 10:38 PM, Richard Purdie wrote:
> On Fri, 2018-12-14 at 21:45 +0000, Burton, Ross wrote:
>> On Fri, 30 Nov 2018 at 02:18, Chen Qi <Qi.Chen@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.
>> RP and myself are still arguing over this so I thought I'd make my
>> argument on the list for debate.
>>
>> Updating /etc/hosts is being done with a postinst in netbase simply
>> because /etc/hostname is contained in the base-files recipe. I
>> advocate just moving the creation of /etc/hosts to base-files along
>> with /etc/hostname, then base-files can write both files at the same
>> time.  There's already a dependency on base-files from netbase so
>> there will be no change in the rootfs, a file will just move between
>> packages.
> Coming back to this after the holidays, I agree with Ross, we should
> move /etc/hostname to base-files and keep this simple. I'd like to get
> this fixed, could you update the patch please?
>
> Cheers,
>
> Richard
>
>
Yes. I'll send out a new patch.

Best Regards,

Chen Qi



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 0/1] netbase: add entry to /etc/hosts according to /etc/hostname
@ 2018-11-26  6:56 Chen Qi
  0 siblings, 0 replies; 8+ messages in thread
From: Chen Qi @ 2018-11-26  6:56 UTC (permalink / raw)
  To: openembedded-core

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(+)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-01-08  1:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29  9:37 [PATCH 0/1] netbase: add entry to /etc/hosts according to /etc/hostname Chen Qi
2018-11-29  9:37 ` [PATCH 1/1] " Chen Qi
2018-12-14 21:45   ` Burton, Ross
2019-01-07 14:38     ` Richard Purdie
2019-01-08  1:57       ` ChenQi
2018-12-26 16:06   ` Jacob Kroon
2018-12-26 17:12     ` Jacob Kroon
  -- strict thread matches above, loose matches on Subject: below --
2018-11-26  6:56 [PATCH 0/1] " Chen Qi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.