1
0

Makefile 5.4 KB

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