Makefile 4.92 KB
Newer Older
1
#
2
# Copyright (C) 2007-2013 OpenWrt.org
3
# Copyright (C) 2010 Vertical Communications
Mike Baker's avatar
Mike Baker committed
4
5
6
7
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
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:=141
15

16
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
17
PKG_BUILD_DEPENDS:=opkg/host
18

19
include $(INCLUDE_DIR)/package.mk
20

21
ifneq ($(DUMP),1)
22
  TARGET:=-$(BOARD)
23
24
25
  ifneq ($(wildcard $(PLATFORM_DIR)/base-files-$(PROFILE) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)),)
    TARGET:=$(TARGET)-$(PROFILE)
  endif
26
27
endif

28
define Package/base-files
29
30
  SECTION:=base
  CATEGORY:=Base system
31
  DEPENDS:=+netifd +libc +procd
32
33
  TITLE:=Base filesystem for OpenWrt
  URL:=http://openwrt.org/
34
  VERSION:=$(PKG_RELEASE)-$(REVISION)
35
36
endef

37
define Package/base-files/conffiles
Felix Fietkau's avatar
Felix Fietkau committed
38
39
40
41
/etc/hosts
/etc/inittab
/etc/group
/etc/passwd
42
/etc/shadow
Felix Fietkau's avatar
Felix Fietkau committed
43
44
45
/etc/profile
/etc/shells
/etc/sysctl.conf
46
/etc/rc.local
47
/etc/sysupgrade.conf
48
49
/etc/config/
/etc/dropbear/
50
/etc/crontabs/
Felix Fietkau's avatar
Felix Fietkau committed
51
52
53
$(call $(TARGET)/conffiles)
endef

54
define Package/base-files/description
55
56
 This package contains a base filesystem and system scripts for OpenWrt.
endef
57

58
ifneq ($(CONFIG_PREINITOPT),)
59
60
61
62
63
64
65
66
67
68
69
define ImageConfigOptions
	mkdir -p $(1)/lib/preinit
	echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
	echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
	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
	echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
	echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
	echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
	echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
	echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.1.1")' >>$(1)/lib/preinit/00_preinit.conf
	echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf
70
	echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf
71
	echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
72
	echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
73
endef
74
endif
75

76
77
78
79
define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
endef

80
define Build/Compile/Default
81

82
endef
83
Build/Compile = $(Build/Compile/Default)
84

85
define Package/base-files/install
Felix Fietkau's avatar
Felix Fietkau committed
86
	$(CP) ./files/* $(1)/
87
88
89
	if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
		$(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
	fi
90
91
	if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
		$(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
92
	fi
93
94
95
	if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
		$(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
	fi
96
97
98
	if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
		$(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
	fi
99
	$(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
100
101
		if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
			$(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
Felix Fietkau's avatar
Felix Fietkau committed
102
		fi; \
103
104
		if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
			$(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
105
106
107
		fi; \
		if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
			$(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
108
		fi \
109
	)
110

111
112
113
114
115
	$(VERSION_SED) \
		$(1)/etc/banner \
		$(1)/etc/openwrt_version \
		$(1)/etc/openwrt_release

116
	mkdir -p $(1)/CONTROL
117
118
	mkdir -p $(1)/dev
	mkdir -p $(1)/etc/crontabs
119
	mkdir -p $(1)/etc/rc.d
120
	mkdir -p $(1)/overlay
Florian Fainelli's avatar
Florian Fainelli committed
121
	mkdir -p $(1)/lib/firmware
122
	$(if $(LIB_SUFFIX),-ln -s lib $(1)/lib$(LIB_SUFFIX))
123
124
125
126
	mkdir -p $(1)/mnt
	mkdir -p $(1)/proc
	mkdir -p $(1)/tmp
	mkdir -p $(1)/usr/lib
127
	$(if $(LIB_SUFFIX),-ln -s lib $(1)/usr/lib$(LIB_SUFFIX))
128
129
130
	mkdir -p $(1)/usr/bin
	mkdir -p $(1)/sys
	mkdir -p $(1)/www
131
	mkdir -p $(1)/root
132
133
134
135
	ln -sf /proc/mounts $(1)/etc/mtab
	rm -f $(1)/var
	ln -sf /tmp $(1)/var
	mkdir -p $(1)/etc
136
	ln -sf /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
137
138
139
140

	chmod 0600 $(1)/etc/shadow
	chmod 1777 $(1)/tmp

141
	$(call ImageConfigOptions,$(1))
142
143
144
	$(call Package/base-files/install-target,$(1))
	for conffile in $(1)/etc/config/*; do \
		if [ -f "$$$$conffile" ]; then \
145
			grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
146
147
148
				echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
		fi \
	done
149
150
endef

151
152
153
154
ifneq ($(DUMP),1)
  -include $(PLATFORM_DIR)/base-files.mk
endif

155
$(eval $(call BuildPackage,base-files))