Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/1] netbase: add entry to /etc/hosts according to /etc/hostname
@ 2018-11-26  6:56 Chen Qi
  2018-11-26  6:56 ` [PATCH 1/1] " Chen Qi
  0 siblings, 1 reply; 5+ 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] 5+ messages in thread

* [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2018-11-26  6:56 [PATCH 0/1] netbase: add entry to /etc/hosts according to /etc/hostname Chen Qi
@ 2018-11-26  6:56 ` Chen Qi
  2018-11-28 10:26   ` Burton, Ross
  0 siblings, 1 reply; 5+ messages in thread
From: Chen Qi @ 2018-11-26  6:56 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 | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/meta/recipes-core/netbase/netbase_5.4.bb b/meta/recipes-core/netbase/netbase_5.4.bb
index 5ab0c58..384c430 100644
--- a/meta/recipes-core/netbase/netbase_5.4.bb
+++ b/meta/recipes-core/netbase/netbase_5.4.bb
@@ -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



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

* Re: [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2018-11-26  6:56 ` [PATCH 1/1] " Chen Qi
@ 2018-11-28 10:26   ` Burton, Ross
  2018-11-28 11:21     ` Richard Purdie
  0 siblings, 1 reply; 5+ messages in thread
From: Burton, Ross @ 2018-11-28 10:26 UTC (permalink / raw)
  To: ChenQi; +Cc: OE-core

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
On Mon, 26 Nov 2018 at 06:51, 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 | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/meta/recipes-core/netbase/netbase_5.4.bb b/meta/recipes-core/netbase/netbase_5.4.bb
> index 5ab0c58..384c430 100644
> --- a/meta/recipes-core/netbase/netbase_5.4.bb
> +++ b/meta/recipes-core/netbase/netbase_5.4.bb
> @@ -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
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


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

* Re: [PATCH 1/1] netbase: add entry to /etc/hosts according to /etc/hostname
  2018-11-28 10:26   ` Burton, Ross
@ 2018-11-28 11:21     ` Richard Purdie
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Purdie @ 2018-11-28 11:21 UTC (permalink / raw)
  To: Burton, Ross, ChenQi; +Cc: OE-core

On Wed, 2018-11-28 at 10:26 +0000, Burton, Ross wrote:
> 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.

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



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

* [PATCH 0/1] netbase: add entry to /etc/hosts according to /etc/hostname
@ 2018-11-29  9:37 Chen Qi
  0 siblings, 0 replies; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2018-11-29  9:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-26  6:56 [PATCH 0/1] netbase: add entry to /etc/hosts according to /etc/hostname Chen Qi
2018-11-26  6:56 ` [PATCH 1/1] " Chen Qi
2018-11-28 10:26   ` Burton, Ross
2018-11-28 11:21     ` Richard Purdie
  -- strict thread matches above, loose matches on Subject: below --
2018-11-29  9:37 [PATCH 0/1] " Chen Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox