1
0

Makefile 6.3 KB

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