Makefile 5.9 KB

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