base-files: change network_find_wan() procedure to ignore default gateways in differe...
[15.05/openwrt.git] / package / base-files / Makefile
1 #
2 # Copyright (C) 2007-2013 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:=138
15
16 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
17 PKG_BUILD_DEPENDS:=opkg/host
18 PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
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
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/hosts
40 /etc/inittab
41 /etc/group
42 /etc/passwd
43 /etc/shadow
44 /etc/profile
45 /etc/shells
46 /etc/sysctl.conf
47 /etc/rc.local
48 /etc/sysupgrade.conf
49 /etc/config/
50 /etc/dropbear/
51 /etc/crontabs/
52 $(call $(TARGET)/conffiles)
53 endef
54
55 define Package/base-files/description
56  This package contains a base filesystem and system scripts for OpenWrt.
57 endef
58
59 define Package/base-files/config
60 config PROCD_INIT
61         bool "Use procd as the init process"
62         default n
63 endef
64
65 ifeq ($(CONFIG_PROCD_INIT),)
66 define InstallOldFiles
67         $(CP) ./files.old/* $(1)/
68 endef
69 endif
70
71 ifneq ($(CONFIG_PREINITOPT),)
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=$(if $(CONFIG_TARGET_INIT_PATH),$(CONFIG_TARGET_INIT_PATH),"/bin:/sbin:/usr/bin:/usr/sbin")' >>$(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 endef
87 endif
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 define Package/base-files/install
99         $(CP) ./files/* $(1)/
100         if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
101                 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
102         fi
103         $(call InstallOldFiles,$(1))
104         if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
105                 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
106         fi
107         if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
108                 $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
109         fi
110         if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
111                 $(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
112         fi
113         $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
114                 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
115                         $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
116                 fi; \
117                 if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
118                         $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
119                 fi; \
120                 if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
121                         $(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
122                 fi \
123         )
124
125         $(VERSION_SED) \
126                 $(1)/etc/banner \
127                 $(1)/etc/openwrt_version \
128                 $(1)/etc/openwrt_release
129
130         mkdir -p $(1)/CONTROL
131         mkdir -p $(1)/dev
132         mkdir -p $(1)/etc/crontabs
133         mkdir -p $(1)/etc/rc.d
134         mkdir -p $(1)/overlay
135         mkdir -p $(1)/lib/firmware
136         $(if $(LIB_SUFFIX),-ln -s lib $(1)/lib$(LIB_SUFFIX))
137         mkdir -p $(1)/mnt
138         mkdir -p $(1)/proc
139         mkdir -p $(1)/tmp
140         mkdir -p $(1)/usr/lib
141         $(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
142         mkdir -p $(1)/usr/bin
143         mkdir -p $(1)/sys
144         mkdir -p $(1)/www
145         mkdir -p $(1)/root
146         ln -sf /proc/mounts $(1)/etc/mtab
147         rm -f $(1)/var
148         ln -sf /tmp $(1)/var
149         mkdir -p $(1)/etc
150         ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
151
152         chmod 0600 $(1)/etc/shadow
153         chmod 1777 $(1)/tmp
154
155         $(call ImageConfigOptions,$(1))
156         $(call Package/base-files/install-target,$(1))
157         for conffile in $(1)/etc/config/*; do \
158                 if [ -f "$$$$conffile" ]; then \
159                         grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
160                                 echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
161                 fi \
162         done
163 endef
164
165 ifneq ($(DUMP),1)
166   -include $(PLATFORM_DIR)/base-files.mk
167 endif
168
169 $(eval $(call BuildPackage,base-files))