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