xref: /OK3568_Linux_fs/buildroot/package/skeleton-init-common/skeleton-init-common.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun################################################################################
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# skeleton-init-common
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun################################################################################
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun# The skeleton can't depend on the toolchain, since all packages depends on the
8*4882a593Smuzhiyun# skeleton and the toolchain is a target package, as is skeleton.
9*4882a593Smuzhiyun# Hence, skeleton would depends on the toolchain and the toolchain would depend
10*4882a593Smuzhiyun# on skeleton.
11*4882a593SmuzhiyunSKELETON_INIT_COMMON_ADD_TOOLCHAIN_DEPENDENCY = NO
12*4882a593SmuzhiyunSKELETON_INIT_COMMON_ADD_SKELETON_DEPENDENCY = NO
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun# The skeleton also handles the merged /usr case in the sysroot
15*4882a593SmuzhiyunSKELETON_INIT_COMMON_INSTALL_STAGING = YES
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunSKELETON_INIT_COMMON_PATH = system/skeleton
18*4882a593Smuzhiyun
19*4882a593Smuzhiyundefine SKELETON_INIT_COMMON_INSTALL_TARGET_CMDS
20*4882a593Smuzhiyun	$(call SYSTEM_RSYNC,$(SKELETON_INIT_COMMON_PATH),$(TARGET_DIR))
21*4882a593Smuzhiyun	$(call SYSTEM_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
22*4882a593Smuzhiyun	$(call SYSTEM_LIB_SYMLINK,$(TARGET_DIR))
23*4882a593Smuzhiyun	$(SED) 's,@PATH@,$(BR2_SYSTEM_DEFAULT_PATH),' $(TARGET_DIR)/etc/profile
24*4882a593Smuzhiyun	$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
25*4882a593Smuzhiyun		$(TARGET_DIR_WARNING_FILE)
26*4882a593Smuzhiyunendef
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun# We don't care much about what goes in staging, as long as it is
29*4882a593Smuzhiyun# correctly setup for merged/non-merged /usr. The simplest is to
30*4882a593Smuzhiyun# fill it in with the content of the skeleton.
31*4882a593Smuzhiyundefine SKELETON_INIT_COMMON_INSTALL_STAGING_CMDS
32*4882a593Smuzhiyun	$(call SYSTEM_RSYNC,$(SKELETON_INIT_COMMON_PATH),$(STAGING_DIR))
33*4882a593Smuzhiyun	$(call SYSTEM_USR_SYMLINKS_OR_DIRS,$(STAGING_DIR))
34*4882a593Smuzhiyun	$(call SYSTEM_LIB_SYMLINK,$(STAGING_DIR))
35*4882a593Smuzhiyun	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
36*4882a593Smuzhiyunendef
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunSKELETON_INIT_COMMON_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
39*4882a593SmuzhiyunSKELETON_INIT_COMMON_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
40*4882a593SmuzhiyunSKELETON_INIT_COMMON_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
41*4882a593SmuzhiyunSKELETON_INIT_COMMON_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
42*4882a593SmuzhiyunSKELETON_INIT_COMMON_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
43*4882a593Smuzhiyun
44*4882a593Smuzhiyunifneq ($(SKELETON_INIT_COMMON_HOSTNAME),)
45*4882a593SmuzhiyunSKELETON_INIT_COMMON_HOSTS_LINE = $(SKELETON_INIT_COMMON_HOSTNAME)
46*4882a593SmuzhiyunSKELETON_INIT_COMMON_SHORT_HOSTNAME = $(firstword $(subst ., ,$(SKELETON_INIT_COMMON_HOSTNAME)))
47*4882a593Smuzhiyunifneq ($(SKELETON_INIT_COMMON_HOSTNAME),$(SKELETON_INIT_COMMON_SHORT_HOSTNAME))
48*4882a593SmuzhiyunSKELETON_INIT_COMMON_HOSTS_LINE += $(SKELETON_INIT_COMMON_SHORT_HOSTNAME)
49*4882a593Smuzhiyunendif
50*4882a593Smuzhiyundefine SKELETON_INIT_COMMON_SET_HOSTNAME
51*4882a593Smuzhiyun	mkdir -p $(TARGET_DIR)/etc
52*4882a593Smuzhiyun	echo "$(SKELETON_INIT_COMMON_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
53*4882a593Smuzhiyun	$(SED) '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTS_LINE)' \
54*4882a593Smuzhiyun		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
55*4882a593Smuzhiyunendef
56*4882a593SmuzhiyunSKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_HOSTNAME
57*4882a593Smuzhiyunendif
58*4882a593Smuzhiyun
59*4882a593Smuzhiyunifneq ($(SKELETON_INIT_COMMON_ISSUE),)
60*4882a593Smuzhiyundefine SKELETON_INIT_COMMON_SET_ISSUE
61*4882a593Smuzhiyun	mkdir -p $(TARGET_DIR)/etc
62*4882a593Smuzhiyun	echo "$(SKELETON_INIT_COMMON_ISSUE)" > $(TARGET_DIR)/etc/issue
63*4882a593Smuzhiyunendef
64*4882a593SmuzhiyunSKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_ISSUE
65*4882a593Smuzhiyunendif
66*4882a593Smuzhiyun
67*4882a593Smuzhiyunifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
68*4882a593Smuzhiyunifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_INIT_COMMON_ROOT_PASSWD)),)
69*4882a593SmuzhiyunSKELETON_INIT_COMMON_ROOT_PASSWORD = '$(SKELETON_INIT_COMMON_ROOT_PASSWD)'
70*4882a593Smuzhiyunelse ifneq ($(SKELETON_INIT_COMMON_ROOT_PASSWD),)
71*4882a593Smuzhiyun# This variable will only be evaluated in the finalize stage, so we can
72*4882a593Smuzhiyun# be sure that host-mkpasswd will have already been built by that time.
73*4882a593SmuzhiyunSKELETON_INIT_COMMON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_INIT_COMMON_PASSWD_METHOD)" "$(SKELETON_INIT_COMMON_ROOT_PASSWD)"`"
74*4882a593Smuzhiyunendif
75*4882a593Smuzhiyunelse # !BR2_TARGET_ENABLE_ROOT_LOGIN
76*4882a593SmuzhiyunSKELETON_INIT_COMMON_ROOT_PASSWORD = "*"
77*4882a593Smuzhiyunendif
78*4882a593Smuzhiyundefine SKELETON_INIT_COMMON_SET_ROOT_PASSWD
79*4882a593Smuzhiyun	$(SED) s,^root:[^:]*:,root:$(SKELETON_INIT_COMMON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
80*4882a593Smuzhiyunendef
81*4882a593SmuzhiyunSKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_ROOT_PASSWD
82*4882a593Smuzhiyun
83*4882a593Smuzhiyunifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
84*4882a593Smuzhiyundefine SKELETON_INIT_COMMON_SET_BIN_SH
85*4882a593Smuzhiyun	rm -f $(TARGET_DIR)/bin/sh
86*4882a593Smuzhiyunendef
87*4882a593Smuzhiyunelse
88*4882a593Smuzhiyun# Add /bin/sh to /etc/shells otherwise some login tools like dropbear
89*4882a593Smuzhiyun# can reject the user connection. See man shells.
90*4882a593Smuzhiyundefine SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS
91*4882a593Smuzhiyun	grep -qsE '^/bin/sh$$' $(TARGET_DIR)/etc/shells \
92*4882a593Smuzhiyun		|| echo "/bin/sh" >> $(TARGET_DIR)/etc/shells
93*4882a593Smuzhiyunendef
94*4882a593SmuzhiyunSKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS
95*4882a593Smuzhiyunifneq ($(SKELETON_INIT_COMMON_BIN_SH),)
96*4882a593Smuzhiyundefine SKELETON_INIT_COMMON_SET_BIN_SH
97*4882a593Smuzhiyun	ln -sf $(SKELETON_INIT_COMMON_BIN_SH) $(TARGET_DIR)/bin/sh
98*4882a593Smuzhiyun	$(SED) '/^root:/s,[^/]*$$,$(SKELETON_INIT_COMMON_BIN_SH),' \
99*4882a593Smuzhiyun		$(TARGET_DIR)/etc/passwd
100*4882a593Smuzhiyunendef
101*4882a593Smuzhiyunendif
102*4882a593Smuzhiyunendif
103*4882a593SmuzhiyunSKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_BIN_SH
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun$(eval $(generic-package))
106