1
0

Makefile 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. include $(INCLUDE_DIR)/feeds.mk
  12. PKG_NAME:=base-files
  13. PKG_RELEASE:=191
  14. PKG_FLAGS:=nonshared
  15. PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
  16. PKG_BUILD_DEPENDS:=usign/host
  17. PKG_LICENSE:=GPL-2.0
  18. # Extend depends from version.mk
  19. PKG_CONFIG_DEPENDS += \
  20. CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE \
  21. CONFIG_NAND_SUPPORT \
  22. CONFIG_CLEAN_IPKG \
  23. CONFIG_PER_FEED_REPO \
  24. CONFIG_PER_FEED_REPO_ADD_DISABLED \
  25. CONFIG_PER_FEED_REPO_ADD_COMMENTED \
  26. $(foreach feed,$(FEEDS_INSTALLED),CONFIG_FEED_$(feed))
  27. include $(INCLUDE_DIR)/package.mk
  28. ifneq ($(DUMP),1)
  29. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | mkhash md5)
  30. TARGET:=-$(BOARD)
  31. endif
  32. define Package/base-files
  33. SECTION:=base
  34. CATEGORY:=Base system
  35. DEPENDS:=+netifd +libc +procd +jsonfilter +SIGNED_PACKAGES:usign +SIGNED_PACKAGES:librecmc-keyring +NAND_SUPPORT:ubi-utils +fstools +fwtool
  36. TITLE:=Base filesystem for OpenWrt
  37. URL:=http://openwrt.org/
  38. VERSION:=$(PKG_RELEASE)-$(REVISION)
  39. endef
  40. define Package/base-files/conffiles
  41. /etc/config/
  42. /etc/config/network
  43. /etc/config/system
  44. /etc/crontabs/
  45. /etc/dropbear/
  46. /etc/group
  47. /etc/hosts
  48. /etc/inittab
  49. /etc/iproute2/rt_protos
  50. /etc/iproute2/rt_tables
  51. /etc/passwd
  52. /etc/profile
  53. /etc/profile.d
  54. /etc/protocols
  55. /etc/rc.local
  56. /etc/services
  57. /etc/shadow
  58. /etc/shells
  59. /etc/sysctl.conf
  60. /etc/sysupgrade.conf
  61. $(call $(TARGET)/conffiles)
  62. endef
  63. define Package/base-files/description
  64. This package contains a base filesystem and system scripts for OpenWrt.
  65. endef
  66. define ImageConfigOptions
  67. mkdir -p $(1)/lib/preinit
  68. echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
  69. echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
  70. echo 'pi_init_path="$(TARGET_INIT_PATH)"' >>$(1)/lib/preinit/00_preinit.conf
  71. echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
  72. echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
  73. echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
  74. echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
  75. echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.10.1")' >>$(1)/lib/preinit/00_preinit.conf
  76. 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.10.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. echo 'pi_preinit_no_failsafe="$(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE)"' >>$(1)/lib/preinit/00_preinit.conf
  81. endef
  82. define Build/Prepare
  83. mkdir -p $(PKG_BUILD_DIR)
  84. endef
  85. define Build/Compile/Default
  86. endef
  87. Build/Compile = $(Build/Compile/Default)
  88. ifdef CONFIG_SIGNED_PACKAGES
  89. define Build/Configure
  90. [ -s $(BUILD_KEY) -a -s $(BUILD_KEY).pub ] || \
  91. $(STAGING_DIR_HOST)/bin/usign -G -s $(BUILD_KEY) -p $(BUILD_KEY).pub -c "Local build key"
  92. endef
  93. define Package/base-files/install-key
  94. mkdir -p $(1)/etc/opkg/keys
  95. $(CP) $(BUILD_KEY).pub $(1)/etc/opkg/keys/`$(STAGING_DIR_HOST)/bin/usign -F -p $(BUILD_KEY).pub`
  96. endef
  97. endif
  98. ifeq ($(CONFIG_NAND_SUPPORT),)
  99. define Package/base-files/nand-support
  100. rm -f $(1)/lib/upgrade/nand.sh
  101. endef
  102. endif
  103. define Package/base-files/install
  104. $(CP) ./files/* $(1)/
  105. $(Package/base-files/install-key)
  106. $(Package/base-files/nand-support)
  107. if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
  108. $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
  109. fi
  110. if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
  111. $(CP) $(PLATFORM_DIR)/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. )
  118. $(VERSION_SED_SCRIPT) \
  119. $(1)/etc/banner \
  120. $(1)/etc/openwrt_version \
  121. $(1)/usr/lib/os-release
  122. $(VERSION_SED_SCRIPT) \
  123. $(1)/etc/openwrt_release \
  124. $(1)/etc/device_info \
  125. $(1)/usr/lib/os-release
  126. $(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \
  127. $(1)/sbin/hotplug-call \
  128. $(1)/etc/preinit \
  129. $(1)/etc/profile
  130. mkdir -p $(1)/CONTROL
  131. mkdir -p $(1)/dev
  132. mkdir -p $(1)/etc/config
  133. mkdir -p $(1)/etc/crontabs
  134. mkdir -p $(1)/etc/rc.d
  135. mkdir -p $(1)/overlay
  136. mkdir -p $(1)/lib/firmware
  137. $(if $(LIB_SUFFIX),-$(LN) lib $(1)/lib$(LIB_SUFFIX))
  138. mkdir -p $(1)/mnt
  139. mkdir -p $(1)/proc
  140. mkdir -p $(1)/tmp
  141. mkdir -p $(1)/usr/lib
  142. $(if $(LIB_SUFFIX),-$(LN) lib $(1)/usr/lib$(LIB_SUFFIX))
  143. mkdir -p $(1)/usr/bin
  144. mkdir -p $(1)/sys
  145. mkdir -p $(1)/www
  146. mkdir -p $(1)/root
  147. $(LN) /proc/mounts $(1)/etc/mtab
  148. rm -f $(1)/var
  149. $(LN) tmp $(1)/var
  150. mkdir -p $(1)/etc
  151. $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
  152. chmod 0600 $(1)/etc/shadow
  153. chmod 1777 $(1)/tmp
  154. $(call ImageConfigOptions,$(1))
  155. $(call Package/base-files/install-target,$(1))
  156. for conffile in $(1)/etc/config/*; do \
  157. if [ -f "$$$$conffile" ]; then \
  158. grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
  159. echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
  160. fi \
  161. done
  162. $(if $(CONFIG_INCLUDE_CONFIG), \
  163. echo -e "# Build configuration for board $(BOARD)/$(SUBTARGET)/$(PROFILE)\n" >$(1)/etc/build.config; \
  164. cat $(BIN_DIR)/config.seed >>$(1)/etc/build.config)
  165. $(if $(CONFIG_CLEAN_IPKG),, \
  166. mkdir -p $(1)/etc/opkg; \
  167. $(call FeedSourcesAppend,$(1)/etc/opkg/distfeeds.conf); \
  168. $(VERSION_SED_SCRIPT) $(1)/etc/opkg/distfeeds.conf)
  169. endef
  170. ifneq ($(DUMP),1)
  171. -include $(PLATFORM_DIR)/base-files.mk
  172. -include $(PLATFORM_SUBDIR)/base-files.mk
  173. endif
  174. $(eval $(call BuildPackage,base-files))