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