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
77 $(call $(TARGET)/conffiles)
80 define Package/base-files/description
81 This package contains a base filesystem and system scripts for OpenWrt.
84 define ImageConfigOptions
85 mkdir -p $(1)/lib/preinit
86 echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
87 echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
88 echo 'pi_init_path="$(TARGET_INIT_PATH)"' >>$(1)/lib/preinit/00_preinit.conf
89 echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
90 echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
91 echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
92 echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
93 echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib/preinit/00_preinit.conf
94 echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf
95 echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf
96 echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
97 echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
98 echo 'pi_preinit_no_failsafe="$(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE)"' >>$(1)/lib/preinit/00_preinit.conf
102 mkdir -p $(PKG_BUILD_DIR)
105 define Build/Compile/Default
108 Build/Compile = $(Build/Compile/Default)
110 ifdef CONFIG_SIGNED_PACKAGES
111 define Build/Configure
112 [ -s $(BUILD_KEY) -a -s $(BUILD_KEY).pub ] || \
113 $(STAGING_DIR_HOST)/bin/usign -G -s $(BUILD_KEY) -p $(BUILD_KEY).pub -c "Local build key"
115 [ -s $(BUILD_KEY).ucert ] || \
116 $(STAGING_DIR_HOST)/bin/ucert -I -c $(BUILD_KEY).ucert -p $(BUILD_KEY).pub -s $(BUILD_KEY)
120 define Package/base-files/install-key
121 mkdir -p $(1)/etc/opkg/keys
122 $(CP) $(BUILD_KEY).pub $(1)/etc/opkg/keys/`$(STAGING_DIR_HOST)/bin/usign -F -p $(BUILD_KEY).pub`
127 ifeq ($(CONFIG_NAND_SUPPORT),)
128 define Package/base-files/nand-support
129 rm -f $(1)/lib/upgrade/nand.sh
133 define Package/base-files/install
134 $(CP) ./files/* $(1)/
135 $(Package/base-files/install-key)
136 $(Package/base-files/nand-support)
137 if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
138 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
140 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
141 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
143 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
144 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
145 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
149 $(VERSION_SED_SCRIPT) \
151 $(1)/etc/openwrt_version \
152 $(1)/usr/lib/os-release
154 $(VERSION_SED_SCRIPT) \
155 $(1)/etc/openwrt_release \
156 $(1)/etc/device_info \
157 $(1)/usr/lib/os-release
159 $(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \
160 $(1)/sbin/hotplug-call \
164 mkdir -p $(1)/CONTROL
166 mkdir -p $(1)/etc/config
167 mkdir -p $(1)/etc/crontabs
168 mkdir -p $(1)/etc/rc.d
169 mkdir -p $(1)/overlay
170 mkdir -p $(1)/lib/firmware
171 $(if $(LIB_SUFFIX),-$(LN) lib $(1)/lib$(LIB_SUFFIX))
175 mkdir -p $(1)/usr/lib
176 $(if $(LIB_SUFFIX),-$(LN) lib $(1)/usr/lib$(LIB_SUFFIX))
177 mkdir -p $(1)/usr/bin
181 $(LN) /proc/mounts $(1)/etc/mtab
185 $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
187 chmod 0600 $(1)/etc/shadow
190 $(call ImageConfigOptions,$(1))
191 $(call Package/base-files/install-target,$(1))
192 for conffile in $(1)/etc/config/*; do \
193 if [ -f "$$$$conffile" ]; then \
194 grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
195 echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
199 $(if $(CONFIG_INCLUDE_CONFIG), \
200 echo -e "# Build configuration for board $(BOARD)/$(SUBTARGET)/$(PROFILE)\n" >$(1)/etc/build.config; \
201 cat $(BIN_DIR)/config.seed >>$(1)/etc/build.config)
203 $(if $(CONFIG_CLEAN_IPKG),, \
204 mkdir -p $(1)/etc/opkg; \
205 $(call FeedSourcesAppend,$(1)/etc/opkg/distfeeds.conf); \
206 $(VERSION_SED_SCRIPT) $(1)/etc/opkg/distfeeds.conf)
207 $(if $(CONFIG_IPK_FILES_CHECKSUMS), \
208 rm -f $(1)/sbin/pkg_check,)
212 -include $(PLATFORM_DIR)/base-files.mk
213 -include $(PLATFORM_SUBDIR)/base-files.mk
216 $(eval $(call BuildPackage,base-files))