skeleton-init-commom: do not assume /etc/hosts and /etc/shadow exist

This commit is contained in:
Calin Crisan 2018-11-11 23:00:55 +02:00
parent 670925a6a5
commit 89851a1334

View File

@ -44,8 +44,9 @@ 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
$(SED) '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTNAME)' \
-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
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
endif
@ -70,7 +71,7 @@ else # !BR2_TARGET_ENABLE_ROOT_LOGIN
SKELETON_INIT_COMMON_ROOT_PASSWORD = "*"
endif
define SKELETON_INIT_COMMON_SET_ROOT_PASSWD
$(SED) s,^root:[^:]*:,root:$(SKELETON_INIT_COMMON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
test -f $(TARGET_DIR)/etc/shadow && $(SED) s,^root:[^:]*:,root:$(SKELETON_INIT_COMMON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow || true
endef
SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_ROOT_PASSWD