TODO: lantiq: dts: overhaul pci(e) nodes
[openwrt/staging/mkresin.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:=203
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/sysctl.conf
76 /etc/sysupgrade.conf
77 $(call $(TARGET)/conffiles)
78 endef
79
80 define Package/base-files/description
81 This package contains a base filesystem and system scripts for OpenWrt.
82 endef
83
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
99 endef
100
101 define Build/Prepare
102 mkdir -p $(PKG_BUILD_DIR)
103 endef
104
105 define Build/Compile/Default
106
107 endef
108 Build/Compile = $(Build/Compile/Default)
109
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"
114
115 [ -s $(BUILD_KEY).ucert ] || \
116 $(STAGING_DIR_HOST)/bin/ucert -I -c $(BUILD_KEY).ucert -p $(BUILD_KEY).pub -s $(BUILD_KEY)
117
118 endef
119
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`
123
124 endef
125 endif
126
127 ifeq ($(CONFIG_NAND_SUPPORT),)
128 define Package/base-files/nand-support
129 rm -f $(1)/lib/upgrade/nand.sh
130 endef
131 endif
132
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)/; \
139 fi
140 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
141 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
142 fi
143 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
144 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
145 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
146 fi; \
147 )
148
149 $(VERSION_SED_SCRIPT) \
150 $(1)/etc/banner \
151 $(1)/etc/openwrt_version \
152 $(1)/usr/lib/os-release
153
154 $(VERSION_SED_SCRIPT) \
155 $(1)/etc/openwrt_release \
156 $(1)/etc/device_info \
157 $(1)/usr/lib/os-release
158
159 $(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \
160 $(1)/sbin/hotplug-call \
161 $(1)/etc/preinit \
162 $(1)/etc/profile
163
164 mkdir -p $(1)/CONTROL
165 mkdir -p $(1)/dev
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))
172 mkdir -p $(1)/mnt
173 mkdir -p $(1)/proc
174 mkdir -p $(1)/tmp
175 mkdir -p $(1)/usr/lib
176 $(if $(LIB_SUFFIX),-$(LN) lib $(1)/usr/lib$(LIB_SUFFIX))
177 mkdir -p $(1)/usr/bin
178 mkdir -p $(1)/sys
179 mkdir -p $(1)/www
180 mkdir -p $(1)/root
181 $(LN) /proc/mounts $(1)/etc/mtab
182 rm -f $(1)/var
183 $(LN) tmp $(1)/var
184 mkdir -p $(1)/etc
185 $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
186
187 chmod 0600 $(1)/etc/shadow
188 chmod 1777 $(1)/tmp
189
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; \
196 fi \
197 done
198
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)
202
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,)
209 endef
210
211 ifneq ($(DUMP),1)
212 -include $(PLATFORM_DIR)/base-files.mk
213 -include $(PLATFORM_SUBDIR)/base-files.mk
214 endif
215
216 $(eval $(call BuildPackage,base-files))