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