diff --git a/Android.mk b/Android.mk index e91d11545d50fb6cb0b66ee41c6a418669785a84..ff3d20db1a3a860201e0e1c0e0d0d8205da13337 100644 --- a/Android.mk +++ b/Android.mk @@ -92,11 +92,15 @@ PLAT_PRIVATE_POLICY := $(LOCAL_PATH)/private PLAT_VENDOR_POLICY := $(LOCAL_PATH)/vendor REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask +# The current version of the platform sepolicy. +# TODO: This must be fetched from build system after b/36783775 +PLAT_PUBLIC_POLICY_CURRENT_VERSION := 100000.0 + # TODO: move to README when doing the README update and finalizing versioning. -# BOARD_SEPOLICY_VERS should contain the platform version identifier -# corresponding to the platform on which the non-platform policy is to be -# based. If unspecified, this will build against the current public platform -# policy in tree. +# BOARD_SEPOLICY_VERS must take the format "NN.m" and contain the sepolicy +# version identifier corresponding to the sepolicy on which the non-platform +# policy is to be based. If unspecified, this will build against the current +# public platform policy in tree # BOARD_SEPOLICY_VERS_DIR should contain the public platform policy which # is associated with the given BOARD_SEPOLICY_VERS. The policy therein will be # versioned according to the BOARD_SEPOLICY_VERS identifier and included as @@ -104,7 +108,8 @@ REQD_MASK_POLICY := $(LOCAL_PATH)/reqd_mask # platform policy does not break non-platform policy. ifndef BOARD_SEPOLICY_VERS $(warning BOARD_SEPOLICY_VERS not specified, assuming current platform version) -BOARD_SEPOLICY_VERS := current +# The default platform policy version. +BOARD_SEPOLICY_VERS := $(PLAT_PUBLIC_POLICY_CURRENT_VERSION) BOARD_SEPOLICY_VERS_DIR := $(PLAT_PUBLIC_POLICY) else ifndef BOARD_SEPOLICY_VERS_DIR @@ -319,13 +324,14 @@ include $(BUILD_SYSTEM)/base_rules.mk # auto-generate the mapping file for current platform policy, since it needs to # track platform policy development -current_mapping.cil := $(intermediates)/mapping/current.cil -$(current_mapping.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS) +current_mapping.cil := $(intermediates)/mapping/$(PLAT_PUBLIC_POLICY_CURRENT_VERSION).cil +$(current_mapping.cil) : PRIVATE_VERS := $(PLAT_PUBLIC_POLICY_CURRENT_VERSION) $(current_mapping.cil) : $(plat_pub_policy.cil) $(HOST_OUT_EXECUTABLES)/version_policy @mkdir -p $(dir $@) $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@ -ifeq ($(BOARD_SEPOLICY_VERS), current) + +ifeq ($(BOARD_SEPOLICY_VERS), $(PLAT_PUBLIC_POLICY_CURRENT_VERSION)) mapping_policy_nvr := $(current_mapping.cil) else mapping_policy_nvr := $(addsuffix /$(BOARD_SEPOLICY_VERS).cil, $(PLAT_PRIVATE_POLICY)/mapping) @@ -562,17 +568,17 @@ plat_policy.recovery.conf := # auto-generate the mapping file for current platform policy, since it needs to # track platform policy development -current_mapping.recovery.cil := $(intermediates)/mapping/current.recovery.cil -$(current_mapping.recovery.cil) : PRIVATE_VERS := $(BOARD_SEPOLICY_VERS) +current_mapping.recovery.cil := $(intermediates)/mapping/$(PLAT_PUBLIC_POLICY_CURRENT_VERSION).recovery.cil +$(current_mapping.recovery.cil) : PRIVATE_VERS := $(PLAT_PUBLIC_POLICY_CURRENT_VERSION) $(current_mapping.recovery.cil) : $(plat_pub_policy.recovery.cil) $(HOST_OUT_EXECUTABLES)/version_policy @mkdir -p $(dir $@) $(hide) $(HOST_OUT_EXECUTABLES)/version_policy -b $< -m -n $(PRIVATE_VERS) -o $@ -ifeq ($(BOARD_SEPOLICY_VERS), current) +ifeq ($(BOARD_SEPOLICY_VERS), $(PLAT_PUBLIC_POLICY_CURRENT_VERSION)) mapping_policy_nvr.recovery := $(current_mapping.recovery.cil) else mapping_policy_nvr.recovery := $(addsuffix /$(BOARD_SEPOLICY_VERS).recovery.cil, \ -$(PLAT_PRIVATE_POLICY)/mapping) + $(PLAT_PRIVATE_POLICY)/mapping) endif current_mapping.recovery.cil := diff --git a/tools/version_policy.c b/tools/version_policy.c index 74c9c73d6076c5f879f1353d4d27923b1415f903..24b2a3cc65e2b2a40309134f6adfc38de6716e1c 100644 --- a/tools/version_policy.c +++ b/tools/version_policy.c @@ -87,6 +87,7 @@ int main(int argc, char *argv[]) char *base = NULL; char *tgt_policy = NULL; char *num = NULL; + char *dot; char *output = NULL; struct cil_db *base_db = NULL; struct cil_db *out_db = NULL; @@ -138,6 +139,13 @@ int main(int argc, char *argv[]) usage(argv[0]); } + /* policy language doesn't like '.', so replace them with '_' in mapping version */ + dot = num; + while ((dot = strchr(dot, '.')) != NULL) { + *dot = '_'; + ++dot; + } + if (mapping && tgt_policy) { fprintf(stderr, "Please select only one mode between --mapping and --tgt_policy\n"); usage(argv[0]);