1 ################################################################################
5 ################################################################################
7 # The skeleton can't depend on the toolchain, since all packages depends on the
8 # skeleton and the toolchain is a target package, as is skeleton.
9 # Hence, skeleton would depends on the toolchain and the toolchain would depend
11 SKELETON_ADD_TOOLCHAIN_DEPENDENCY
= NO
13 # The skeleton also handles the merged /usr case in the sysroot
14 SKELETON_INSTALL_STAGING
= YES
16 ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM
),y
)
18 SKELETON_PATH
= $(call qstrip
,$(BR2_ROOTFS_SKELETON_CUSTOM_PATH
))
20 ifeq ($(BR_BUILDING
),y
)
21 ifeq ($(SKELETON_PATH
),)
22 $(error No path specified for the custom skeleton
)
26 ifeq ($(BR2_ROOTFS_MERGED_USR
),y
)
28 # Ensure the user has prepared a merged /usr.
30 # Extract the inode numbers for all of those directories. In case any is
31 # a symlink, we want to get the inode of the pointed-to directory, so we
32 # append '/.' to be sure we get the target directory. Since the symlinks
33 # can be anyway (/bin -> /usr/bin or /usr/bin -> /bin), we do that for
36 SKELETON_LIB_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/lib
/.
)
37 SKELETON_BIN_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/bin
/.
)
38 SKELETON_SBIN_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/sbin
/.
)
39 SKELETON_USR_LIB_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/usr
/lib
/.
)
40 SKELETON_USR_BIN_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/usr
/bin
/.
)
41 SKELETON_USR_SBIN_INODE
= $(shell stat
-c
'%i' $(SKELETON_PATH
)/usr
/sbin
/.
)
43 ifneq ($(SKELETON_LIB_INODE
),$(SKELETON_USR_LIB_INODE
))
44 SKELETON_CUSTOM_NOT_MERGED_USR
+= /lib
46 ifneq ($(SKELETON_BIN_INODE
),$(SKELETON_USR_BIN_INODE
))
47 SKELETON_CUSTOM_NOT_MERGED_USR
+= /bin
49 ifneq ($(SKELETON_SBIN_INODE
),$(SKELETON_USR_SBIN_INODE
))
50 SKELETON_CUSTOM_NOT_MERGED_USR
+= /sbin
53 ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR
),)
54 $(error The custom skeleton in
$(SKELETON_PATH
) is not \
55 using a merged
/usr for the following directories
: \
56 $(SKELETON_CUSTOM_NOT_MERGED_USR
))
61 else # ! custom skeleton
63 SKELETON_PATH
= system
/skeleton
65 endif # ! custom skeleton
67 # This function handles the merged or non-merged /usr cases
68 ifeq ($(BR2_ROOTFS_MERGED_USR
),y
)
69 define SKELETON_USR_SYMLINKS_OR_DIRS
70 ln
-snf usr
/bin
$(1)/bin
71 ln
-snf usr
/sbin
$(1)/sbin
72 ln
-snf usr
/lib
$(1)/lib
75 define SKELETON_USR_SYMLINKS_OR_DIRS
76 $(INSTALL
) -d
-m
0755 $(1)/bin
77 $(INSTALL
) -d
-m
0755 $(1)/sbin
78 $(INSTALL
) -d
-m
0755 $(1)/lib
82 # We make a symlink lib32->lib or lib64->lib as appropriate
83 # MIPS64/n32 requires lib32 even though it's a 64-bit arch.
84 ifeq ($(BR2_ARCH_IS_64
)$(BR2_MIPS_NABI32
),y
)
85 SKELETON_LIB_SYMLINK
= lib64
87 SKELETON_LIB_SYMLINK
= lib32
90 define SKELETON_INSTALL_TARGET_CMDS
91 rsync
-a
--ignore-times
$(RSYNC_VCS_EXCLUSIONS
) \
92 --chmod
=u
=rwX
,go
=rX
--exclude .empty
--exclude
'*~' \
93 $(SKELETON_PATH
)/ $(TARGET_DIR
)/
94 $(call SKELETON_USR_SYMLINKS_OR_DIRS
,$(TARGET_DIR
))
95 ln
-snf lib
$(TARGET_DIR
)/$(SKELETON_LIB_SYMLINK
)
96 ln
-snf lib
$(TARGET_DIR
)/usr
/$(SKELETON_LIB_SYMLINK
)
97 $(INSTALL
) -m
0644 support
/misc
/target-dir-warning.txt \
98 $(TARGET_DIR_WARNING_FILE
)
101 # For the staging dir, we don't really care about /bin and /sbin.
102 # But for consistency with the target dir, and to simplify the code,
103 # we still handle them for the merged or non-merged /usr cases.
104 # Since the toolchain is not yet available, the staging is not yet
105 # populated, so we need to create the directories in /usr
106 define SKELETON_INSTALL_STAGING_CMDS
107 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/lib
108 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/bin
109 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/sbin
110 $(INSTALL
) -d
-m
0755 $(STAGING_DIR
)/usr
/include
111 $(call SKELETON_USR_SYMLINKS_OR_DIRS
,$(STAGING_DIR
))
112 ln
-snf lib
$(STAGING_DIR
)/$(SKELETON_LIB_SYMLINK
)
113 ln
-snf lib
$(STAGING_DIR
)/usr
/$(SKELETON_LIB_SYMLINK
)
116 # The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
118 ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT
),y
)
120 SKELETON_TARGET_GENERIC_HOSTNAME
= $(call qstrip
,$(BR2_TARGET_GENERIC_HOSTNAME
))
121 SKELETON_TARGET_GENERIC_ISSUE
= $(call qstrip
,$(BR2_TARGET_GENERIC_ISSUE
))
122 SKELETON_TARGET_GENERIC_ROOT_PASSWD
= $(call qstrip
,$(BR2_TARGET_GENERIC_ROOT_PASSWD
))
123 SKELETON_TARGET_GENERIC_PASSWD_METHOD
= $(call qstrip
,$(BR2_TARGET_GENERIC_PASSWD_METHOD
))
124 SKELETON_TARGET_GENERIC_BIN_SH
= $(call qstrip
,$(BR2_SYSTEM_BIN_SH
))
125 SKELETON_TARGET_GENERIC_GETTY_PORT
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_PORT
))
126 SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE
))
127 SKELETON_TARGET_GENERIC_GETTY_TERM
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_TERM
))
128 SKELETON_TARGET_GENERIC_GETTY_OPTIONS
= $(call qstrip
,$(BR2_TARGET_GENERIC_GETTY_OPTIONS
))
130 ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME
),)
131 define SKELETON_SET_HOSTNAME
132 mkdir
-p
$(TARGET_DIR
)/etc
133 echo
"$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR
)/etc
/hostname
134 $(SED
) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
135 -e
'/^127.0.1.1/d' $(TARGET_DIR
)/etc
/hosts
137 TARGET_FINALIZE_HOOKS
+= SKELETON_SET_HOSTNAME
140 ifneq ($(SKELETON_TARGET_GENERIC_ISSUE
),)
141 define SKELETON_SET_ISSUE
142 mkdir
-p
$(TARGET_DIR
)/etc
143 echo
"$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR
)/etc
/issue
145 TARGET_FINALIZE_HOOKS
+= SKELETON_SET_ISSUE
148 define SKELETON_SET_NETWORK_LOCALHOST
150 echo
"# interface file auto-generated by buildroot"; \
153 echo
"iface lo inet loopback"; \
154 ) > $(TARGET_DIR
)/etc
/network
/interfaces
157 SKELETON_NETWORK_DHCP_IFACE
= $(call qstrip
,$(BR2_SYSTEM_DHCP
))
159 ifneq ($(SKELETON_NETWORK_DHCP_IFACE
),)
160 define SKELETON_SET_NETWORK_DHCP
163 echo
"auto $(SKELETON_NETWORK_DHCP_IFACE)"; \
164 echo
"iface $(SKELETON_NETWORK_DHCP_IFACE) inet dhcp"; \
165 echo
" pre-up /etc/network/nfs_check"; \
166 echo
" wait-delay 15"; \
167 ) >> $(TARGET_DIR
)/etc
/network
/interfaces
168 $(INSTALL
) -m
0755 -D
$(SKELETON_PKGDIR
)/nfs_check \
169 $(TARGET_DIR
)/etc
/network
/nfs_check
173 define SKELETON_SET_NETWORK
174 mkdir
-p
$(TARGET_DIR
)/etc
/network
/
175 $(SKELETON_SET_NETWORK_LOCALHOST
)
176 $(SKELETON_SET_NETWORK_DHCP
)
179 TARGET_FINALIZE_HOOKS
+= SKELETON_SET_NETWORK
181 ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN
),y
)
182 ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD
),)
183 SKELETON_ROOT_PASSWORD
=
184 else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD
)),)
185 SKELETON_ROOT_PASSWORD
= '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
187 SKELETON_DEPENDENCIES
+= host-mkpasswd
188 # This variable will only be evaluated in the finalize stage, so we can
189 # be sure that host-mkpasswd will have already been built by that time.
190 SKELETON_ROOT_PASSWORD
= "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD
)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD
)"`"
192 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
193 SKELETON_ROOT_PASSWORD
= "*"
196 define SKELETON_SET_ROOT_PASSWD
197 $(SED
) s
,^root
:[^
:]*:,root
:$(SKELETON_ROOT_PASSWORD
):, $(TARGET_DIR
)/etc
/shadow
199 TARGET_FINALIZE_HOOKS
+= SKELETON_SET_ROOT_PASSWD
201 ifeq ($(BR2_SYSTEM_BIN_SH_NONE
),y
)
202 define SKELETON_BIN_SH
203 rm -f
$(TARGET_DIR
)/bin
/sh
206 define SKELETON_BIN_SH
207 ln
-sf
$(SKELETON_TARGET_GENERIC_BIN_SH
) $(TARGET_DIR
)/bin
/sh
210 TARGET_FINALIZE_HOOKS
+= SKELETON_BIN_SH
212 ifeq ($(BR2_TARGET_GENERIC_GETTY
),y
)
213 ifeq ($(BR2_INIT_SYSV
),y
)
214 # In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
215 # skip the "tty" part and keep only the remaining.
216 define SKELETON_SET_GETTY
217 $(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) #~' \
218 $(TARGET_DIR
)/etc
/inittab
220 else ifeq ($(BR2_INIT_BUSYBOX
),y
)
221 # Add getty to busybox inittab
222 define SKELETON_SET_GETTY
223 $(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) #~' \
224 $(TARGET_DIR
)/etc
/inittab
227 TARGET_FINALIZE_HOOKS
+= SKELETON_SET_GETTY
230 ifeq ($(BR2_INIT_BUSYBOX
)$(BR2_INIT_SYSV
),y
)
231 ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
),y
)
232 # Find commented line, if any, and remove leading '#'s
233 define SKELETON_REMOUNT_RW
234 $(SED
) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR
)/etc
/inittab
237 # Find uncommented line, if any, and add a leading '#'
238 define SKELETON_REMOUNT_RW
239 $(SED
) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR
)/etc
/inittab
242 TARGET_FINALIZE_HOOKS
+= SKELETON_REMOUNT_RW
243 endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
245 endif # BR2_ROOTFS_SKELETON_DEFAULT
247 $(eval
$(generic-package
))