All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] skeleton-init-common: improve /etc/hosts generation
@ 2018-10-19 13:38 Carlos Santos
  2018-10-20 12:09 ` Arnout Vandecappelle
  0 siblings, 1 reply; 3+ messages in thread
From: Carlos Santos @ 2018-10-19 13:38 UTC (permalink / raw)
  To: buildroot

If BR2_TARGET_GENERIC_HOSTNAME contains a FQDN, strip the host part and
add it as an alias, e.g.

    127.0.1.1	hostname.example.com hostname

Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
 package/skeleton-init-common/skeleton-init-common.mk | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/package/skeleton-init-common/skeleton-init-common.mk b/package/skeleton-init-common/skeleton-init-common.mk
index e8a0522052..93a410914a 100644
--- a/package/skeleton-init-common/skeleton-init-common.mk
+++ b/package/skeleton-init-common/skeleton-init-common.mk
@@ -41,10 +41,16 @@ SKELETON_INIT_COMMON_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_M
 SKELETON_INIT_COMMON_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
 
 ifneq ($(SKELETON_INIT_COMMON_HOSTNAME),)
+SKELETON_INIT_COMMON_HOSTS_LINE = $(SKELETON_INIT_COMMON_HOSTNAME)
+SKELETON_INIT_COMMON_SHORT_HOSTNAME = $(firstword $(subst ., ,$(SKELETON_INIT_COMMON_HOSTNAME)))
+ifneq ($(SKELETON_INIT_COMMON_HOSTNAME),$(SKELETON_INIT_COMMON_SHORT_HOSTNAME))
+SKELETON_INIT_COMMON_HOSTS_LINE += $(SKELETON_INIT_COMMON_SHORT_HOSTNAME)
+else
+endif
 define SKELETON_INIT_COMMON_SET_HOSTNAME
 	mkdir -p $(TARGET_DIR)/etc
 	echo "$(SKELETON_INIT_COMMON_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
-	$(SED) '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTNAME)' \
+	$(SED) '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTS_LINE)' \
 		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
 endef
 SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_HOSTNAME
-- 
2.14.4

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

* [Buildroot] [PATCH] skeleton-init-common: improve /etc/hosts generation
  2018-10-19 13:38 [Buildroot] [PATCH] skeleton-init-common: improve /etc/hosts generation Carlos Santos
@ 2018-10-20 12:09 ` Arnout Vandecappelle
  2018-10-21 19:46   ` Carlos Santos
  0 siblings, 1 reply; 3+ messages in thread
From: Arnout Vandecappelle @ 2018-10-20 12:09 UTC (permalink / raw)
  To: buildroot



On 19/10/2018 14:38, Carlos Santos wrote:
> If BR2_TARGET_GENERIC_HOSTNAME contains a FQDN, strip the host part and
> add it as an alias, e.g.
> 
>     127.0.1.1	hostname.example.com hostname
> 
> Signed-off-by: Carlos Santos <casantos@datacom.com.br>

Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

 Regards,
 Arnout

> ---
>  package/skeleton-init-common/skeleton-init-common.mk | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/package/skeleton-init-common/skeleton-init-common.mk b/package/skeleton-init-common/skeleton-init-common.mk
> index e8a0522052..93a410914a 100644
> --- a/package/skeleton-init-common/skeleton-init-common.mk
> +++ b/package/skeleton-init-common/skeleton-init-common.mk
> @@ -41,10 +41,16 @@ SKELETON_INIT_COMMON_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_M
>  SKELETON_INIT_COMMON_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
>  
>  ifneq ($(SKELETON_INIT_COMMON_HOSTNAME),)
> +SKELETON_INIT_COMMON_HOSTS_LINE = $(SKELETON_INIT_COMMON_HOSTNAME)
> +SKELETON_INIT_COMMON_SHORT_HOSTNAME = $(firstword $(subst ., ,$(SKELETON_INIT_COMMON_HOSTNAME)))
> +ifneq ($(SKELETON_INIT_COMMON_HOSTNAME),$(SKELETON_INIT_COMMON_SHORT_HOSTNAME))
> +SKELETON_INIT_COMMON_HOSTS_LINE += $(SKELETON_INIT_COMMON_SHORT_HOSTNAME)
> +else
> +endif
>  define SKELETON_INIT_COMMON_SET_HOSTNAME
>  	mkdir -p $(TARGET_DIR)/etc
>  	echo "$(SKELETON_INIT_COMMON_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
> -	$(SED) '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTNAME)' \
> +	$(SED) '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTS_LINE)' \
>  		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
>  endef
>  SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_HOSTNAME
> 

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

* [Buildroot] [PATCH] skeleton-init-common: improve /etc/hosts generation
  2018-10-20 12:09 ` Arnout Vandecappelle
@ 2018-10-21 19:46   ` Carlos Santos
  0 siblings, 0 replies; 3+ messages in thread
From: Carlos Santos @ 2018-10-21 19:46 UTC (permalink / raw)
  To: buildroot

> From: "Arnout Vandecappelle" <arnout@mind.be>
> To: "DATACOM" <casantos@datacom.com.br>, "buildroot" <buildroot@buildroot.org>
> Sent: Saturday, October 20, 2018 9:09:57 AM
> Subject: Re: [Buildroot] [PATCH] skeleton-init-common: improve /etc/hosts generation

> On 19/10/2018 14:38, Carlos Santos wrote:
>> If BR2_TARGET_GENERIC_HOSTNAME contains a FQDN, strip the host part and
>> add it as an alias, e.g.
>> 
>>     127.0.1.1	hostname.example.com hostname
>> 
>> Signed-off-by: Carlos Santos <casantos@datacom.com.br>
> 
> Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

Warning: superseded by https://patchwork.ozlabs.org/patch/986832/

-- 
Carlos Santos (Casantos) - DATACOM, P&D
?Marched towards the enemy, spear upright, armed with the certainty
that only the ignorant can have.? ? Epitaph of a volunteer

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

end of thread, other threads:[~2018-10-21 19:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-19 13:38 [Buildroot] [PATCH] skeleton-init-common: improve /etc/hosts generation Carlos Santos
2018-10-20 12:09 ` Arnout Vandecappelle
2018-10-21 19:46   ` Carlos Santos

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.