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