Makefile 5.6 KB

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