Makefile 5.55 KB
Newer Older
1
#
2
# Copyright (C) 2007-2014 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:=157
15

16
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
17
PKG_BUILD_DEPENDS:=opkg/host usign/host
Steven Barth's avatar
Steven Barth committed
18
PKG_LICENSE:=GPL-2.0
19

20
21
PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES

22
include $(INCLUDE_DIR)/package.mk
23

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

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

40
define Package/base-files/conffiles
41
42
/etc/config/network
/etc/config/system
Felix Fietkau's avatar
Felix Fietkau committed
43
44
45
46
/etc/hosts
/etc/inittab
/etc/group
/etc/passwd
47
/etc/shadow
Felix Fietkau's avatar
Felix Fietkau committed
48
/etc/profile
49
50
/etc/protocols
/etc/services
Felix Fietkau's avatar
Felix Fietkau committed
51
52
/etc/shells
/etc/sysctl.conf
53
/etc/rc.local
54
/etc/sysupgrade.conf
55
56
/etc/config/
/etc/dropbear/
57
/etc/crontabs/
Felix Fietkau's avatar
Felix Fietkau committed
58
59
60
$(call $(TARGET)/conffiles)
endef

61
define Package/base-files/description
62
63
 This package contains a base filesystem and system scripts for OpenWrt.
endef
64

65
ifneq ($(CONFIG_PREINITOPT),)
66
67
68
69
70
71
72
73
74
75
76
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
77
	echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.1.255")' >>$(1)/lib/preinit/00_preinit.conf
78
	echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
79
	echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
80
endef
81
endif
82

83
84
85
86
define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
endef

87
define Build/Compile/Default
88

89
endef
90
Build/Compile = $(Build/Compile/Default)
91

92
93
94
95
96
97
98
99
100
101
102
103
104
105
ifdef CONFIG_SIGNED_PACKAGES
  define Build/Configure
	[ -s $(BUILD_KEY) -a -s $(BUILD_KEY).pub ] || \
		$(STAGING_DIR_HOST)/bin/usign -G -s $(BUILD_KEY) -p $(BUILD_KEY).pub -c "Local build key"

  endef

  define Package/base-files/install-key
	mkdir -p $(1)/etc/opkg/keys
	$(CP) $(BUILD_KEY).pub $(1)/etc/opkg/keys/`$(STAGING_DIR_HOST)/bin/usign -F -p $(BUILD_KEY).pub`

  endef
endif

106
define Package/base-files/install
Felix Fietkau's avatar
Felix Fietkau committed
107
	$(CP) ./files/* $(1)/
108
	$(Package/base-files/install-key)
109
110
111
	if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
		$(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
	fi
112
113
	if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
		$(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
114
	fi
115
116
117
	if [ -d $(PLATFORM_DIR)/base-files-$(PROFILE)/. ]; then \
		$(CP) $(PLATFORM_DIR)/base-files-$(PROFILE)/* $(1)/; \
	fi
118
119
120
	if [ -d $(PLATFORM_DIR)/$(PROFILE)/base-files/. ]; then \
		$(CP) $(PLATFORM_DIR)/$(PROFILE)/base-files/* $(1)/; \
	fi
121
	$(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
122
123
		if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
			$(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
Felix Fietkau's avatar
Felix Fietkau committed
124
		fi; \
125
126
		if [ -d $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/. ]; then \
			$(CP) $(PLATFORM_SUBDIR)/base-files-$(PROFILE)/* $(1)/; \
127
128
129
		fi; \
		if [ -d $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/. ]; then \
			$(CP) $(PLATFORM_SUBDIR)/$(PROFILE)/base-files/* $(1)/; \
130
		fi \
131
	)
132

133
134
	$(VERSION_SED) \
		$(1)/etc/banner \
135
136
137
		$(1)/etc/openwrt_version

	$(VERSION_SED_SCRIPT) \
138
139
		$(1)/etc/openwrt_release \
		$(1)/etc/device_info
140

141
	mkdir -p $(1)/CONTROL
142
143
	mkdir -p $(1)/dev
	mkdir -p $(1)/etc/crontabs
144
	mkdir -p $(1)/etc/rc.d
145
	mkdir -p $(1)/overlay
Florian Fainelli's avatar
Florian Fainelli committed
146
	mkdir -p $(1)/lib/firmware
147
	$(if $(LIB_SUFFIX),-$(LN) lib $(1)/lib$(LIB_SUFFIX))
148
149
150
151
	mkdir -p $(1)/mnt
	mkdir -p $(1)/proc
	mkdir -p $(1)/tmp
	mkdir -p $(1)/usr/lib
152
	$(if $(LIB_SUFFIX),-$(LN) lib $(1)/usr/lib$(LIB_SUFFIX))
153
154
155
	mkdir -p $(1)/usr/bin
	mkdir -p $(1)/sys
	mkdir -p $(1)/www
156
	mkdir -p $(1)/root
157
	$(LN) /proc/mounts $(1)/etc/mtab
158
	rm -f $(1)/var
159
	$(LN) /tmp $(1)/var
160
	mkdir -p $(1)/etc
161
	$(LN) /tmp/resolv.conf /tmp/fstab /tmp/TZ $(1)/etc/
162
163
164
165

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

166
	$(call ImageConfigOptions,$(1))
167
168
169
	$(call Package/base-files/install-target,$(1))
	for conffile in $(1)/etc/config/*; do \
		if [ -f "$$$$conffile" ]; then \
170
			grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
171
172
173
				echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
		fi \
	done
174
175
endef

176
177
178
179
ifneq ($(DUMP),1)
  -include $(PLATFORM_DIR)/base-files.mk
endif

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