base-files: do not source system.sh in functions.sh
[openwrt/openwrt.git] / package / base-files / Makefile
1 #
2 # Copyright (C) 2007-2016 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11 include $(INCLUDE_DIR)/version.mk
12 include $(INCLUDE_DIR)/feeds.mk
13
14 PKG_NAME:=base-files
15 PKG_RELEASE:=216
16 PKG_FLAGS:=nonshared
17
18 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
19 PKG_BUILD_DEPENDS:=usign/host ucert/host
20 PKG_LICENSE:=GPL-2.0
21
22 # Extend depends from version.mk
23 PKG_CONFIG_DEPENDS += \
24 CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE \
25 CONFIG_NAND_SUPPORT \
26 CONFIG_CLEAN_IPKG \
27 CONFIG_PER_FEED_REPO \
28 $(foreach feed,$(FEEDS_AVAILABLE),CONFIG_FEED_$(feed))
29
30 include $(INCLUDE_DIR)/package.mk
31
32 ifneq ($(DUMP),1)
33 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | mkhash md5)
34 TARGET:=-$(BOARD)
35 endif
36
37 define Package/base-files
38 SECTION:=base
39 CATEGORY:=Base system
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)
44 endef
45
46 define Package/urandom-seed
47 SECTION:=base
48 CATEGORY:=Base system
49 DEPENDS:=+libc +ubox-getrandom
50 TITLE:=/etc/urandom.seed handling for OpenWrt
51 URL:=http://openwrt.org/
52 VERSION:=$(PKG_RELEASE)-$(REVISION)
53 endef
54
55 define Package/base-files/conffiles
56 /etc/config/
57 /etc/config/network
58 /etc/config/system
59 /etc/crontabs/
60 /etc/dropbear/
61 /etc/ethers
62 /etc/group
63 /etc/hosts
64 /etc/inittab
65 /etc/iproute2/rt_protos
66 /etc/iproute2/rt_tables
67 /etc/passwd
68 /etc/profile
69 /etc/profile.d
70 /etc/protocols
71 /etc/rc.local
72 /etc/services
73 /etc/shadow
74 /etc/shells
75 /etc/shinit
76 /etc/sysctl.conf
77 /etc/sysupgrade.conf
78 $(call $(TARGET)/conffiles)
79 endef
80
81 define Package/base-files/description
82 This package contains a base filesystem and system scripts for OpenWrt.
83 endef
84
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
100 endef
101
102 define Build/Prepare
103 mkdir -p $(PKG_BUILD_DIR)
104 endef
105
106 define Build/Compile/Default
107
108 endef
109 Build/Compile = $(Build/Compile/Default)
110
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"
115
116 [ -s $(BUILD_KEY).ucert ] || \
117 $(STAGING_DIR_HOST)/bin/ucert -I -c $(BUILD_KEY).ucert -p $(BUILD_KEY).pub -s $(BUILD_KEY)
118
119 endef
120
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`
124
125 endef
126 endif
127
128 ifeq ($(CONFIG_NAND_SUPPORT),)
129 define Package/base-files/nand-support
130 rm -f $(1)/lib/upgrade/nand.sh
131 endef
132 endif
133
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)/; \
140 fi
141 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
142 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
143 fi
144 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
145 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
146 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
147 fi; \
148 )
149
150 $(VERSION_SED_SCRIPT) \
151 $(1)/etc/banner \
152 $(1)/etc/openwrt_version \
153 $(1)/usr/lib/os-release
154
155 $(VERSION_SED_SCRIPT) \
156 $(1)/etc/openwrt_release \
157 $(1)/etc/device_info \
158 $(1)/usr/lib/os-release
159
160 $(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \
161 $(1)/sbin/hotplug-call \
162 $(1)/etc/preinit \
163 $(1)/etc/profile
164
165 mkdir -p $(1)/CONTROL
166 mkdir -p $(1)/dev
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))
173 mkdir -p $(1)/mnt
174 mkdir -p $(1)/proc
175 mkdir -p $(1)/tmp
176 mkdir -p $(1)/usr/lib
177 $(if $(LIB_SUFFIX),-$(LN) lib $(1)/usr/lib$(LIB_SUFFIX))
178 mkdir -p $(1)/usr/bin
179 mkdir -p $(1)/sys
180 mkdir -p $(1)/www
181 mkdir -p $(1)/root
182 $(LN) /proc/mounts $(1)/etc/mtab
183 rm -f $(1)/var
184 $(LN) tmp $(1)/var
185 mkdir -p $(1)/etc
186 $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
187
188 chmod 0600 $(1)/etc/shadow
189 chmod 1777 $(1)/tmp
190
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; \
197 fi \
198 done
199
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)
205
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)
212 endef
213
214 ifneq ($(DUMP),1)
215 -include $(PLATFORM_DIR)/base-files.mk
216 -include $(PLATFORM_SUBDIR)/base-files.mk
217 endif
218
219 $(eval $(call BuildPackage,base-files))