From e4665d7f85c7ee550f24d1799c09eb87a229b5c9 Mon Sep 17 00:00:00 2001 From: Alex Klyubin Date: Thu, 19 Jan 2017 19:58:34 -0800 Subject: [PATCH] Fix bugs in *_file_contexts targets This fixes the following issues introduced in commit d225b6979db89959c272b4351fb05363a7a18ea7: * plat_file_contexts was empty because the target was referencing system/sepolicy/private/file_contexts via a misspelled variable name. * plat_file_contexts wasn't marked as dirty and thus wasn't rebuilt when system/sepolicy/private/file_contexts changed. This is because the file_contexts dependency was referenced via a misspelled variable name. * plat_file_contexts wasn't sorted (as opposed to other similar targets, such as nonplat_file_contexts and file_contexts.bin). This may lead to unnecessary non-determinism. * nonplat_file_contexts wasn't marked dirty and thus wasn't rebuilt when device-specific file_contexts file(s) changed. This is because the file_contexts files were referenced via a misspelled variable name. Test: "make plat_file_contexts" produces a non-empty file containing mappings from system/sepolicy/private/file_contexts Test: "make plat_file_contexts" updates output when system/sepolicy/private/file_contexts changes Test: "make plat_file_contexts" produces output which is sorted accroding to rules in fc_sort Test: "make nonplat_file_contexts" updates output when device/lge/bullhead/sepolicy/file_contexts changes (tested on aosp_bullhead-eng) Bug: 31363362 Change-Id: I540555651103f02c96cf958bb93618f600e47a75 --- Android.mk | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Android.mk b/Android.mk index 269e66e7c..0061c7665 100644 --- a/Android.mk +++ b/Android.mk @@ -666,16 +666,21 @@ local_fc_files := $(PLAT_PRIVATE_POLICY)/file_contexts ifneq ($(filter address,$(SANITIZE_TARGET)),) local_fc_files += $(PLAT_PRIVATE_POLICY)/file_contexts_asan endif +local_fcfiles_with_nl := $(call add_nl, $(local_fc_files), $(built_nl)) -$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles) +$(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(local_fcfiles_with_nl) $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy) -$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(local_fcfiles) $(built_sepolicy) +$(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort +$(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \ +$(local_fcfiles_with_nl) $(built_sepolicy) @mkdir -p $(dir $@) - $(hide) m4 -s $(PRIVATE_FC_FILES) > $@ - $(hide) $< $(PRIVATE_SEPOLICY) $@ + $(hide) m4 -s $(PRIVATE_FC_FILES) > $@.tmp + $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp + $(hide) $(PRIVATE_FC_SORT) $@.tmp $@ built_plat_fc := $(LOCAL_BUILT_MODULE) local_fc_files := +local_fcfiles_with_nl := ################################## include $(CLEAR_VARS) @@ -694,7 +699,7 @@ $(LOCAL_BUILT_MODULE): PRIVATE_FC_FILES := $(nonplat_fcfiles_with_nl) $(LOCAL_BUILT_MODULE): PRIVATE_SEPOLICY := $(built_sepolicy) $(LOCAL_BUILT_MODULE): PRIVATE_FC_SORT := $(HOST_OUT_EXECUTABLES)/fc_sort $(LOCAL_BUILT_MODULE): $(HOST_OUT_EXECUTABLES)/checkfc $(HOST_OUT_EXECUTABLES)/fc_sort \ -$(device_fcfiles_with_nl) $(built_sepolicy) +$(nonplat_fcfiles_with_nl) $(built_sepolicy) @mkdir -p $(dir $@) $(hide) m4 -s $(PRIVATE_ADDITIONAL_M4DEFS) $(PRIVATE_FC_FILES) > $@.tmp $(hide) $< $(PRIVATE_SEPOLICY) $@.tmp