Rewrite how to generate apexkeys.txt
Instead of listing all apexes in the source tree, now each apex emits
its own fragment for apexkeys.txt, which is pointed by
LOCAL_APEX_KEYS_FILE. Makefile collects apexkeys.txt from installed apex
files. This is to avoid listing unrelated apexes (not installed,
testdata, unexported namespaces, etc.)
Bug: 304914238
Test: m apexkeys.txt
Test: m blueprint-tests
Change-Id: I6b5601609d16452a0717f09ecaa703ee09693094
diff --git a/core/Makefile b/core/Makefile
index d371fb8..5433ee9 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -793,9 +793,25 @@
.PHONY: apkcerts-list
apkcerts-list: $(APKCERTS_FILE)
+intermediates := $(call intermediates-dir-for,PACKAGING,apexkeys)
+APEX_KEYS_FILE := $(intermediates)/apexkeys.txt
+
+all_apex_keys_files := $(sort $(foreach m,$(call product-installed-modules,$(INTERNAL_PRODUCT)),$(ALL_MODULES.$(m).APEX_KEYS_FILE)))
+$(APEX_KEYS_FILE): $(all_apex_keys_files)
+ @mkdir -p $(dir $@)
+ @rm -f $@
+ $(hide) touch $@
+ $(hide) $(foreach file,$^,cat $(file) >> $@ $(newline))
+all_apex_keys_files :=
+
+$(call declare-0p-target,$(APEX_KEYS_FILE))
+
+.PHONY: apexkeys.txt
+apexkeys.txt: $(APEX_KEYS_FILE)
+
ifneq (,$(TARGET_BUILD_APPS))
$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
- $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
+ $(call dist-for-goals, apps_only, $(APEX_KEYS_FILE):apexkeys.txt)
endif
@@ -6336,7 +6352,7 @@
$(INSTALLED_MISC_INFO_TARGET) \
$(INSTALLED_FASTBOOT_INFO_TARGET) \
$(APKCERTS_FILE) \
- $(SOONG_APEX_KEYS_FILE) \
+ $(APEX_KEYS_FILE) \
$(SOONG_ZIP) \
$(HOST_OUT_EXECUTABLES)/fs_config \
$(HOST_OUT_EXECUTABLES)/map_file_generator \
@@ -6547,7 +6563,7 @@
@# build them.
$(hide) mkdir -p $(zip_root)/META
$(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
- $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
+ $(hide) cp $(APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
ifneq ($(tool_extension),)
$(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
endif
@@ -6810,7 +6826,7 @@
$(INSTALLED_MISC_INFO_TARGET) \
$(INSTALLED_FASTBOOT_INFO_TARGET) \
$(APKCERTS_FILE) \
- $(SOONG_APEX_KEYS_FILE) \
+ $(APEX_KEYS_FILE) \
$(HOST_OUT_EXECUTABLES)/fs_config \
$(HOST_OUT_EXECUTABLES)/map_file_generator \
$(ADD_IMG_TO_TARGET_FILES) \