b58843163fd44638242d830764d2c849307c696f
[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:=191
16 PKG_FLAGS:=nonshared
17
18 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
19 PKG_BUILD_DEPENDS:=usign/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/base-files/conffiles
47 /etc/config/
48 /etc/config/network
49 /etc/config/system
50 /etc/crontabs/
51 /etc/dropbear/
52 /etc/group
53 /etc/hosts
54 /etc/inittab
55 /etc/iproute2/rt_protos
56 /etc/iproute2/rt_tables
57 /etc/passwd
58 /etc/profile
59 /etc/profile.d
60 /etc/protocols
61 /etc/rc.local
62 /etc/services
63 /etc/shadow
64 /etc/shells
65 /etc/sysctl.conf
66 /etc/sysupgrade.conf
67 $(call $(TARGET)/conffiles)
68 endef
69
70 define Package/base-files/description
71 This package contains a base filesystem and system scripts for OpenWrt.
72 endef
73
74 define ImageConfigOptions
75 mkdir -p $(1)/lib/preinit
76 echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
77 echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
78 echo 'pi_init_path="$(TARGET_INIT_PATH)"' >>$(1)/lib/preinit/00_preinit.conf
79 echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
80 echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
81 echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
82 echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
83 echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib/preinit/00_preinit.conf
84 echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf
85 echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf
86 echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
87 echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
88 echo 'pi_preinit_no_failsafe="$(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE)"' >>$(1)/lib/preinit/00_preinit.conf
89 endef
90
91 define Build/Prepare
92 mkdir -p $(PKG_BUILD_DIR)
93 endef
94
95 define Build/Compile/Default
96
97 endef
98 Build/Compile = $(Build/Compile/Default)
99
100 ifdef CONFIG_SIGNED_PACKAGES
101 define Build/Configure
102 [ -s $(BUILD_KEY) -a -s $(BUILD_KEY).pub ] || \
103 $(STAGING_DIR_HOST)/bin/usign -G -s $(BUILD_KEY) -p $(BUILD_KEY).pub -c "Local build key"
104
105 endef
106
107 define Package/base-files/install-key
108 mkdir -p $(1)/etc/opkg/keys
109 $(CP) $(BUILD_KEY).pub $(1)/etc/opkg/keys/`$(STAGING_DIR_HOST)/bin/usign -F -p $(BUILD_KEY).pub`
110
111 endef
112 endif
113
114 ifeq ($(CONFIG_NAND_SUPPORT),)
115 define Package/base-files/nand-support
116 rm -f $(1)/lib/upgrade/nand.sh
117 endef
118 endif
119
120 define Package/base-files/install
121 $(CP) ./files/* $(1)/
122 $(Package/base-files/install-key)
123 $(Package/base-files/nand-support)
124 if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
125 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
126 fi
127 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
128 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
129 fi
130 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
131 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
132 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
133 fi; \
134 )
135
136 $(VERSION_SED_SCRIPT) \
137 $(1)/etc/banner \
138 $(1)/etc/openwrt_version \
139 $(1)/usr/lib/os-release
140
141 $(VERSION_SED_SCRIPT) \
142 $(1)/etc/openwrt_release \
143 $(1)/etc/device_info \
144 $(1)/usr/lib/os-release
145
146 $(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \
147 $(1)/sbin/hotplug-call \
148 $(1)/etc/preinit \
149 $(1)/etc/profile
150
151 mkdir -p $(1)/CONTROL
152 mkdir -p $(1)/dev
153 mkdir -p $(1)/etc/config
154 mkdir -p $(1)/etc/crontabs
155 mkdir -p $(1)/etc/rc.d
156 mkdir -p $(1)/overlay
157 mkdir -p $(1)/lib/firmware
158 $(if $(LIB_SUFFIX),-$(LN) lib $(1)/lib$(LIB_SUFFIX))
159 mkdir -p $(1)/mnt
160 mkdir -p $(1)/proc
161 mkdir -p $(1)/tmp
162 mkdir -p $(1)/usr/lib
163 $(if $(LIB_SUFFIX),-$(LN) lib $(1)/usr/lib$(LIB_SUFFIX))
164 mkdir -p $(1)/usr/bin
165 mkdir -p $(1)/sys
166 mkdir -p $(1)/www
167 mkdir -p $(1)/root
168 $(LN) /proc/mounts $(1)/etc/mtab
169 rm -f $(1)/var
170 $(LN) tmp $(1)/var
171 mkdir -p $(1)/etc
172 $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
173
174 chmod 0600 $(1)/etc/shadow
175 chmod 1777 $(1)/tmp
176
177 $(call ImageConfigOptions,$(1))
178 $(call Package/base-files/install-target,$(1))
179 for conffile in $(1)/etc/config/*; do \
180 if [ -f "$$$$conffile" ]; then \
181 grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
182 echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
183 fi \
184 done
185
186 $(if $(CONFIG_INCLUDE_CONFIG), \
187 echo -e "# Build configuration for board $(BOARD)/$(SUBTARGET)/$(PROFILE)\n" >$(1)/etc/build.config; \
188 cat $(BIN_DIR)/config.seed >>$(1)/etc/build.config)
189
190 $(if $(CONFIG_CLEAN_IPKG),, \
191 mkdir -p $(1)/etc/opkg; \
192 $(call FeedSourcesAppend,$(1)/etc/opkg/distfeeds.conf); \
193 $(VERSION_SED_SCRIPT) $(1)/etc/opkg/distfeeds.conf)
194 endef
195
196 ifneq ($(DUMP),1)
197 -include $(PLATFORM_DIR)/base-files.mk
198 -include $(PLATFORM_SUBDIR)/base-files.mk
199 endif
200
201 $(eval $(call BuildPackage,base-files))