skeleton-init-common.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ################################################################################
  2. #
  3. # skeleton-init-common
  4. #
  5. ################################################################################
  6. # The skeleton can't depend on the toolchain, since all packages depends on the
  7. # skeleton and the toolchain is a target package, as is skeleton.
  8. # Hence, skeleton would depends on the toolchain and the toolchain would depend
  9. # on skeleton.
  10. SKELETON_INIT_COMMON_ADD_TOOLCHAIN_DEPENDENCY = NO
  11. SKELETON_INIT_COMMON_ADD_SKELETON_DEPENDENCY = NO
  12. # The skeleton also handles the merged /usr case in the sysroot
  13. SKELETON_INIT_COMMON_INSTALL_STAGING = YES
  14. SKELETON_INIT_COMMON_PATH = system/skeleton
  15. define SKELETON_INIT_COMMON_INSTALL_TARGET_CMDS
  16. $(call SYSTEM_RSYNC,$(SKELETON_INIT_COMMON_PATH),$(TARGET_DIR))
  17. $(call SYSTEM_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
  18. $(call SYSTEM_LIB_SYMLINK,$(TARGET_DIR))
  19. $(SED) 's,@PATH@,$(BR2_SYSTEM_DEFAULT_PATH),' $(TARGET_DIR)/etc/profile
  20. $(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
  21. $(TARGET_DIR_WARNING_FILE)
  22. endef
  23. # We don't care much about what goes in staging, as long as it is
  24. # correctly setup for merged/non-merged /usr. The simplest is to
  25. # fill it in with the content of the skeleton.
  26. define SKELETON_INIT_COMMON_INSTALL_STAGING_CMDS
  27. $(call SYSTEM_RSYNC,$(SKELETON_INIT_COMMON_PATH),$(STAGING_DIR))
  28. $(call SYSTEM_USR_SYMLINKS_OR_DIRS,$(STAGING_DIR))
  29. $(call SYSTEM_LIB_SYMLINK,$(STAGING_DIR))
  30. $(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
  31. endef
  32. SKELETON_INIT_COMMON_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
  33. SKELETON_INIT_COMMON_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
  34. SKELETON_INIT_COMMON_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
  35. SKELETON_INIT_COMMON_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
  36. SKELETON_INIT_COMMON_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
  37. ifneq ($(SKELETON_INIT_COMMON_HOSTNAME),)
  38. SKELETON_INIT_COMMON_HOSTS_LINE = $(SKELETON_INIT_COMMON_HOSTNAME)
  39. SKELETON_INIT_COMMON_SHORT_HOSTNAME = $(firstword $(subst ., ,$(SKELETON_INIT_COMMON_HOSTNAME)))
  40. ifneq ($(SKELETON_INIT_COMMON_HOSTNAME),$(SKELETON_INIT_COMMON_SHORT_HOSTNAME))
  41. SKELETON_INIT_COMMON_HOSTS_LINE += $(SKELETON_INIT_COMMON_SHORT_HOSTNAME)
  42. endif
  43. define SKELETON_INIT_COMMON_SET_HOSTNAME
  44. mkdir -p $(TARGET_DIR)/etc
  45. echo "$(SKELETON_INIT_COMMON_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
  46. $(SED) '$$a \127.0.1.1\t$(SKELETON_INIT_COMMON_HOSTS_LINE)' \
  47. -e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
  48. endef
  49. SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_HOSTNAME
  50. endif
  51. ifneq ($(SKELETON_INIT_COMMON_ISSUE),)
  52. define SKELETON_INIT_COMMON_SET_ISSUE
  53. mkdir -p $(TARGET_DIR)/etc
  54. echo "$(SKELETON_INIT_COMMON_ISSUE)" > $(TARGET_DIR)/etc/issue
  55. endef
  56. SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_ISSUE
  57. endif
  58. ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
  59. ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_INIT_COMMON_ROOT_PASSWD)),)
  60. SKELETON_INIT_COMMON_ROOT_PASSWORD = '$(SKELETON_INIT_COMMON_ROOT_PASSWD)'
  61. else ifneq ($(SKELETON_INIT_COMMON_ROOT_PASSWD),)
  62. # This variable will only be evaluated in the finalize stage, so we can
  63. # be sure that host-mkpasswd will have already been built by that time.
  64. SKELETON_INIT_COMMON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_INIT_COMMON_PASSWD_METHOD)" "$(SKELETON_INIT_COMMON_ROOT_PASSWD)"`"
  65. endif
  66. else # !BR2_TARGET_ENABLE_ROOT_LOGIN
  67. SKELETON_INIT_COMMON_ROOT_PASSWORD = "*"
  68. endif
  69. define SKELETON_INIT_COMMON_SET_ROOT_PASSWD
  70. $(SED) s,^root:[^:]*:,root:$(SKELETON_INIT_COMMON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
  71. endef
  72. SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_ROOT_PASSWD
  73. ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
  74. define SKELETON_INIT_COMMON_SET_BIN_SH
  75. rm -f $(TARGET_DIR)/bin/sh
  76. endef
  77. else
  78. # Add /bin/sh to /etc/shells otherwise some login tools like dropbear
  79. # can reject the user connection. See man shells.
  80. define SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS
  81. grep -qsE '^/bin/sh$$' $(TARGET_DIR)/etc/shells \
  82. || echo "/bin/sh" >> $(TARGET_DIR)/etc/shells
  83. endef
  84. SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_ADD_SH_TO_SHELLS
  85. ifneq ($(SKELETON_INIT_COMMON_BIN_SH),)
  86. define SKELETON_INIT_COMMON_SET_BIN_SH
  87. ln -sf $(SKELETON_INIT_COMMON_BIN_SH) $(TARGET_DIR)/bin/sh
  88. $(SED) '/^root:/s,[^/]*$$,$(SKELETON_INIT_COMMON_BIN_SH),' \
  89. $(TARGET_DIR)/etc/passwd
  90. endef
  91. endif
  92. endif
  93. SKELETON_INIT_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_INIT_COMMON_SET_BIN_SH
  94. $(eval $(generic-package))