file_contexts.mk 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. include $(CLEAR_VARS)
  2. LOCAL_MODULE := plat_file_contexts
  3. LOCAL_MODULE_CLASS := ETC
  4. LOCAL_MODULE_TAGS := optional
  5. LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
  6. include $(BUILD_SYSTEM)/base_rules.mk
  7. local_fc_files := $(call build_policy, file_contexts, $(PLAT_PRIVATE_POLICY))
  8. ifneq ($(filter address,$(SANITIZE_TARGET)),)
  9. local_fc_files += $(wildcard $(addsuffix /file_contexts_asan, $(PLAT_PRIVATE_POLICY)))
  10. endif
  11. ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
  12. local_fc_files += $(wildcard $(addsuffix /file_contexts_overlayfs, $(PLAT_PRIVATE_POLICY)))
  13. endif
  14. ifeq ($(TARGET_FLATTEN_APEX),true)
  15. apex_fc_files := $(wildcard $(LOCAL_PATH)/apex/*-file_contexts)
  16. $(foreach _input,$(apex_fc_files),\
  17. $(eval _output := $(intermediates)/$(notdir $(_input))-flattened)\
  18. $(eval _apex_name := $(patsubst %-file_contexts,%,$(notdir $(_input))))\
  19. $(eval $(call build_flattened_apex_file_contexts,$(_input),$(_apex_name),$(_output),local_fc_files))\
  20. )
  21. endif
  22. local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl))
  23. $(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl)
  24. $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
  25. $(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
  26. $(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
  27. $(local_fcfiles_with_nl) $(built_sepolicy)
  28. @mkdir -p $(dir $@)
  29. $(hide) m4 --fatal-warnings -s $(PRIVATE_FC_FILES) > [email protected]
  30. $(hide) $< $(PRIVATE_SEPOLICY) [email protected]
  31. $(hide) $(PRIVATE_FC_SORT) [email protected] $@
  32. built_plat_fc := $(LOCAL_BUILT_MODULE)
  33. local_fc_files :=
  34. local_fcfiles_with_nl :=
  35. ##################################
  36. include $(CLEAR_VARS)
  37. LOCAL_MODULE := product_file_contexts
  38. LOCAL_MODULE_CLASS := ETC
  39. LOCAL_MODULE_TAGS := optional
  40. LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT)/etc/selinux
  41. include $(BUILD_SYSTEM)/base_rules.mk
  42. product_fc_files := $(call build_policy, file_contexts, $(PRODUCT_PRIVATE_POLICY))
  43. product_fcfiles_with_nl := $(call add_nl, $(product_fc_files), $(built_nl))
  44. $(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(product_fcfiles_with_nl)
  45. $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
  46. $(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
  47. $(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
  48. $(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
  49. $(product_fcfiles_with_nl) $(built_sepolicy)
  50. @mkdir -p $(dir $@)
  51. $(hide) m4 --fatal-warnings -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > [email protected]
  52. $(hide) $< $(PRIVATE_SEPOLICY) [email protected]
  53. $(hide) $(PRIVATE_FC_SORT) [email protected] $@
  54. built_product_fc := $(LOCAL_BUILT_MODULE)
  55. product_fc_files :=
  56. product_fcfiles_with_nl :=
  57. ##################################
  58. include $(CLEAR_VARS)
  59. LOCAL_MODULE := vendor_file_contexts
  60. LOCAL_MODULE_CLASS := ETC
  61. LOCAL_MODULE_TAGS := optional
  62. LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
  63. include $(BUILD_SYSTEM)/base_rules.mk
  64. vendor_fc_files := $(call build_vendor_policy, file_contexts)
  65. vendor_fcfiles_with_nl := $(call add_nl, $(vendor_fc_files), $(built_nl))
  66. $(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(vendor_fcfiles_with_nl)
  67. $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
  68. $(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
  69. $(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
  70. $(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
  71. $(vendor_fcfiles_with_nl) $(built_sepolicy)
  72. @mkdir -p $(dir $@)
  73. $(hide) m4 --fatal-warnings -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > [email protected]
  74. $(hide) $< $(PRIVATE_SEPOLICY) [email protected]
  75. $(hide) $(PRIVATE_FC_SORT) [email protected] $@
  76. built_vendor_fc := $(LOCAL_BUILT_MODULE)
  77. vendor_fc_files :=
  78. vendor_fcfiles_with_nl :=
  79. ##################################
  80. include $(CLEAR_VARS)
  81. LOCAL_MODULE := odm_file_contexts
  82. LOCAL_MODULE_CLASS := ETC
  83. LOCAL_MODULE_TAGS := optional
  84. LOCAL_MODULE_PATH := $(TARGET_OUT_ODM)/etc/selinux
  85. include $(BUILD_SYSTEM)/base_rules.mk
  86. odm_fc_files := $(call build_odm_policy, file_contexts)
  87. odm_fcfiles_with_nl := $(call add_nl, $(odm_fc_files), $(built_nl))
  88. $(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(odm_fcfiles_with_nl)
  89. $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy)
  90. $(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
  91. $(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort
  92. $(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \
  93. $(odm_fcfiles_with_nl) $(built_sepolicy)
  94. @mkdir -p $(dir $@)
  95. $(hide) m4 --fatal-warnings -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > [email protected]
  96. $(hide) $< $(PRIVATE_SEPOLICY) [email protected]
  97. $(hide) $(PRIVATE_FC_SORT) [email protected] $@
  98. built_odm_fc := $(LOCAL_BUILT_MODULE)
  99. odm_fc_files :=
  100. odm_fcfiles_with_nl :=
  101. ##################################
  102. include $(CLEAR_VARS)
  103. LOCAL_MODULE := plat_file_contexts.recovery
  104. LOCAL_MODULE_STEM := plat_file_contexts
  105. LOCAL_MODULE_CLASS := ETC
  106. LOCAL_MODULE_TAGS := optional
  107. LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
  108. include $(BUILD_SYSTEM)/base_rules.mk
  109. $(LOCAL_BUILT_MODULE): $(built_plat_fc)
  110. $(hide) cp -f $< $@
  111. ##################################
  112. include $(CLEAR_VARS)
  113. LOCAL_MODULE := product_file_contexts.recovery
  114. LOCAL_MODULE_STEM := product_file_contexts
  115. LOCAL_MODULE_CLASS := ETC
  116. LOCAL_MODULE_TAGS := optional
  117. LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
  118. include $(BUILD_SYSTEM)/base_rules.mk
  119. $(LOCAL_BUILT_MODULE): $(built_product_fc)
  120. $(hide) cp -f $< $@
  121. ##################################
  122. include $(CLEAR_VARS)
  123. LOCAL_MODULE := vendor_file_contexts.recovery
  124. LOCAL_MODULE_STEM := vendor_file_contexts
  125. LOCAL_MODULE_CLASS := ETC
  126. LOCAL_MODULE_TAGS := optional
  127. LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
  128. include $(BUILD_SYSTEM)/base_rules.mk
  129. $(LOCAL_BUILT_MODULE): $(built_vendor_fc)
  130. $(hide) cp -f $< $@
  131. ##################################
  132. include $(CLEAR_VARS)
  133. LOCAL_MODULE := odm_file_contexts.recovery
  134. LOCAL_MODULE_STEM := odm_file_contexts
  135. LOCAL_MODULE_CLASS := ETC
  136. LOCAL_MODULE_TAGS := optional
  137. LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)
  138. include $(BUILD_SYSTEM)/base_rules.mk
  139. $(LOCAL_BUILT_MODULE): $(built_odm_fc)
  140. $(hide) cp -f $< $@