2 # Copyright (C) 2007-2013 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11 include $(INCLUDE_DIR)/version.mk
16 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
17 PKG_BUILD_DEPENDS:=opkg/host
18 PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
20 include $(INCLUDE_DIR)/package.mk
24 ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
25 TARGET:=$(TARGET)-$(PROFILE)
29 define Package/base-files
32 DEPENDS:=+netifd +libc +procd
33 TITLE:=Base filesystem for OpenWrt
34 URL:=http://openwrt.org/
35 VERSION:=$(PKG_RELEASE)-$(REVISION)
38 define Package/base-files/conffiles
52 $(call $(TARGET)/conffiles)
55 define Package/base-files/description
56 This package contains a base filesystem and system scripts for OpenWrt.
59 define Package/base-files/config
61 bool "Use procd as the init process"
65 ifeq ($(CONFIG_PROCD_INIT),)
66 define InstallOldFiles
67 $(CP) ./files.old/* $(1)/
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
90 mkdir -p $(PKG_BUILD_DIR)
93 define Build/Compile/Default
96 Build/Compile = $(Build/Compile/Default)
98 define Package/base-files/install
100 if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
101 $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
103 $(call InstallOldFiles,$(1))
104 if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
105 $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
107 if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
108 $(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
110 if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
111 $(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
113 $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
114 if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
115 $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
117 if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
118 $(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
120 if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
121 $(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
127 $(1)/etc/openwrt_version \
128 $(1)/etc/openwrt_release
130 mkdir -p $(1)/CONTROL
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))
140 mkdir -p $(1)/usr/lib
141 $(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
142 mkdir -p $(1)/usr/bin
146 ln -sf /proc/mounts $(1)/etc/mtab
150 ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
152 chmod 0600 $(1)/etc/shadow
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; \
166 -include $(PLATFORM_DIR)/base-files.mk
169 $(eval $(call BuildPackage,base-files))