Makefile 6.6 KB

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