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