Makefile 5.5 KB

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