1 ################################################################################
5 ################################################################################
7 # source included in buildroot
10 # The skeleton can't depend on the toolchain, since all packages depends on the
11 # skeleton and the toolchain is a target package, as is skeleton.
12 # Hence, skeleton would depends on the toolchain and the toolchain would depend
14 SKELETON_ADD_TOOLCHAIN_DEPENDENCY
= NO
16 # The skeleton also handles the merged /usr case in the sysroot
17 SKELETON_INSTALL_STAGING
= YES
19 ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM
),y
)
21 SKELETON_PATH
= $(call qstrip
,$(BR2_ROOTFS_SKELETON_CUSTOM_PATH
))
23 ifeq ($(BR2_ROOTFS_MERGED_USR
),y
)
25 # Ensure the user has prepared a merged /usr.
27 # Extract the inode numbers for all of those directories. In case any is
28 # a symlink, we want to get the inode of the pointed-to directory, so we
29 # append '/.' to be sure we get the target directory. Since the symlinks
30 # can be anyway (/bin -> /usr/bin or /usr/bin -> /bin), we do that for
33 SKELETON_LIB_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/lib
/.
)
34 SKELETON_BIN_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/bin
/.
)
35 SKELETON_SBIN_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/sbin
/.
)
36 SKELETON_USR_LIB_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/usr
/lib
/.
)
37 SKELETON_USR_BIN_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/usr
/bin
/.
)
38 SKELETON_USR_SBIN_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/usr
/sbin
/.
)
40 ifneq ($(SKELETON_LIB_INODE
),$(SKELETON_USR_LIB_INODE
))
41 SKELETON_CUSTOM_NOT_MERGED_USR
+= /lib
43 ifneq ($(SKELETON_BIN_INODE
),$(SKELETON_USR_BIN_INODE
))
44 SKELETON_CUSTOM_NOT_MERGED_USR
+= /bin
46 ifneq ($(SKELETON_SBIN_INODE
),$(SKELETON_USR_SBIN_INODE
))
47 SKELETON_CUSTOM_NOT_MERGED_USR
+= /sbin
50 ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR
),)
51 $(error Use of systemd
as an init system requires a merged
/usr. \
52 However
, the custom skeleton in
$(SKELETON_PATH
) is not \
53 using a merged
/usr for the following directories
: \
54 $(SKELETON_CUSTOM_NOT_MERGED_USR
))
59 else # ! custom skeleton
61 SKELETON_PATH
= system
/skeleton
63 endif # ! custom skeleton
65 # This function handles the merged or non-merged /usr cases
66 ifeq ($(BR2_ROOTFS_MERGED_USR
),y
)
67 define SKELETON_USR_SYMLINKS_OR_DIRS
68 ln
-snf usr
/bin
$(1)/bin
69 ln
-snf usr
/sbin
$(1)/sbin
70 ln
-snf usr
/lib
$(1)/lib
73 define SKELETON_USR_SYMLINKS_OR_DIRS
74 $(INSTALL
) -d
-m
0755 $(1)/bin
75 $(INSTALL
) -d
-m
0755 $(1)/sbin
76 $(INSTALL
) -d
-m
0755 $(1)/lib
80 define SKELETON_INSTALL_TARGET_CMDS
81 rsync
-a
--ignore-times
$(SYNC_VCS_EXCLUSIONS
) \
82 --chmod
=u
=rwX
,go
=rX
--exclude .empty
--exclude
'*~' \
83 $(SKELETON_PATH
)/ $(TARGET_DIR
)/
84 $(call SKELETON_USR_SYMLINKS_OR_DIRS
,$(TARGET_DIR
))
85 ln
-snf lib
$(TARGET_DIR
)/$(LIB_SYMLINK
)
86 ln
-snf lib
$(TARGET_DIR
)/usr
/$(LIB_SYMLINK
)
87 $(INSTALL
) -m
0644 support
/misc
/target-dir-warning.txt \
88 $(TARGET_DIR_WARNING_FILE
)
91 # For the staging dir, we don't really care about /bin and /sbin.
92 # But for consistency with the target dir, and to simplify the code,
93 # we still handle them for the merged or non-merged /usr cases.
94 # Since the toolchain is not yet available, the staging is not yet
95 # populated, so we need to create the directories in /usr
96 define SKELETON_INSTALL_STAGING_CMDS
97 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/lib
98 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/bin
99 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/sbin
100 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/include
101 $(call SKELETON_USR_SYMLINKS_OR_DIRS
,$(STAGING_DIR
))
102 ln
-snf lib
$(STAGING_DIR
)/$(LIB_SYMLINK
)
103 ln
-snf lib
$(STAGING_DIR
)/usr
/$(LIB_SYMLINK
)
106 SKELETON_TARGET_GENERIC_HOSTNAME
= $(call qstrip
,$(BR2_TARGET_GENERIC_HOSTNAME
))
107 SKELETON_TARGET_GENERIC_ISSUE
= $(call qstrip
,$(BR2_TARGET_GENERIC_ISSUE
))
108 SKELETON_TARGET_GENERIC_ROOT_PASSWD
= $(call qstrip
,$(BR2_TARGET_GENERIC_ROOT_PASSWD
))
109 SKELETON_TARGET_GENERIC_PASSWD_METHOD
= $(call qstrip
,$(BR2_TARGET_GENERIC_PASSWD_METHOD
))
110 SKELETON_TARGET_GENERIC_BIN_SH
= $(call qstrip
,$(BR2_SYSTEM_BIN_SH
))
111 SKELETON_TARGET_GENERIC_GETTY_PORT
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_PORT
))
112 SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE
))
113 SKELETON_TARGET_GENERIC_GETTY_TERM
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_TERM
))
114 SKELETON_TARGET_GENERIC_GETTY_OPTIONS
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_OPTIONS
))
116 ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME
),)
117 define SYSTEM_HOSTNAME
118 mkdir
-p
$(TARGET_DIR
)/etc
119 echo
"$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR
)/etc
/hostname
120 $(SED
) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
121 -e
'/^127.0.1.1/d' $(TARGET_DIR
)/etc
/hosts
123 TARGET_FINALIZE_HOOKS
+= SYSTEM_HOSTNAME
126 ifneq ($(SKELETON_TARGET_GENERIC_ISSUE
),)
128 mkdir
-p
$(TARGET_DIR
)/etc
129 echo
"$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR
)/etc
/issue
131 TARGET_FINALIZE_HOOKS
+= SYSTEM_ISSUE
134 define SET_NETWORK_LOCALHOST
136 echo
"# interface file auto-generated by buildroot"; \
139 echo
"iface lo inet loopback"; \
140 ) > $(TARGET_DIR
)/etc
/network
/interfaces
143 NETWORK_DHCP_IFACE
= $(call qstrip
,$(BR2_SYSTEM_DHCP
))
145 ifneq ($(NETWORK_DHCP_IFACE
),)
146 define SET_NETWORK_DHCP
149 echo
"auto $(NETWORK_DHCP_IFACE)"; \
150 echo
"iface $(NETWORK_DHCP_IFACE) inet dhcp"; \
151 echo
" pre-up /etc/network/nfs_check"; \
152 echo
" wait-delay 15"; \
153 ) >> $(TARGET_DIR
)/etc
/network
/interfaces
154 $(INSTALL
) -m
0755 -D
$(SKELETON_PKGDIR
)/nfs_check \
155 $(TARGET_DIR
)/etc
/network
/nfs_check
160 mkdir
-p
$(TARGET_DIR
)/etc
/network
/
161 $(SET_NETWORK_LOCALHOST
)
165 TARGET_FINALIZE_HOOKS
+= SET_NETWORK
167 # The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
169 ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT
),y
)
171 ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN
),y
)
172 ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD
),)
173 SYSTEM_ROOT_PASSWORD
=
174 else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD
)),)
175 SYSTEM_ROOT_PASSWORD
= '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
177 SKELETON_DEPENDENCIES
+= host-mkpasswd
178 # This variable will only be evaluated in the finalize stage, so we can
179 # be sure that host-mkpasswd will have already been built by that time.
180 SYSTEM_ROOT_PASSWORD
= "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD
)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD
)"`"
182 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
183 SYSTEM_ROOT_PASSWORD
= "*"
186 define SKELETON_SYSTEM_SET_ROOT_PASSWD
187 $(SED
) s
,^root
:[^
:]*:,root
:$(SYSTEM_ROOT_PASSWORD
):, $(TARGET_DIR
)/etc
/shadow
189 TARGET_FINALIZE_HOOKS
+= SKELETON_SYSTEM_SET_ROOT_PASSWD
191 ifeq ($(BR2_SYSTEM_BIN_SH_NONE
),y
)
192 define SKELETON_SYSTEM_BIN_SH
193 rm -f
$(TARGET_DIR
)/bin
/sh
196 define SKELETON_SYSTEM_BIN_SH
197 ln
-sf
$(SKELETON_TARGET_GENERIC_BIN_SH
) $(TARGET_DIR
)/bin
/sh
200 TARGET_FINALIZE_HOOKS
+= SKELETON_SYSTEM_BIN_SH
202 ifeq ($(BR2_TARGET_GENERIC_GETTY
),y
)
203 ifeq ($(BR2_INIT_SYSV
),y
)
204 # In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
205 # skip the "tty" part and keep only the remaining.
206 define SKELETON_SYSTEM_GETTY
207 $(SED
) '/# GENERIC_SERIAL$$/s~^.*#~$(shell echo $(SKELETON_TARGET_GENERIC_GETTY_PORT) | tail -c+4)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
208 $(TARGET_DIR
)/etc
/inittab
210 else ifeq ($(BR2_INIT_BUSYBOX
),y
)
211 # Add getty to busybox inittab
212 define SKELETON_SYSTEM_GETTY
213 $(SED
) '/# GENERIC_SERIAL$$/s~^.*#~$(SKELETON_TARGET_GENERIC_GETTY_PORT)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
214 $(TARGET_DIR
)/etc
/inittab
217 TARGET_FINALIZE_HOOKS
+= SKELETON_SYSTEM_GETTY
220 ifeq ($(BR2_INIT_BUSYBOX
)$(BR2_INIT_SYSV
),y
)
221 ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
),y
)
222 # Find commented line, if any, and remove leading '#'s
223 define SKELETON_SYSTEM_REMOUNT_RW
224 $(SED
) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR
)/etc
/inittab
227 # Find uncommented line, if any, and add a leading '#'
228 define SKELETON_SYSTEM_REMOUNT_RW
229 $(SED
) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR
)/etc
/inittab
232 TARGET_FINALIZE_HOOKS
+= SKELETON_SYSTEM_REMOUNT_RW
233 endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
235 endif # BR2_ROOTFS_SKELETON_DEFAULT
237 $(eval
$(generic-package
))