2 # Copyright (C) 2007-2016 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 include $(TOPDIR
)/rules.mk
10 include $(INCLUDE_DIR
)/kernel.mk
11 include $(INCLUDE_DIR
)/version.mk
12 include $(INCLUDE_DIR
)/feeds.mk
18 PKG_FILE_DEPENDS
:=$(PLATFORM_DIR
)/ $(GENERIC_PLATFORM_DIR
)/base-files
/
19 PKG_BUILD_DEPENDS
:=usign
/host ucert
/host
22 # Extend depends from version.mk
23 PKG_CONFIG_DEPENDS
+= \
24 CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE \
27 CONFIG_PER_FEED_REPO \
28 $(foreach feed
,$(FEEDS_AVAILABLE
),CONFIG_FEED_
$(feed
))
30 include $(INCLUDE_DIR
)/package.mk
33 STAMP_CONFIGURED
:=$(strip $(STAMP_CONFIGURED
))_
$(shell echo
$(CONFIG_TARGET_INIT_PATH
) | mkhash md5
)
37 define Package
/base-files
40 DEPENDS
:=+netifd
+libc
+procd
+jsonfilter
+SIGNED_PACKAGES
:usign
+SIGNED_PACKAGES
:openwrt-keyring
+NAND_SUPPORT
:ubi-utils
+fstools
+fwtool
41 TITLE
:=Base filesystem for OpenWrt
42 URL
:=http
://openwrt.org
/
43 VERSION
:=$(PKG_RELEASE
)-$(REVISION
)
46 define Package
/urandom-seed
49 DEPENDS
:=+libc
+ubox-getrandom
50 TITLE
:=/etc
/urandom.seed handling for OpenWrt
51 URL
:=http
://openwrt.org
/
52 VERSION
:=$(PKG_RELEASE
)-$(REVISION
)
55 define Package
/base-files
/conffiles
65 /etc
/iproute2
/rt_protos
66 /etc
/iproute2
/rt_tables
78 $(call
$(TARGET
)/conffiles
)
81 define Package
/base-files
/description
82 This package contains a base filesystem and system scripts for OpenWrt.
85 define ImageConfigOptions
86 mkdir
-p
$(1)/lib
/preinit
87 echo
'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib
/preinit
/00_preinit.conf
88 echo
'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib
/preinit
/00_preinit.conf
89 echo
'pi_init_path="$(TARGET_INIT_PATH)"' >>$(1)/lib
/preinit
/00_preinit.conf
90 echo
'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib
/preinit
/00_preinit.conf
91 echo
'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib
/preinit
/00_preinit.conf
92 echo
'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib
/preinit
/00_preinit.conf
93 echo
'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib
/preinit
/00_preinit.conf
94 echo
'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib
/preinit
/00_preinit.conf
95 echo
'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib
/preinit
/00_preinit.conf
96 echo
'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib
/preinit
/00_preinit.conf
97 echo
'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib
/preinit
/00_preinit.conf
98 echo
'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib
/preinit
/00_preinit.conf
99 echo
'pi_preinit_no_failsafe="$(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE)"' >>$(1)/lib
/preinit
/00_preinit.conf
103 mkdir
-p
$(PKG_BUILD_DIR
)
106 define Build
/Compile
/Default
109 Build
/Compile
= $(Build
/Compile
/Default
)
111 ifdef CONFIG_SIGNED_PACKAGES
112 define Build
/Configure
113 [ -s
$(BUILD_KEY
) -a
-s
$(BUILD_KEY
).pub
] || \
114 $(STAGING_DIR_HOST
)/bin
/usign
-G
-s
$(BUILD_KEY
) -p
$(BUILD_KEY
).pub
-c
"Local build key"
116 [ -s
$(BUILD_KEY
).ucert
] || \
117 $(STAGING_DIR_HOST
)/bin
/ucert
-I
-c
$(BUILD_KEY
).ucert
-p
$(BUILD_KEY
).pub
-s
$(BUILD_KEY
)
121 define Package
/base-files
/install-key
122 mkdir
-p
$(1)/etc
/opkg
/keys
123 $(CP
) $(BUILD_KEY
).pub
$(1)/etc
/opkg
/keys
/`$(STAGING_DIR_HOST)/bin/usign -F -p $(BUILD_KEY).pub`
128 ifeq ($(CONFIG_NAND_SUPPORT
),)
129 define Package
/base-files
/nand-support
130 rm -f
$(1)/lib
/upgrade
/nand.sh
134 define Package
/base-files
/install
135 $(CP
) .
/files
/* $(1)/
136 $(Package
/base-files
/install-key
)
137 $(Package
/base-files
/nand-support
)
138 if
[ -d
$(GENERIC_PLATFORM_DIR
)/base-files
/.
]; then \
139 $(CP
) $(GENERIC_PLATFORM_DIR
)/base-files
/* $(1)/; \
141 if
[ -d
$(PLATFORM_DIR
)/base-files
/.
]; then \
142 $(CP
) $(PLATFORM_DIR
)/base-files
/* $(1)/; \
144 $(if
$(filter-out $(PLATFORM_DIR
),$(PLATFORM_SUBDIR
)), \
145 if
[ -d
$(PLATFORM_SUBDIR
)/base-files
/.
]; then \
146 $(CP
) $(PLATFORM_SUBDIR
)/base-files
/* $(1)/; \
150 $(VERSION_SED_SCRIPT
) \
152 $(1)/etc
/openwrt_version \
153 $(1)/usr
/lib
/os-release
155 $(VERSION_SED_SCRIPT
) \
156 $(1)/etc
/openwrt_release \
157 $(1)/etc
/device_info \
158 $(1)/usr
/lib
/os-release
160 $(SED
) "s#%PATH%#$(TARGET_INIT_PATH)#g" \
161 $(1)/sbin
/hotplug-call \
165 mkdir
-p
$(1)/CONTROL
167 mkdir
-p
$(1)/etc
/config
168 mkdir
-p
$(1)/etc
/crontabs
169 mkdir
-p
$(1)/etc
/rc.d
170 mkdir
-p
$(1)/overlay
171 mkdir
-p
$(1)/lib
/firmware
172 $(if
$(LIB_SUFFIX
),-$(LN
) lib
$(1)/lib
$(LIB_SUFFIX
))
176 mkdir
-p
$(1)/usr
/lib
177 $(if
$(LIB_SUFFIX
),-$(LN
) lib
$(1)/usr
/lib
$(LIB_SUFFIX
))
178 mkdir
-p
$(1)/usr
/bin
182 $(LN
) /proc
/mounts
$(1)/etc
/mtab
186 $(LN
) /tmp
/resolv.conf
/tmp
/TZ
/tmp
/localtime
$(1)/etc
/
188 chmod
0600 $(1)/etc
/shadow
191 $(call ImageConfigOptions
,$(1))
192 $(call Package
/base-files
/install-target
,$(1))
193 for conffile in
$(1)/etc
/config
/*; do \
194 if
[ -f
"$$$$conffile" ]; then \
195 grep
"$$$${conffile##$(1)}" $(1)/CONTROL
/conffiles || \
196 echo
"$$$${conffile##$(1)}" >> $(1)/CONTROL
/conffiles
; \
200 $(if
$(CONFIG_INCLUDE_CONFIG
), \
201 echo
-e
"# Build configuration for board $(BOARD)/$(SUBTARGET)/$(PROFILE)\n" >$(1)/etc
/build.config
; \
202 cat
$(BIN_DIR
)/config.buildinfo
>>$(1)/etc
/build.config
; \
203 cat
$(BIN_DIR
)/feeds.buildinfo
>>$(1)/etc
/build.feeds
; \
204 cat
$(BIN_DIR
)/version.buildinfo
>>$(1)/etc
/build.version
)
206 $(if
$(CONFIG_CLEAN_IPKG
),, \
207 mkdir
-p
$(1)/etc
/opkg
; \
208 $(call FeedSourcesAppend
,$(1)/etc
/opkg
/distfeeds.conf
); \
209 $(VERSION_SED_SCRIPT
) $(1)/etc
/opkg
/distfeeds.conf
)
210 $(if
$(CONFIG_IPK_FILES_CHECKSUMS
),, \
211 rm -f
$(1)/sbin
/pkg_check
)
215 -include $(PLATFORM_DIR
)/base-files.mk
216 -include $(PLATFORM_SUBDIR
)/base-files.mk
219 $(eval
$(call BuildPackage
,base-files
))