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 # We make a symlink lib32->lib or lib64->lib as appropriate
81 # MIPS64/n32 requires lib32 even though it's a 64-bit arch.
82 ifeq ($(BR2_ARCH_IS_64
)$(BR2_MIPS_NABI32
),y
)
83 SKELETON_LIB_SYMLINK
= lib64
85 SKELETON_LIB_SYMLINK
= lib32
88 define SKELETON_INSTALL_TARGET_CMDS
89 rsync
-a
--ignore-times
$(RSYNC_VCS_EXCLUSIONS
) \
90 --chmod
=u
=rwX
,go
=rX
--exclude .empty
--exclude
'*~' \
91 $(SKELETON_PATH
)/ $(TARGET_DIR
)/
92 $(call SKELETON_USR_SYMLINKS_OR_DIRS
,$(TARGET_DIR
))
93 ln
-snf lib
$(TARGET_DIR
)/$(SKELETON_LIB_SYMLINK
)
94 ln
-snf lib
$(TARGET_DIR
)/usr
/$(SKELETON_LIB_SYMLINK
)
95 $(INSTALL
) -m
0644 support
/misc
/target-dir-warning.txt \
96 $(TARGET_DIR_WARNING_FILE
)
99 # For the staging dir, we don't really care about /bin and /sbin.
100 # But for consistency with the target dir, and to simplify the code,
101 # we still handle them for the merged or non-merged /usr cases.
102 # Since the toolchain is not yet available, the staging is not yet
103 # populated, so we need to create the directories in /usr
104 define SKELETON_INSTALL_STAGING_CMDS
105 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/lib
106 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/bin
107 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/sbin
108 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/include
109 $(call SKELETON_USR_SYMLINKS_OR_DIRS
,$(STAGING_DIR
))
110 ln
-snf lib
$(STAGING_DIR
)/$(SKELETON_LIB_SYMLINK
)
111 ln
-snf lib
$(STAGING_DIR
)/usr
/$(SKELETON_LIB_SYMLINK
)
114 SKELETON_TARGET_GENERIC_HOSTNAME
= $(call qstrip
,$(BR2_TARGET_GENERIC_HOSTNAME
))
115 SKELETON_TARGET_GENERIC_ISSUE
= $(call qstrip
,$(BR2_TARGET_GENERIC_ISSUE
))
116 SKELETON_TARGET_GENERIC_ROOT_PASSWD
= $(call qstrip
,$(BR2_TARGET_GENERIC_ROOT_PASSWD
))
117 SKELETON_TARGET_GENERIC_PASSWD_METHOD
= $(call qstrip
,$(BR2_TARGET_GENERIC_PASSWD_METHOD
))
118 SKELETON_TARGET_GENERIC_BIN_SH
= $(call qstrip
,$(BR2_SYSTEM_BIN_SH
))
119 SKELETON_TARGET_GENERIC_GETTY_PORT
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_PORT
))
120 SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE
))
121 SKELETON_TARGET_GENERIC_GETTY_TERM
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_TERM
))
122 SKELETON_TARGET_GENERIC_GETTY_OPTIONS
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_OPTIONS
))
124 ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME
),)
125 define SYSTEM_HOSTNAME
126 mkdir
-p
$(TARGET_DIR
)/etc
127 echo
"$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR
)/etc
/hostname
128 $(SED
) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
129 -e
'/^127.0.1.1/d' $(TARGET_DIR
)/etc
/hosts
131 TARGET_FINALIZE_HOOKS
+= SYSTEM_HOSTNAME
134 ifneq ($(SKELETON_TARGET_GENERIC_ISSUE
),)
136 mkdir
-p
$(TARGET_DIR
)/etc
137 echo
"$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR
)/etc
/issue
139 TARGET_FINALIZE_HOOKS
+= SYSTEM_ISSUE
142 define SET_NETWORK_LOCALHOST
144 echo
"# interface file auto-generated by buildroot"; \
147 echo
"iface lo inet loopback"; \
148 ) > $(TARGET_DIR
)/etc
/network
/interfaces
151 NETWORK_DHCP_IFACE
= $(call qstrip
,$(BR2_SYSTEM_DHCP
))
153 ifneq ($(NETWORK_DHCP_IFACE
),)
154 define SET_NETWORK_DHCP
157 echo
"auto $(NETWORK_DHCP_IFACE)"; \
158 echo
"iface $(NETWORK_DHCP_IFACE) inet dhcp"; \
159 echo
" pre-up /etc/network/nfs_check"; \
160 echo
" wait-delay 15"; \
161 ) >> $(TARGET_DIR
)/etc
/network
/interfaces
162 $(INSTALL
) -m
0755 -D
$(SKELETON_PKGDIR
)/nfs_check \
163 $(TARGET_DIR
)/etc
/network
/nfs_check
168 mkdir
-p
$(TARGET_DIR
)/etc
/network
/
169 $(SET_NETWORK_LOCALHOST
)
173 TARGET_FINALIZE_HOOKS
+= SET_NETWORK
175 # The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
177 ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT
),y
)
179 ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN
),y
)
180 ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD
),)
181 SYSTEM_ROOT_PASSWORD
=
182 else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD
)),)
183 SYSTEM_ROOT_PASSWORD
= '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
185 SKELETON_DEPENDENCIES
+= host-mkpasswd
186 # This variable will only be evaluated in the finalize stage, so we can
187 # be sure that host-mkpasswd will have already been built by that time.
188 SYSTEM_ROOT_PASSWORD
= "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD
)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD
)"`"
190 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
191 SYSTEM_ROOT_PASSWORD
= "*"
194 define SKELETON_SYSTEM_SET_ROOT_PASSWD
195 $(SED
) s
,^root
:[^
:]*:,root
:$(SYSTEM_ROOT_PASSWORD
):, $(TARGET_DIR
)/etc
/shadow
197 TARGET_FINALIZE_HOOKS
+= SKELETON_SYSTEM_SET_ROOT_PASSWD
199 ifeq ($(BR2_SYSTEM_BIN_SH_NONE
),y
)
200 define SKELETON_SYSTEM_BIN_SH
201 rm -f
$(TARGET_DIR
)/bin
/sh
204 define SKELETON_SYSTEM_BIN_SH
205 ln
-sf
$(SKELETON_TARGET_GENERIC_BIN_SH
) $(TARGET_DIR
)/bin
/sh
208 TARGET_FINALIZE_HOOKS
+= SKELETON_SYSTEM_BIN_SH
210 ifeq ($(BR2_TARGET_GENERIC_GETTY
),y
)
211 ifeq ($(BR2_INIT_SYSV
),y
)
212 # In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
213 # skip the "tty" part and keep only the remaining.
214 define SKELETON_SYSTEM_GETTY
215 $(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) #~' \
216 $(TARGET_DIR
)/etc
/inittab
218 else ifeq ($(BR2_INIT_BUSYBOX
),y
)
219 # Add getty to busybox inittab
220 define SKELETON_SYSTEM_GETTY
221 $(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) #~' \
222 $(TARGET_DIR
)/etc
/inittab
225 TARGET_FINALIZE_HOOKS
+= SKELETON_SYSTEM_GETTY
228 ifeq ($(BR2_INIT_BUSYBOX
)$(BR2_INIT_SYSV
),y
)
229 ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
),y
)
230 # Find commented line, if any, and remove leading '#'s
231 define SKELETON_SYSTEM_REMOUNT_RW
232 $(SED
) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR
)/etc
/inittab
235 # Find uncommented line, if any, and add a leading '#'
236 define SKELETON_SYSTEM_REMOUNT_RW
237 $(SED
) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR
)/etc
/inittab
240 TARGET_FINALIZE_HOOKS
+= SKELETON_SYSTEM_REMOUNT_RW
241 endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
243 endif # BR2_ROOTFS_SKELETON_DEFAULT
245 $(eval
$(generic-package
))