From b088ab0f26ce64faaca8cf457a0ec56cee880003 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 18 Nov 2018 19:55:56 +0200 Subject: [PATCH] skeleton-init-commom: do not assume /etc/hostname exists --- package/skeleton-init-common/skeleton-init-common.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package/skeleton-init-common/skeleton-init-common.mk b/package/skeleton-init-common/skeleton-init-common.mk index ca98f5cfd9..532173df45 100644 --- a/package/skeleton-init-common/skeleton-init-common.mk +++ b/package/skeleton-init-common/skeleton-init-common.mk @@ -43,9 +43,10 @@ SKELETON_INIT_COMMON_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH)) ifneq ($(SKELETON_INIT_COMMON_HOSTNAME),) define SKELETON_INIT_COMMON_SET_HOSTNAME mkdir -p $(TARGET_DIR)/etc - echo "$(SKELETON_INIT_COMMON_HOSTNAME)" > $(TARGET_DIR)/etc/hostname - test -f $(TARGET_DIR)/etc/hosts && $(SED) \ - '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTNAME)' \ + test -f $(TARGET_DIR)/etc/hostname && \ + echo "$(SKELETON_INIT_COMMON_HOSTNAME)" > $(TARGET_DIR)/etc/hostname || true + test -f $(TARGET_DIR)/etc/hosts && \ + $(SED) '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTNAME)' \ -e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts || true endef SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_HOSTNAME