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