Makefile 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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:=171
  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 Lede
  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. $(call $(TARGET)/conffiles)
  53. endef
  54. define Package/base-files/description
  55. This package contains a base filesystem and system scripts for OpenWrt.
  56. endef
  57. define ImageConfigOptions
  58. mkdir -p $(1)/lib/preinit
  59. echo 'pi_suppress_stderr="$(CONFIG_TARGET_PREINIT_SUPPRESS_STDERR)"' >$(1)/lib/preinit/00_preinit.conf
  60. echo 'fs_failsafe_wait_timeout=$(if $(CONFIG_TARGET_PREINIT_TIMEOUT),$(CONFIG_TARGET_PREINIT_TIMEOUT),2)' >>$(1)/lib/preinit/00_preinit.conf
  61. echo 'pi_init_path="$(TARGET_INIT_PATH)"' >>$(1)/lib/preinit/00_preinit.conf
  62. echo 'pi_init_env=$(if $(CONFIG_TARGET_INIT_ENV),$(CONFIG_TARGET_INIT_ENV),"")' >>$(1)/lib/preinit/00_preinit.conf
  63. echo 'pi_init_cmd=$(if $(CONFIG_TARGET_INIT_CMD),$(CONFIG_TARGET_INIT_CMD),"/sbin/init")' >>$(1)/lib/preinit/00_preinit.conf
  64. echo 'pi_init_suppress_stderr="$(CONFIG_TARGET_INIT_SUPPRESS_STDERR)"' >>$(1)/lib/preinit/00_preinit.conf
  65. echo 'pi_ifname=$(if $(CONFIG_TARGET_PREINIT_IFNAME),$(CONFIG_TARGET_PREINIT_IFNAME),"")' >>$(1)/lib/preinit/00_preinit.conf
  66. echo 'pi_ip=$(if $(CONFIG_TARGET_PREINIT_IP),$(CONFIG_TARGET_PREINIT_IP),"192.168.10.1")' >>$(1)/lib/preinit/00_preinit.conf
  67. echo 'pi_netmask=$(if $(CONFIG_TARGET_PREINIT_NETMASK),$(CONFIG_TARGET_PREINIT_NETMASK),"255.255.255.0")' >>$(1)/lib/preinit/00_preinit.conf
  68. echo 'pi_broadcast=$(if $(CONFIG_TARGET_PREINIT_BROADCAST),$(CONFIG_TARGET_PREINIT_BROADCAST),"192.168.10.255")' >>$(1)/lib/preinit/00_preinit.conf
  69. echo 'pi_preinit_net_messages="$(CONFIG_TARGET_PREINIT_SHOW_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
  70. echo 'pi_preinit_no_failsafe_netmsg="$(CONFIG_TARGET_PREINIT_SUPPRESS_FAILSAFE_NETMSG)"' >>$(1)/lib/preinit/00_preinit.conf
  71. echo 'pi_preinit_no_failsafe="$(CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE)"' >>$(1)/lib/preinit/00_preinit.conf
  72. endef
  73. define Build/Prepare
  74. mkdir -p $(PKG_BUILD_DIR)
  75. endef
  76. define Build/Compile/Default
  77. endef
  78. Build/Compile = $(Build/Compile/Default)
  79. ifdef CONFIG_SIGNED_PACKAGES
  80. define Build/Configure
  81. [ -s $(BUILD_KEY) -a -s $(BUILD_KEY).pub ] || \
  82. $(STAGING_DIR_HOST)/bin/usign -G -s $(BUILD_KEY) -p $(BUILD_KEY).pub -c "Local build key"
  83. endef
  84. define Package/base-files/install-key
  85. mkdir -p $(1)/etc/opkg/keys
  86. $(CP) $(BUILD_KEY).pub $(1)/etc/opkg/keys/`$(STAGING_DIR_HOST)/bin/usign -F -p $(BUILD_KEY).pub`
  87. endef
  88. endif
  89. define Package/base-files/install
  90. $(CP) ./files/* $(1)/
  91. $(Package/base-files/install-key)
  92. if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
  93. $(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
  94. fi
  95. if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
  96. $(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
  97. fi
  98. $(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
  99. if [ -d $(PLATFORM_SUBDIR)/base-files/. ]; then \
  100. $(CP) $(PLATFORM_SUBDIR)/base-files/* $(1)/; \
  101. fi; \
  102. )
  103. $(VERSION_SED) \
  104. $(1)/etc/banner \
  105. $(1)/etc/openwrt_version \
  106. $(1)/usr/lib/os-release
  107. $(VERSION_SED_SCRIPT) \
  108. $(1)/etc/openwrt_release \
  109. $(1)/etc/device_info \
  110. $(1)/usr/lib/os-release
  111. $(SED) "s#%PATH%#$(TARGET_INIT_PATH)#g" \
  112. $(1)/sbin/hotplug-call \
  113. $(1)/etc/preinit \
  114. $(1)/etc/profile
  115. mkdir -p $(1)/CONTROL
  116. mkdir -p $(1)/dev
  117. mkdir -p $(1)/etc/crontabs
  118. mkdir -p $(1)/etc/rc.d
  119. mkdir -p $(1)/overlay
  120. mkdir -p $(1)/lib/firmware
  121. $(if $(LIB_SUFFIX),-$(LN) lib $(1)/lib$(LIB_SUFFIX))
  122. mkdir -p $(1)/mnt
  123. mkdir -p $(1)/proc
  124. mkdir -p $(1)/tmp
  125. mkdir -p $(1)/usr/lib
  126. $(if $(LIB_SUFFIX),-$(LN) lib $(1)/usr/lib$(LIB_SUFFIX))
  127. mkdir -p $(1)/usr/bin
  128. mkdir -p $(1)/sys
  129. mkdir -p $(1)/www
  130. mkdir -p $(1)/root
  131. $(LN) /proc/mounts $(1)/etc/mtab
  132. rm -f $(1)/var
  133. $(LN) /tmp $(1)/var
  134. mkdir -p $(1)/etc
  135. $(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
  136. chmod 0600 $(1)/etc/shadow
  137. chmod 1777 $(1)/tmp
  138. $(call ImageConfigOptions,$(1))
  139. $(call Package/base-files/install-target,$(1))
  140. for conffile in $(1)/etc/config/*; do \
  141. if [ -f "$$$$conffile" ]; then \
  142. grep "$$$${conffile##$(1)}" $(1)/CONTROL/conffiles || \
  143. echo "$$$${conffile##$(1)}" >> $(1)/CONTROL/conffiles; \
  144. fi \
  145. done
  146. endef
  147. ifneq ($(DUMP),1)
  148. -include $(PLATFORM_DIR)/base-files.mk
  149. -include $(PLATFORM_SUBDIR)/base-files.mk
  150. endif
  151. $(eval $(call BuildPackage,base-files))