1include $(CLEAR_VARS)
2
3LOCAL_MODULE := plat_mac_permissions.xml
4LOCAL_MODULE_CLASS := ETC
5LOCAL_MODULE_TAGS := optional
6LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/selinux
7
8include $(BUILD_SYSTEM)/base_rules.mk
9
10all_plat_mac_perms_keys := $(call build_policy, keys.conf, $(PLAT_PRIVATE_POLICY) $(SYSTEM_EXT_PRIVATE_POLICY) $(PRODUCT_PRIVATE_POLICY))
11all_plat_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_PRIVATE_POLICY))
12
13# Build keys.conf
14plat_mac_perms_keys.tmp := $(intermediates)/plat_keys.tmp
15$(plat_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
16$(plat_mac_perms_keys.tmp): PRIVATE_KEYS := $(all_plat_mac_perms_keys)
17$(plat_mac_perms_keys.tmp): $(all_plat_mac_perms_keys) $(M4)
18	@mkdir -p $(dir $@)
19	$(hide) $(M4) --fatal-warnings -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_KEYS) > $@
20
21# Should be synced with keys.conf.
22all_plat_keys := platform media networkstack shared testkey
23all_plat_keys := $(all_plat_keys:%=$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))/%.x509.pem)
24
25$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_plat_mac_perms_files)
26$(LOCAL_BUILT_MODULE): $(plat_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
27$(all_plat_mac_perms_files) $(all_plat_keys)
28	@mkdir -p $(dir $@)
29	$(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
30		MAINLINE_SEPOLICY_DEV_CERTIFICATES="$(MAINLINE_SEPOLICY_DEV_CERTIFICATES)" \
31		$(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
32
33all_plat_keys :=
34all_plat_mac_perms_files :=
35all_plat_mac_perms_keys :=
36plat_mac_perms_keys.tmp :=
37
38##################################
39include $(CLEAR_VARS)
40
41LOCAL_MODULE := system_ext_mac_permissions.xml
42LOCAL_MODULE_CLASS := ETC
43LOCAL_MODULE_TAGS := optional
44LOCAL_MODULE_PATH := $(TARGET_OUT_SYSTEM_EXT)/etc/selinux
45
46include $(BUILD_SYSTEM)/base_rules.mk
47
48all_system_ext_mac_perms_keys := $(call build_policy, keys.conf, $(SYSTEM_EXT_PRIVATE_POLICY) $(REQD_MASK_POLICY))
49all_system_ext_mac_perms_files := $(call build_policy, mac_permissions.xml, $(SYSTEM_EXT_PRIVATE_POLICY) $(REQD_MASK_POLICY))
50
51# Build keys.conf
52system_ext_mac_perms_keys.tmp := $(intermediates)/system_ext_keys.tmp
53$(system_ext_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
54$(system_ext_mac_perms_keys.tmp): PRIVATE_KEYS := $(all_system_ext_mac_perms_keys)
55$(system_ext_mac_perms_keys.tmp): $(all_system_ext_mac_perms_keys) $(M4)
56	@mkdir -p $(dir $@)
57	$(hide) $(M4) --fatal-warnings -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_KEYS) > $@
58
59$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_system_ext_mac_perms_files)
60$(LOCAL_BUILT_MODULE): $(system_ext_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
61$(all_system_ext_mac_perms_files)
62	@mkdir -p $(dir $@)
63	$(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
64
65system_ext_mac_perms_keys.tmp :=
66all_system_ext_mac_perms_files :=
67all_system_ext_mac_perms_keys :=
68
69##################################
70include $(CLEAR_VARS)
71
72LOCAL_MODULE := product_mac_permissions.xml
73LOCAL_MODULE_CLASS := ETC
74LOCAL_MODULE_TAGS := optional
75LOCAL_MODULE_PATH := $(TARGET_OUT_PRODUCT)/etc/selinux
76
77include $(BUILD_SYSTEM)/base_rules.mk
78
79all_product_mac_perms_keys := $(call build_policy, keys.conf, $(PRODUCT_PRIVATE_POLICY) $(REQD_MASK_POLICY))
80all_product_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PRODUCT_PRIVATE_POLICY) $(REQD_MASK_POLICY))
81
82# Build keys.conf
83product_mac_perms_keys.tmp := $(intermediates)/product_keys.tmp
84$(product_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
85$(product_mac_perms_keys.tmp): PRIVATE_KEYS := $(all_product_mac_perms_keys)
86$(product_mac_perms_keys.tmp): $(all_product_mac_perms_keys) $(M4)
87	@mkdir -p $(dir $@)
88	$(hide) $(M4) --fatal-warnings -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_KEYS) > $@
89
90$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_product_mac_perms_files)
91$(LOCAL_BUILT_MODULE): $(product_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
92$(all_product_mac_perms_files)
93	@mkdir -p $(dir $@)
94	$(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
95
96product_mac_perms_keys.tmp :=
97all_product_mac_perms_files :=
98all_product_mac_perms_keys :=
99
100##################################
101include $(CLEAR_VARS)
102
103LOCAL_MODULE := vendor_mac_permissions.xml
104LOCAL_MODULE_CLASS := ETC
105LOCAL_MODULE_TAGS := optional
106LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/etc/selinux
107
108include $(BUILD_SYSTEM)/base_rules.mk
109
110all_vendor_mac_perms_keys := $(call build_policy, keys.conf, $(PLAT_VENDOR_POLICY) $(BOARD_VENDOR_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
111all_vendor_mac_perms_files := $(call build_policy, mac_permissions.xml, $(PLAT_VENDOR_POLICY) $(BOARD_VENDOR_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
112
113# Build keys.conf
114vendor_mac_perms_keys.tmp := $(intermediates)/vendor_keys.tmp
115$(vendor_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
116$(vendor_mac_perms_keys.tmp): PRIVATE_KEYS := $(all_vendor_mac_perms_keys)
117$(vendor_mac_perms_keys.tmp): $(all_vendor_mac_perms_keys) $(M4)
118	@mkdir -p $(dir $@)
119	$(hide) $(M4) --fatal-warnings -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_KEYS) > $@
120
121$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_vendor_mac_perms_files)
122$(LOCAL_BUILT_MODULE): $(vendor_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
123$(all_vendor_mac_perms_files)
124	@mkdir -p $(dir $@)
125	$(hide) DEFAULT_SYSTEM_DEV_CERTIFICATE="$(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))" \
126		$(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
127
128vendor_mac_perms_keys.tmp :=
129all_vendor_mac_perms_files :=
130all_vendor_mac_perms_keys :=
131
132##################################
133include $(CLEAR_VARS)
134
135LOCAL_MODULE := odm_mac_permissions.xml
136LOCAL_MODULE_CLASS := ETC
137LOCAL_MODULE_TAGS := optional
138LOCAL_MODULE_PATH := $(TARGET_OUT_ODM)/etc/selinux
139
140include $(BUILD_SYSTEM)/base_rules.mk
141
142all_odm_mac_perms_keys := $(call build_policy, keys.conf, $(BOARD_ODM_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
143all_odm_mac_perms_files := $(call build_policy, mac_permissions.xml, $(BOARD_ODM_SEPOLICY_DIRS) $(REQD_MASK_POLICY))
144
145# Build keys.conf
146odm_mac_perms_keys.tmp := $(intermediates)/odm_keys.tmp
147$(odm_mac_perms_keys.tmp): PRIVATE_ADDITIONAL_M4DEFS := $(LOCAL_ADDITIONAL_M4DEFS)
148$(odm_mac_perms_keys.tmp): PRIVATE_KEYS := $(all_odm_mac_perms_keys)
149$(odm_mac_perms_keys.tmp): $(all_odm_mac_perms_keys) $(M4)
150	@mkdir -p $(dir $@)
151	$(hide) $(M4) --fatal-warnings -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_KEYS) > $@
152
153$(LOCAL_BUILT_MODULE): PRIVATE_MAC_PERMS_FILES := $(all_odm_mac_perms_files)
154$(LOCAL_BUILT_MODULE): $(odm_mac_perms_keys.tmp) $(HOST_OUT_EXECUTABLES)/insertkeys.py \
155$(all_odm_mac_perms_files)
156	@mkdir -p $(dir $@)
157	$(hide) $(HOST_OUT_EXECUTABLES)/insertkeys.py -t $(TARGET_BUILD_VARIANT) -c $(TOP) $< -o $@ $(PRIVATE_MAC_PERMS_FILES)
158
159odm_mac_perms_keys.tmp :=
160all_odm_mac_perms_files :=
161