Skip to contentSkip to conversation

skeleton-init-common: improve /etc/hosts generation

PATCH New Carlos Santos 3 participants 3 messages Oct 19, 2018 – Jan 28, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 skeleton-init-common: improve /etc/hosts generation

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

---
Changes v1->v2: remove stray "else"

---
 package/skeleton-init-common/skeleton-init-common.mk | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
package/skeleton-init-common/skeleton-init-common.mk +6 -1
index e8a0522052..02f86df359 100644
@@ -41,10 +41,15 @@ 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)
+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
Signature · 1 line
2.14.4
#1 lore raw

PATCH v2 1/1 skeleton-init-common: improve /etc/hosts generation

Carlos,

Quoted 7 lines · Carlos Santos

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

Review

Quoted 7 lines

---
Changes v1->v2: remove stray "else"

---
 package/skeleton-init-common/skeleton-init-common.mk | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/package/skeleton-init-common/skeleton-init-common.mk

package/skeleton-init-common/skeleton-init-common.mk SKELETON_INIT_COMMON_PASSWD_METHOD = $(call

Quoted 4 lines

index e8a0522052..02f86df359 100644

package/skeleton-init-common/skeleton-init-common.mk +0 -0
@@ -41,10 +41,15 @@ SKELETON_INIT_COMMON_PASSWD_METHOD = $(call

qstrip,$(BR2_TARGET_GENERIC_PASSWD_M

package/skeleton-init-common/skeleton-init-common.mk SKELETON_INIT_COMMON_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_M

Quoted 5 lines
package/skeleton-init-common/skeleton-init-common.mk +2 -0
 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)))

package/skeleton-init-common/skeleton-init-common.mk SKELETON_INIT_COMMON_PASSWD_METHOD = $(call · line 46

Quoted 1 line
package/skeleton-init-common/skeleton-init-common.mk +1 -0
+ifneq

($(SKELETON_INIT_COMMON_HOSTNAME),$(SKELETON_INIT_COMMON_SHORT_HOSTNAME))

package/skeleton-init-common/skeleton-init-common.mk SKELETON_INIT_COMMON_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_M

Quoted 5 lines
package/skeleton-init-common/skeleton-init-common.mk +2 -0
+SKELETON_INIT_COMMON_HOSTS_LINE += $(SKELETON_INIT_COMMON_SHORT_HOSTNAME)
+endif
 define SKELETON_INIT_COMMON_SET_HOSTNAME
        mkdir -p $(TARGET_DIR)/etc
        echo "$(SKELETON_INIT_COMMON_HOSTNAME)" >

$(TARGET_DIR)/etc/hostname

package/skeleton-init-common/skeleton-init-common.mk SKELETON_INIT_COMMON_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_M

Quoted 5 lines
package/skeleton-init-common/skeleton-init-common.mk +1 -1
-       $(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

Quoted 7 lines

--
2.14.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 11 lines
Matthew L Weber / Pr Software Engineer
Airborne Information Systems / RC Linux Secure Platforms
MS 131-100, C Ave NE, Cedar Rapids, IA, 52498, USA
www.rockwellcollins.com

Note: Any Export License Required Information and License Restricted Third
Party Intellectual Property (TPIP) content must be encrypted and sent to
matthew.weber at corp.rockwellcollins.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20181019/4497daca/attachment.html>
#2 lore raw

PATCH v2 1/1 skeleton-init-common: improve /etc/hosts generation

In reply to Carlos Santos
Quoted 6 lines · Carlos Santos

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

Applied to master, thanks.

Regards,
Arnout

Quoted 28 lines

---
Changes v1->v2: remove stray "else"

---
 package/skeleton-init-common/skeleton-init-common.mk | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
package/skeleton-init-common/skeleton-init-common.mk +6 -1
index e8a0522052..02f86df359 100644
@@ -41,10 +41,15 @@ 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)
+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