diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-03-02 16:11:10 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-03-02 16:11:10 +0000 |
commit | 38fc61bf2bcae2215b77265ad5832cedba038843 (patch) | |
tree | 062f104d43d7346acea380aa4b8edc2acbb0b2bc | |
parent | f7dc62cc592b87c126ed2590d4d301f33ab936ea (diff) | |
parent | 0d361c76df4140f5f2426ba205aa2029cedb145c (diff) | |
download | build-platform-tools-34.0.1.tar.gz |
Merge "Snap for 9679998 from 04d5903f121d7f9ffdff76ee9c00c61684cdd413 to sdk-release" into sdk-releaseplatform-tools-34.0.1
51 files changed, 984 insertions, 421 deletions
@@ -5,5 +5,3 @@ include platform/build/soong:/OWNERS per-file envsetup.sh = joeo@google.com, jingwen@google.com, lberki@google.com per-file shell_utils.sh = joeo@google.com, jingwen@google.com, lberki@google.com -# Finalization scripts -per-file finalize* = smoreland@google.com, alexbuy@google.com diff --git a/core/Makefile b/core/Makefile index 0503c35d40..5f236771b7 100644 --- a/core/Makefile +++ b/core/Makefile @@ -181,6 +181,7 @@ endif ifeq ($(HOST_OS),linux) $(call dist-for-goals,sdk,$(API_FINGERPRINT)) +$(call dist-for-goals,droidcore,$(API_FINGERPRINT)) endif INSTALLED_RECOVERYIMAGE_TARGET := @@ -596,6 +597,19 @@ $(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\ $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(kmd))))) +ifeq ($(BOARD_SYSTEM_KERNEL_MODULES),) +ifneq ($(BOARD_SYSTEM_DLKM_SRC),) +ifneq ($(wildcard $(BOARD_SYSTEM_DLKM_SRC)/*),) + SYSTEM_KERNEL_MODULES := $(shell find $(BOARD_SYSTEM_DLKM_SRC) -type f) + SRC_SYSTEM_KERNEL_MODULES := $(SYSTEM_KERNEL_MODULES) + DST_SYSTEM_KERNEL_MODULES := $(patsubst $(BOARD_SYSTEM_DLKM_SRC)/%,:$(TARGET_OUT_SYSTEM_DLKM)/%,$(SRC_SYSTEM_KERNEL_MODULES)) + SYSTEM_KERNEL_MODULE_COPY_PAIRS := $(join $(SRC_SYSTEM_KERNEL_MODULES),$(DST_SYSTEM_KERNEL_MODULES)) + ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(SYSTEM_KERNEL_MODULE_COPY_PAIRS)) +endif +endif +endif + + # ----------------------------------------------------------------- # Cert-to-package mapping. Used by the post-build signing tools. # Use a macro to add newline to each echo command @@ -1275,7 +1289,7 @@ $(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $(AVBT $(AVBTOOL) add_hash_footer \ --image $@ \ $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \ - --partition_name boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \ + --partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \ $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS) $(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),) @@ -4709,7 +4723,7 @@ check_vintf_system_log := $(intermediates)/check_vintf_system.log check_vintf_all_deps += $(check_vintf_system_log) $(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps) @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 ) -$(call declare-0p-target,$(check_vintf_system_log)) +$(call declare-1p-target,$(check_vintf_system_log)) check_vintf_system_log := # -- Check framework manifest against frozen manifests for GSI targets. They need to be compatible. @@ -4721,7 +4735,7 @@ $(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps) @( $< --check --dirmap /system:$(TARGET_OUT) \ $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 ) -$(call declare-0p-target,$(vintffm_log)) +$(call declare-1p-target,$(vintffm_log)) endif # check_vintf_system_deps check_vintf_system_deps := @@ -4745,7 +4759,7 @@ $(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vend ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) --dirmap /apex:$(APEX_OUT) \ --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \ > $@ 2>&1 ) || ( cat $@ && exit 1 ); ) -$(call declare-0p-target,$(check_vintf_vendor_log)) +$(call declare-1p-target,$(check_vintf_vendor_log)) check_vintf_vendor_log := endif # check_vintf_vendor_deps check_vintf_vendor_deps := @@ -4767,8 +4781,8 @@ $(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE) $(BUILT_KERNEL_VERSION_FILE): echo $(BOARD_KERNEL_VERSION) > $@ -$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE)) -$(call declare-0p-target,$(BUILT_KERNEL_VERSION_FILE)) +$(call declare-license-metadata,$(BUILT_KERNEL_CONFIGS_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel) +$(call declare-license-metadata,$(BUILT_KERNEL_VERSION_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel) my_board_extracted_kernel := true endif # BOARD_KERNEL_VERSION @@ -4793,7 +4807,7 @@ $(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_T --output-configs $@ \ --output-release $(BUILT_KERNEL_VERSION_FILE) -$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE)) +$(call declare-license-metadata,$(BUILT_KERNEL_CONFIGS_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel) my_board_extracted_kernel := true endif # INSTALLED_KERNEL_TARGET @@ -4814,7 +4828,7 @@ $(BUILT_KERNEL_CONFIGS_FILE): \ --output-configs $@ \ --output-release $(BUILT_KERNEL_VERSION_FILE) -$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE)) +$(call declare-license-metadata,$(BUILT_KERNEL_CONFIGS_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel) my_board_extracted_kernel := true endif # INSTALLED_BOOTIMAGE_TARGET @@ -4906,7 +4920,7 @@ $(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_ --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \ >> $@ 2>&1 ) || (cat $@ && exit 1); )) -$(call declare-0p-target,$(check_vintf_compatible_log)) +$(call declare-1p-target,$(check_vintf_compatible_log)) check_vintf_compatible_log := check_vintf_compatible_args := @@ -4971,7 +4985,7 @@ $(check_all_partition_sizes_log): \ $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \ $@) -$(call declare-0p-target,$(check_all_partition_sizes_log)) +$(call declare-1p-target,$(check_all_partition_sizes_log)) .PHONY: check-all-partition-sizes check-all-partition-sizes: $(check_all_partition_sizes_log) @@ -5114,6 +5128,8 @@ INTERNAL_OTATOOLS_MODULES := \ verity_verifier \ zipalign \ zucchini \ + zip2zip \ + # Additional tools to unpack and repack the apex file. INTERNAL_OTATOOLS_MODULES += \ @@ -5130,7 +5146,7 @@ INTERNAL_OTATOOLS_MODULES += \ ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) INTERNAL_OTATOOLS_MODULES += \ - futility \ + futility-host \ vboot_signer endif @@ -6146,6 +6162,7 @@ endif ifdef BUILDING_INIT_BOOT_IMAGE $(hide) $(call package_files-copy-root, $(TARGET_RAMDISK_OUT),$(zip_root)/INIT_BOOT/RAMDISK) $(hide) $(call fs_config,$(zip_root)/INIT_BOOT/RAMDISK,) > $(zip_root)/META/init_boot_filesystem_config.txt + $(hide) cp $(RAMDISK_NODE_LIST) $(zip_root)/META/ramdisk_node_list ifdef BOARD_KERNEL_PAGESIZE $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/INIT_BOOT/pagesize endif # BOARD_KERNEL_PAGESIZE diff --git a/core/OWNERS b/core/OWNERS index 762d2a7ff9..eb1d5c3c46 100644 --- a/core/OWNERS +++ b/core/OWNERS @@ -1,6 +1,3 @@ -per-file *dex_preopt*.* = jiakaiz@google.com,ngeoffray@google.com,skvadrik@google.com -per-file art_*.* = jiakaiz@google.com,ngeoffray@google.com,skvadrik@google.com -per-file verify_uses_libraries.sh = ngeoffray@google.com,skvadrik@google.com # For global Proguard rules per-file proguard*.flags = jdduke@google.com diff --git a/core/base_rules.mk b/core/base_rules.mk index 18730aa0e3..ec5a21e917 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -716,6 +716,15 @@ endif ## Compatibility suite files. ########################################################### ifdef LOCAL_COMPATIBILITY_SUITE + +ifneq (,$(LOCAL_FULL_TEST_CONFIG)) + test_config := $(LOCAL_FULL_TEST_CONFIG) +else ifneq (,$(LOCAL_TEST_CONFIG)) + test_config := $(LOCAL_PATH)/$(LOCAL_TEST_CONFIG) +else + test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml) +endif + ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) # If we are building a native test or benchmark and its stem variants are not defined, @@ -762,13 +771,6 @@ $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ # Auto-generate build config. -ifneq (,$(LOCAL_FULL_TEST_CONFIG)) - test_config := $(LOCAL_FULL_TEST_CONFIG) -else ifneq (,$(LOCAL_TEST_CONFIG)) - test_config := $(LOCAL_PATH)/$(LOCAL_TEST_CONFIG) -else - test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml) -endif ifeq (,$(test_config)) ifneq (true,$(is_native)) is_instrumentation_test := true @@ -847,16 +849,6 @@ else endif endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files -# HACK: pretend a soong LOCAL_FULL_TEST_CONFIG is autogenerated by setting the flag in -# module-info.json -# TODO: (b/113029686) Add explicit flag from Soong to determine if a test was -# autogenerated. -ifneq (,$(filter $(SOONG_OUT_DIR)%,$(LOCAL_FULL_TEST_CONFIG))) - ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) - ALL_MODULES.$(my_register_name).auto_test_config := true - endif -endif - ifeq ($(use_testcase_folder),true) ifneq ($(my_test_data_file_pairs),) @@ -897,6 +889,17 @@ $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ $(eval my_compat_dist_test_data_$(suite) := )) endif # LOCAL_UNINSTALLABLE_MODULE + +# HACK: pretend a soong LOCAL_FULL_TEST_CONFIG is autogenerated by setting the flag in +# module-info.json +# TODO: (b/113029686) Add explicit flag from Soong to determine if a test was +# autogenerated. +ifneq (,$(filter $(SOONG_OUT_DIR)%,$(LOCAL_FULL_TEST_CONFIG))) + ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) + ALL_MODULES.$(my_register_name).auto_test_config := true + endif +endif + endif # LOCAL_COMPATIBILITY_SUITE my_supported_variant := diff --git a/core/clang/OWNERS b/core/clang/OWNERS deleted file mode 100644 index d41d3fcea2..0000000000 --- a/core/clang/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -chh@google.com -pirama@google.com -srhines@google.com -yikong@google.com diff --git a/core/clang/config.mk b/core/clang/config.mk index 28a75ecd07..d03c5417d2 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -2,7 +2,7 @@ LLVM_READOBJ := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-readobj -LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/clang/$(LLVM_RELEASE_VERSION)/lib/linux/ +LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib/clang/$(LLVM_RELEASE_VERSION)/lib/linux/ define convert-to-clang-flags $(strip $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(1))) diff --git a/core/os_licensing.mk b/core/os_licensing.mk index db7c422205..1e1b7df7a9 100644 --- a/core/os_licensing.mk +++ b/core/os_licensing.mk @@ -21,8 +21,8 @@ $(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz) $(copy-file-to-target) endif -$(call declare-0p-target,$(target_notice_file_xml_gz)) -$(call declare-0p-target,$(installed_notice_html_or_xml_gz)) +$(call declare-1p-target,$(target_notice_file_xml_gz)) +$(call declare-1p-target,$(installed_notice_html_or_xml_gz)) endif .PHONY: vendorlicense @@ -43,8 +43,8 @@ $(eval $(call xml-notice-rule,$(target_vendor_notice_file_xml_gz),"Vendor image" $(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz) $(copy-file-to-target) -$(call declare-0p-target,$(target_vendor_notice_file_xml_gz)) -$(call declare-0p-target,$(installed_vendor_notice_xml_gz)) +$(call declare-1p-target,$(target_vendor_notice_file_xml_gz)) +$(call declare-1p-target,$(installed_vendor_notice_xml_gz)) endif .PHONY: odmlicense @@ -62,8 +62,8 @@ $(eval $(call xml-notice-rule,$(target_odm_notice_file_xml_gz),"ODM filesystem i $(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz) $(copy-file-to-target) -$(call declare-0p-target,$(target_odm_notice_file_xml_gz)) -$(call declare-0p-target,$(installed_odm_notice_xml_gz)) +$(call declare-1p-target,$(target_odm_notice_file_xml_gz)) +$(call declare-1p-target,$(installed_odm_notice_xml_gz)) endif .PHONY: oemlicense @@ -84,8 +84,8 @@ $(eval $(call xml-notice-rule,$(target_product_notice_file_xml_gz),"Product imag $(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz) $(copy-file-to-target) -$(call declare-0p-target,$(target_product_notice_file_xml_gz)) -$(call declare-0p-target,$(installed_product_notice_xml_gz)) +$(call declare-1p-target,$(target_product_notice_file_xml_gz)) +$(call declare-1p-target,$(installed_product_notice_xml_gz)) endif .PHONY: systemextlicense @@ -103,8 +103,8 @@ $(eval $(call xml-notice-rule,$(target_system_ext_notice_file_xml_gz),"System_ex $(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz) $(copy-file-to-target) -$(call declare-0p-target,$(target_system_ext_notice_file_xml_gz)) -$(call declare-0p-target,$(installed_system_ext_notice_xml_gz)) +$(call declare-1p-target,$(target_system_ext_notice_file_xml_gz)) +$(call declare-1p-target,$(installed_system_ext_notice_xml_gz)) endif .PHONY: vendor_dlkmlicense @@ -122,8 +122,8 @@ $(eval $(call xml-notice-rule,$(target_vendor_dlkm_notice_file_xml_gz),"Vendor_d $(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz) $(copy-file-to-target) -$(call declare-0p-target,$(target_vendor_dlkm_notice_file_xml_gz)) -$(call declare-0p-target,$(installed_vendor_dlkm_notice_xml_gz)) +$(call declare-1p-target,$(target_vendor_dlkm_notice_file_xml_gz)) +$(call declare-1p-target,$(installed_vendor_dlkm_notice_xml_gz)) endif .PHONY: odm_dlkmlicense @@ -141,8 +141,8 @@ $(eval $(call xml-notice-rule,$(target_odm_dlkm_notice_file_xml_gz),"ODM_dlkm fi $(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz) $(copy-file-to-target) -$(call declare-0p-target,$(target_odm_dlkm_notice_file_xml_gz)) -$(call declare-0p-target,$(installed_odm_dlkm_notice_xml_gz)) +$(call declare-1p-target,$(target_odm_dlkm_notice_file_xml_gz)) +$(call declare-1p-target,$(installed_odm_dlkm_notice_xml_gz)) endif .PHONY: system_dlkmlicense @@ -160,8 +160,8 @@ $(eval $(call xml-notice-rule,$(target_system_dlkm_notice_file_xml_gz),"System_d $(installed_system_dlkm_notice_xml_gz): $(target_system_dlkm_notice_file_xml_gz) $(copy-file-to-target) -$(call declare-0p-target,$(target_system_dlkm_notice_file_xml_gz)) -$(call declare-0p-target,$(installed_sysetm_dlkm_notice_xml_gz)) +$(call declare-1p-target,$(target_system_dlkm_notice_file_xml_gz)) +$(call declare-1p-target,$(installed_sysetm_dlkm_notice_xml_gz)) endif endif # not TARGET_BUILD_APPS diff --git a/core/product_config.rbc b/core/product_config.rbc index da8209b0fc..97c1d00471 100644 --- a/core/product_config.rbc +++ b/core/product_config.rbc @@ -462,6 +462,9 @@ def _addsuffix(suffix, string_or_list): def __words(string_or_list): if type(string_or_list) == "list": + for x in string_or_list: + if type(x) != "string": + return string_or_list string_or_list = " ".join(string_or_list) return _mkstrip(string_or_list).split() diff --git a/core/sysprop.mk b/core/sysprop.mk index b7f0651e59..6e2caed318 100644 --- a/core/sysprop.mk +++ b/core/sysprop.mk @@ -141,7 +141,7 @@ endif fi;) $(hide) echo "# end of file" >> $$@ -$(call declare-0p-target,$(2)) +$(call declare-1p-target,$(2)) endef # ----------------------------------------------------------------- diff --git a/core/tasks/OWNERS b/core/tasks/OWNERS deleted file mode 100644 index 372ff8b7da..0000000000 --- a/core/tasks/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -per-file art-host-tests.mk = dshi@google.com,dsrbecky@google.com,jdesprez@google.com,rpl@google.com -per-file catbox.mk = smara@google.com,schinchalkar@google.com,kaneesh@google.com diff --git a/core/tasks/device-tests.mk b/core/tasks/device-tests.mk index 3196f52d8e..4167a7eb1a 100644 --- a/core/tasks/device-tests.mk +++ b/core/tasks/device-tests.mk @@ -39,7 +39,7 @@ $(device-tests-zip) : $(COMPATIBILITY.device-tests.FILES) $(my_host_shared_lib_f grep $(HOST_OUT_TESTCASES) $@-shared-libs.list > $@-host-shared-libs.list || true grep $(TARGET_OUT_TESTCASES) $@.list > $@-target.list || true grep -e .*\\.config$$ $@-target.list > $@-target-test-configs.list || true - $(hide) $(SOONG_ZIP) -d -o $@ -P host -C $(HOST_OUT) -l $@-host.list -P target -C $(PRODUCT_OUT) -l $@-target.list + $(hide) $(SOONG_ZIP) -d -o $@ -P host -C $(HOST_OUT) -l $@-host.list -P target -C $(PRODUCT_OUT) -l $@-target.list -sha256 $(hide) $(SOONG_ZIP) -d -o $(device-tests-configs-zip) \ -P host -C $(HOST_OUT) -l $@-host-test-configs.list \ -P target -C $(PRODUCT_OUT) -l $@-target-test-configs.list diff --git a/core/tasks/general-tests.mk b/core/tasks/general-tests.mk index 5726ee20b5..8dbc76f131 100644 --- a/core/tasks/general-tests.mk +++ b/core/tasks/general-tests.mk @@ -87,7 +87,8 @@ $(general_tests_zip) : $(COMPATIBILITY.general-tests.FILES) $(general_tests_tool $(SOONG_ZIP) -d -o $@ \ -P host -C $(PRIVATE_INTERMEDIATES_DIR) -D $(PRIVATE_INTERMEDIATES_DIR)/tools \ -P host -C $(HOST_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/host.list \ - -P target -C $(PRODUCT_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/target.list + -P target -C $(PRODUCT_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/target.list \ + -sha256 $(SOONG_ZIP) -d -o $(PRIVATE_general_tests_configs_zip) \ -P host -C $(HOST_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/host-test-configs.list \ -P target -C $(PRODUCT_OUT) -l $(PRIVATE_INTERMEDIATES_DIR)/target-test-configs.list diff --git a/core/tasks/host-unit-tests.mk b/core/tasks/host-unit-tests.mk index ed2f2a68c3..733a2e258c 100644 --- a/core/tasks/host-unit-tests.mk +++ b/core/tasks/host-unit-tests.mk @@ -41,7 +41,7 @@ $(host_unit_tests_zip) : $(COMPATIBILITY.host-unit-tests.FILES) $(my_host_shared grep $(TARGET_OUT_TESTCASES) $@.list > $@-target.list || true $(hide) $(SOONG_ZIP) -d -o $@ -P host -C $(HOST_OUT) -l $@-host.list \ -P target -C $(PRODUCT_OUT) -l $@-target.list \ - -P host/testcases -C $(HOST_OUT) -l $@-host-libs.list + -P host/testcases -C $(HOST_OUT) -l $@-host-libs.list -sha256 rm -f $@.list $@-host.list $@-target.list $@-host-libs.list host-unit-tests: $(host_unit_tests_zip) diff --git a/core/tasks/owners.mk b/core/tasks/owners.mk index 806b8ee758..29f3c449f6 100644 --- a/core/tasks/owners.mk +++ b/core/tasks/owners.mk @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# Create an artifact to include TEST_MAPPING files in source tree. +# Create an artifact to include OWNERS files in source tree. .PHONY: owners diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk index a5f162af63..94008909cc 100644 --- a/core/tasks/tools/compatibility.mk +++ b/core/tasks/tools/compatibility.mk @@ -51,7 +51,7 @@ $(test_suite_jdk): PRIVATE_JDK_DIR := $(test_suite_jdk_dir) $(test_suite_jdk): PRIVATE_SUBDIR := $(test_suite_subdir) $(test_suite_jdk): $(shell find $(test_suite_jdk_dir) -type f | sort) $(test_suite_jdk): $(SOONG_ZIP) - $(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR) + $(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR) -sha256 $(call declare-license-metadata,$(test_suite_jdk),SPDX-license-identifier-GPL-2.0-with-classpath-exception,permissive,\ $(test_suite_jdk_dir)/legal/java.base/LICENSE,JDK,prebuilts/jdk/$(notdir $(patsubst %/,%,$(dir $(test_suite_jdk_dir))))) @@ -123,7 +123,7 @@ $(compatibility_zip): $(compatibility_zip_deps) | $(ADB) $(ACP) cp $(PRIVATE_TOOLS) $(PRIVATE_OUT_DIR)/tools $(if $(PRIVATE_DYNAMIC_CONFIG),$(hide) cp $(PRIVATE_DYNAMIC_CONFIG) $(PRIVATE_OUT_DIR)/testcases/$(PRIVATE_SUITE_NAME).dynamic) find $(PRIVATE_RESOURCES) | sort >$@.list - $(SOONG_ZIP) -d -o $@.tmp -C $(dir $@) -l $@.list + $(SOONG_ZIP) -d -o $@.tmp -C $(dir $@) -l $@.list -sha256 $(MERGE_ZIPS) $@ $@.tmp $(PRIVATE_JDK) rm -f $@.tmp # Build a list of tests diff --git a/core/version_defaults.mk b/core/version_defaults.mk index e6a96ffdfa..a664b9deb1 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -103,7 +103,7 @@ ifndef PLATFORM_SECURITY_PATCH # It must be of the form "YYYY-MM-DD" on production devices. # It must match one of the Android Security Patch Level strings of the Public Security Bulletins. # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty. - PLATFORM_SECURITY_PATCH := 2023-01-05 + PLATFORM_SECURITY_PATCH := 2023-02-05 endif include $(BUILD_SYSTEM)/version_util.mk diff --git a/envsetup.sh b/envsetup.sh index 027262473e..905635c890 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -1210,7 +1210,7 @@ case `uname -s` in Darwin) function sgrep() { - find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|hpp|S|java|kt|xml|sh|mk|aidl|vts|proto)' \ + find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|hpp|S|java|kt|xml|sh|mk|aidl|vts|proto|rs|go)' \ -exec grep --color -n "$@" {} + } @@ -1218,7 +1218,7 @@ case `uname -s` in *) function sgrep() { - find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|hpp\|S\|java\|kt\|xml\|sh\|mk\|aidl\|vts\|proto\)' \ + find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|hpp\|S\|java\|kt\|xml\|sh\|mk\|aidl\|vts\|proto\|rs\|go\)' \ -exec grep --color -n "$@" {} + } ;; diff --git a/finalize-aidl-vndk-sdk-resources.sh b/finalize-aidl-vndk-sdk-resources.sh deleted file mode 100755 index f03fb435c9..0000000000 --- a/finalize-aidl-vndk-sdk-resources.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -set -ex - -function finalize_aidl_vndk_sdk_resources() { - local PLATFORM_CODENAME='UpsideDownCake' - local PLATFORM_CODENAME_JAVA='UPSIDE_DOWN_CAKE' - local PLATFORM_SDK_VERSION='34' - local PLATFORM_VERSION='14' - - local SDK_CODENAME="public static final int $PLATFORM_CODENAME_JAVA = CUR_DEVELOPMENT;" - local SDK_VERSION="public static final int $PLATFORM_CODENAME_JAVA = $PLATFORM_SDK_VERSION;" - - local top="$(dirname "$0")"/../.. - - # default target to modify tree and build SDK - local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - - # This script is WIP and only finalizes part of the Android branch for release. - # The full process can be found at (INTERNAL) go/android-sdk-finalization. - - # Update references in the codebase to new API version (TODO) - # ... - - # VNDK definitions for new SDK version - cp "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-current.txt" \ - "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-$PLATFORM_SDK_VERSION.txt" - - AIDL_TRANSITIVE_FREEZE=true $m aidl-freeze-api create_reference_dumps - - # Generate ABI dumps - ANDROID_BUILD_TOP="$top" \ - out/host/linux-x86/bin/create_reference_dumps \ - -p aosp_arm64 --build-variant user - - echo "NOTE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF (until 'DONE')" - # Update new versions of files. See update-vndk-list.sh (which requires envsetup.sh) - $m check-vndk-list || \ - { cp $top/out/soong/vndk/vndk.libraries.txt $top/build/make/target/product/gsi/current.txt; } - echo "DONE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF" - - # Finalize SDK - - # build/make - local version_defaults="$top/build/make/core/version_defaults.mk" - sed -i -e "s/PLATFORM_SDK_VERSION := .*/PLATFORM_SDK_VERSION := ${PLATFORM_SDK_VERSION}/g" $version_defaults - sed -i -e "s/PLATFORM_VERSION_LAST_STABLE := .*/PLATFORM_VERSION_LAST_STABLE := ${PLATFORM_VERSION}/g" $version_defaults - sed -i -e "s/sepolicy_major_vers := .*/sepolicy_major_vers := ${PLATFORM_SDK_VERSION}/g" "$top/build/make/core/config.mk" - cp "$top/build/make/target/product/gsi/current.txt" "$top/build/make/target/product/gsi/$PLATFORM_SDK_VERSION.txt" - - # build/soong - sed -i -e "/:.*$((${PLATFORM_SDK_VERSION}-1)),/a \\\t\t\t\"${PLATFORM_CODENAME}\": ${PLATFORM_SDK_VERSION}," "$top/build/soong/android/api_levels.go" - - # cts - echo ${PLATFORM_VERSION} > "$top/cts/tests/tests/os/assets/platform_releases.txt" - sed -i -e "s/EXPECTED_SDK = $((${PLATFORM_SDK_VERSION}-1))/EXPECTED_SDK = ${PLATFORM_SDK_VERSION}/g" "$top/cts/tests/tests/os/src/android/os/cts/BuildVersionTest.java" - - # libcore - sed -i "s%$SDK_CODENAME%$SDK_VERSION%g" "$top/libcore/dalvik/src/main/java/dalvik/annotation/compat/VersionCodes.java" - - # platform_testing - local version_codes="$top/platform_testing/libraries/compatibility-common-util/src/com/android/compatibility/common/util/VersionCodes.java" - sed -i -e "/=.*$((${PLATFORM_SDK_VERSION}-1));/a \\ ${SDK_VERSION}" $version_codes - - # Finalize resources - "$top/frameworks/base/tools/aapt2/tools/finalize_res.py" \ - "$top/frameworks/base/core/res/res/values/public-staging.xml" \ - "$top/frameworks/base/core/res/res/values/public-final.xml" - - # frameworks/base - sed -i "s%$SDK_CODENAME%$SDK_VERSION%g" "$top/frameworks/base/core/java/android/os/Build.java" - sed -i -e "/=.*$((${PLATFORM_SDK_VERSION}-1)),/a \\ SDK_${PLATFORM_CODENAME_JAVA} = ${PLATFORM_SDK_VERSION}," "$top/frameworks/base/tools/aapt/SdkConstants.h" - sed -i -e "/=.*$((${PLATFORM_SDK_VERSION}-1)),/a \\ SDK_${PLATFORM_CODENAME_JAVA} = ${PLATFORM_SDK_VERSION}," "$top/frameworks/base/tools/aapt2/SdkConstants.h" - - # Force update current.txt - $m clobber - $m update-api -} - -finalize_aidl_vndk_sdk_resources - diff --git a/finalize-locally-mainline-sdk.sh b/finalize-locally-mainline-sdk.sh deleted file mode 100755 index c72ef8c9e2..0000000000 --- a/finalize-locally-mainline-sdk.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -ex - -function finalize_locally_mainline_sdk() { - local MAINLINE_EXTENSION='6' - - local top="$(dirname "$0")"/../.. - - # Bump SDK extension version. - "$top/packages/modules/SdkExtensions/gen_sdk/bump_sdk.sh" ${MAINLINE_EXTENSION} - - local version_defaults="$top/build/make/core/version_defaults.mk" - sed -i -e "s/PLATFORM_SDK_EXTENSION_VERSION := .*/PLATFORM_SDK_EXTENSION_VERSION := ${MAINLINE_EXTENSION}/g" $version_defaults - - # Build modules SDKs. - TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true "$top/vendor/google/build/mainline_modules_sdks.sh" - - # Update prebuilts. - "$top/prebuilts/build-tools/path/linux-x86/python3" "$top/packages/modules/common/tools/finalize_sdk.py" -l -b 0 -f ${MAINLINE_EXTENSION} -r '' 0 -} - -finalize_locally_mainline_sdk - diff --git a/finalize-sdk-rel.sh b/finalize-sdk-rel.sh deleted file mode 100755 index b19e56acec..0000000000 --- a/finalize-sdk-rel.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -ex - -function finalize_sdk_rel() { - local DEV_SRC_DIR="$(dirname "$0")"/../.. - local BUILD_PREFIX='UP1A' - local PLATFORM_CODENAME='UpsideDownCake' - local PLATFORM_VERSION='14' - local PLATFORM_SDK_VERSION='34' - - # default target to modify tree and build SDK - local m="$DEV_SRC_DIR/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - - # adb keys - $m adb - LOGNAME=android-eng HOSTNAME=google.com "$DEV_SRC_DIR/out/host/linux-x86/bin/adb" keygen "$DEV_SRC_DIR/vendor/google/security/adb/${PLATFORM_VERSION}.adb_key" - - # build/make/core/version_defaults.mk - sed -i -e "s/PLATFORM_VERSION_CODENAME.${BUILD_PREFIX} := .*/PLATFORM_VERSION_CODENAME.${BUILD_PREFIX} := REL/g" "$DEV_SRC_DIR/build/make/core/version_defaults.mk" - - # cts - echo "$PLATFORM_VERSION" > "$DEV_SRC_DIR/cts/tests/tests/os/assets/platform_versions.txt" - git -C "$DEV_SRC_DIR/cts" mv hostsidetests/theme/assets/${PLATFORM_CODENAME} hostsidetests/theme/assets/${PLATFORM_SDK_VERSION} - - # system/sepolicy - mkdir -p "$DEV_SRC_DIR/system/sepolicy/prebuilts/api/${PLATFORM_SDK_VERSION}.0/" - cp -r "$DEV_SRC_DIR/system/sepolicy/public/" "$DEV_SRC_DIR/system/sepolicy/prebuilts/api/${PLATFORM_SDK_VERSION}.0/" - cp -r "$DEV_SRC_DIR/system/sepolicy/private/" "$DEV_SRC_DIR/system/sepolicy/prebuilts/api/${PLATFORM_SDK_VERSION}.0/" - - # prebuilts/abi-dumps/ndk - mv "$DEV_SRC_DIR/prebuilts/abi-dumps/ndk/current" "$DEV_SRC_DIR/prebuilts/abi-dumps/ndk/$PLATFORM_SDK_VERSION" - - # prebuilts/abi-dumps/vndk - mv "$DEV_SRC_DIR/prebuilts/abi-dumps/vndk/$PLATFORM_CODENAME" "$DEV_SRC_DIR/prebuilts/abi-dumps/vndk/$PLATFORM_SDK_VERSION" - - # prebuilts/abi-dumps/platform - mv "$DEV_SRC_DIR/prebuilts/abi-dumps/platform/current" "$DEV_SRC_DIR/prebuilts/abi-dumps/platform/$PLATFORM_SDK_VERSION" -} - -finalize_sdk_rel - diff --git a/finalize-step-1-for-build-target.sh b/finalize-step-1-for-build-target.sh deleted file mode 100755 index 8b35a1d2ad..0000000000 --- a/finalize-step-1-for-build-target.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# Continuous Integration script for *-finalization-1 branches. -# Reverts previous finalization script commits and runs local build. - -set -ex - -function finalize_step_1_main() { - local top="$(dirname "$0")"/../.. - local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - - # vndk etc finalization - source $top/build/make/finalize-aidl-vndk-sdk-resources.sh - - # build to confirm everything is OK - AIDL_FROZEN_REL=true $m -} - -finalize_step_1_main diff --git a/finalize-step-1.sh b/finalize-step-1.sh deleted file mode 100755 index 8871862876..0000000000 --- a/finalize-step-1.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# Automation for finalize_branch_for_release.sh. -# Sets up local environment, runs the finalization script and submits the results. -# WIP: -# - does not submit, only sends to gerrit. - -# set -ex - -function revert_to_unfinalized_state() { - repo forall -c '\ - git checkout . ; git revert --abort ; git clean -fdx ;\ - git checkout @ ; git branch fina-step1 -D ; git reset --hard; \ - repo start fina-step1 ; git checkout @ ; git b fina-step1 -D ;\ - baselineHash="$(git log --format=%H --no-merges --max-count=1 --grep ^FINALIZATION_STEP_1_BASELINE_COMMIT)" ;\ - if [[ $baselineHash ]]; then - previousHash="$(git log --format=%H --no-merges --max-count=100 --grep ^FINALIZATION_STEP_1_SCRIPT_COMMIT $baselineHash..HEAD | tr \n \040)" ;\ - else - previousHash="$(git log --format=%H --no-merges --max-count=100 --grep ^FINALIZATION_STEP_1_SCRIPT_COMMIT | tr \n \040)" ;\ - fi ; \ - if [[ $previousHash ]]; then git revert --no-commit --strategy=ort --strategy-option=ours $previousHash ; fi ;' -} - -function commit_changes() { - repo forall -c '\ - if [[ $(git status --short) ]]; then - repo start fina-step1 ; - git add -A . ; - git commit -m FINALIZATION_STEP_1_SCRIPT_COMMIT -m WILL_BE_AUTOMATICALLY_REVERTED ; - repo upload --cbr --no-verify -o nokeycheck -t -y . ; - git clean -fdx ; git reset --hard ; - fi' -} - -function finalize_step_1_main() { - # deprecated, do not use - exit 1 - - local top="$(dirname "$0")"/../.. - - repo selfupdate - - revert_to_unfinalized_state - - # vndk etc finalization - source $top/build/make/finalize-aidl-vndk-sdk-resources.sh - - # move all changes to fina-step1 branch and commit with a robot message - commit_changes -} - -finalize_step_1_main diff --git a/finalize-step-2-for-build-target.sh b/finalize-step-2-for-build-target.sh deleted file mode 100755 index b74fd03b41..0000000000 --- a/finalize-step-2-for-build-target.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# Continuous Integration script for *-finalization-2 branches. -# Reverts previous finalization script commits and runs local build. - -set -ex - -function finalize_step_2_main() { - local top="$(dirname "$0")"/../.. - local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - - # vndk etc finalization - source $top/build/make/finalize-aidl-vndk-sdk-resources.sh - - # prebuilts etc - source $top/build/make/finalize-sdk-rel.sh - - # mainline sdk prebuilts - source $top/build/make/finalize-locally-mainline-sdk.sh - - # build to confirm everything is OK - AIDL_FROZEN_REL=true $m -} - -finalize_step_2_main diff --git a/finalize-step-2.sh b/finalize-step-2.sh deleted file mode 100755 index ef80b2bfef..0000000000 --- a/finalize-step-2.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# Automation for finalize_branch_for_release.sh. -# Sets up local environment, runs the finalization script and submits the results. -# WIP: -# - does not submit, only sends to gerrit. - -# set -ex - -function revert_to_unfinalized_state() { - repo forall -c '\ - git checkout . ; git revert --abort ; git clean -fdx ;\ - git checkout @ ; git branch fina-step2 -D ; git reset --hard; \ - repo start fina-step2 ; git checkout @ ; git b fina-step2 -D ;\ - baselineHash="$(git log --format=%H --no-merges --max-count=1 --grep ^FINALIZATION_STEP_2_BASELINE_COMMIT)" ;\ - if [[ $baselineHash ]]; then - previousHash="$(git log --format=%H --no-merges --max-count=100 --grep ^FINALIZATION_STEP_2_SCRIPT_COMMIT $baselineHash..HEAD | tr \n \040)" ;\ - else - previousHash="$(git log --format=%H --no-merges --max-count=100 --grep ^FINALIZATION_STEP_2_SCRIPT_COMMIT | tr \n \040)" ;\ - fi ; \ - if [[ $previousHash ]]; then git revert --no-commit --strategy=ort --strategy-option=ours $previousHash ; fi ;' -} - -function commit_changes() { - repo forall -c '\ - if [[ $(git status --short) ]]; then - repo start fina-step1 ; - git add -A . ; - git commit -m FINALIZATION_STEP_2_SCRIPT_COMMIT -m WILL_BE_AUTOMATICALLY_REVERTED ; - repo upload --cbr --no-verify -o nokeycheck -t -y . ; - git clean -fdx ; git reset --hard ; - fi' -} - -function finalize_step_2_main() { - # deprecated, do not use - exit 1 - - local top="$(dirname "$0")"/../.. - - repo selfupdate - - revert_to_unfinalized_state - - # vndk etc finalization - source $top/build/make/finalize-aidl-vndk-sdk-resources.sh - - # move all changes to fina-step1 branch and commit with a robot message - commit_changes -} - -finalize_step_2_main diff --git a/finalize_branch_for_release.sh b/finalize_branch_for_release.sh deleted file mode 100755 index 9e9d6a188f..0000000000 --- a/finalize_branch_for_release.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -set -ex - -function finalize_main() { - local top="$(dirname "$0")"/../.. - - # default target to modify tree and build SDK - local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - - # Build finalization artifacts. - source $top/build/make/finalize-aidl-vndk-sdk-resources.sh - - # This command tests: - # The release state for AIDL. - # ABI difference between user and userdebug builds. - # Resource/SDK finalization. - # In the future, we would want to actually turn the branch into the REL - # state and test with that. - AIDL_FROZEN_REL=true $m - - # Build SDK (TODO) - # lunch sdk... - # m ... -} - -finalize_main - diff --git a/target/OWNERS b/target/OWNERS deleted file mode 100644 index feb274262b..0000000000 --- a/target/OWNERS +++ /dev/null @@ -1 +0,0 @@ -hansson@google.com diff --git a/target/product/aosp_riscv64.mk b/target/product/aosp_riscv64.mk index 436ff97588..1261fb16f3 100644 --- a/target/product/aosp_riscv64.mk +++ b/target/product/aosp_riscv64.mk @@ -66,6 +66,12 @@ PRODUCT_PACKAGES := \ init_system \ linker \ shell_and_utilities \ + com.android.art \ + com.android.conscrypt \ + com.android.i18n \ + com.android.runtime \ + com.android.tzdata \ + com.android.os.statsd \ $(call inherit-product, $(SRC_TARGET_DIR)/product/default_art_config.mk) PRODUCT_USES_DEFAULT_ART_CONFIG := false diff --git a/target/product/base_system.mk b/target/product/base_system.mk index b66d2c7920..94b5c16965 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -383,6 +383,7 @@ PRODUCT_PACKAGES_DEBUG := \ iotop \ iperf3 \ iw \ + libclang_rt.ubsan_standalone \ logpersist.start \ logtagd.rc \ procrank \ diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk index bd4fd1cd05..39666ead68 100644 --- a/target/product/runtime_libart.mk +++ b/target/product/runtime_libart.mk @@ -122,6 +122,7 @@ endif # without exceptions). PRODUCT_SYSTEM_PROPERTIES += \ pm.dexopt.post-boot?=extract \ + pm.dexopt.boot-after-mainline-update?=verify \ pm.dexopt.install?=speed-profile \ pm.dexopt.install-fast?=skip \ pm.dexopt.install-bulk?=speed-profile \ diff --git a/tests/run.rbc b/tests/run.rbc index 1b51719e6f..33583eb3cd 100644 --- a/tests/run.rbc +++ b/tests/run.rbc @@ -46,6 +46,11 @@ assert_eq("", rblf.mkstrip(" \n \t ")) assert_eq("a b c", rblf.mkstrip(" a b \n c \t")) assert_eq("1", rblf.mkstrip("1 ")) +assert_eq(["a", "b"], rblf.words("a b")) +assert_eq(["a", "b", "c"], rblf.words(["a b", "c"])) +# 1-tuple like we use in product variables +assert_eq(["a b", ("c",)], rblf.words(["a b", ("c",)])) + assert_eq("b1 b2", rblf.mksubst("a", "b", "a1 a2")) assert_eq(["b1", "x2"], rblf.mksubst("a", "b", ["a1", "x2"])) diff --git a/tools/Android.bp b/tools/Android.bp index 1f0d406566..f446973bbc 100644 --- a/tools/Android.bp +++ b/tools/Android.bp @@ -64,3 +64,8 @@ python_binary_host { name: "check_elf_file", srcs: ["check_elf_file.py"], } + +python_binary_host { + name: "generate_gts_shared_report", + srcs: ["generate_gts_shared_report.py"], +} diff --git a/tools/finalization/OWNERS b/tools/finalization/OWNERS new file mode 100644 index 0000000000..518b60db7e --- /dev/null +++ b/tools/finalization/OWNERS @@ -0,0 +1,5 @@ +include platform/build/soong:/OWNERS +smoreland@google.com +alexbuy@google.com +patb@google.com +zyy@google.com diff --git a/tools/finalization/build-step-1-and-2.sh b/tools/finalization/build-step-1-and-2.sh new file mode 100755 index 0000000000..eaaf0cd3a4 --- /dev/null +++ b/tools/finalization/build-step-1-and-2.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -ex + +function finalize_main_step12() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + # default target to modify tree and build SDK + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # SDK codename -> int + source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh + + # Platform/Mainline SDKs build and move to prebuilts + source $top/build/make/tools/finalization/localonly-finalize-mainline-sdk.sh + + # REL + source $top/build/make/tools/finalization/finalize-sdk-rel.sh +} + +finalize_main_step12 + diff --git a/tools/finalization/build-step-1-and-m.sh b/tools/finalization/build-step-1-and-m.sh new file mode 100755 index 0000000000..0e7129f342 --- /dev/null +++ b/tools/finalization/build-step-1-and-m.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -ex + +function finalize_main_step1_and_m() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/build-step-1.sh + + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # This command tests: + # The release state for AIDL. + # ABI difference between user and userdebug builds. + # Resource/SDK finalization. + AIDL_FROZEN_REL=true $m +} + +finalize_main_step1_and_m + diff --git a/tools/finalization/build-step-1.sh b/tools/finalization/build-step-1.sh new file mode 100755 index 0000000000..edf497ed03 --- /dev/null +++ b/tools/finalization/build-step-1.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -ex + +function finalize_main_step1() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + # default target to modify tree and build SDK + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # Build finalization artifacts. + source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh +} + +finalize_main_step1 + diff --git a/tools/finalization/build_soong_java_droidstubs.go.apply_hack.diff b/tools/finalization/build_soong_java_droidstubs.go.apply_hack.diff new file mode 100644 index 0000000000..9ced2a97b1 --- /dev/null +++ b/tools/finalization/build_soong_java_droidstubs.go.apply_hack.diff @@ -0,0 +1,30 @@ +From 12eea1512f2612f41b5cf7004ee2e6a189d548d7 Mon Sep 17 00:00:00 2001 +From: Alex Buynytskyy <alexbuy@google.com> +Date: Thu, 01 Sep 2022 10:44:21 -0700 +Subject: [PATCH] Hacky workaround for half-finalized builds. + +Metalava increments the SDK level by one when it's not "REL", so we +temporarily force the build to be "REL" while we're still in the +process of finalizing it. + +This CL must be reverted as part of actually declaring "REL". + +Bug: none +Test: Build +Change-Id: I8c24c6dabec0270bc384d8465c582a4ddbe8bd6c +--- + +diff --git a/java/droidstubs.go b/java/droidstubs.go +index 5777b18..ec4a0f4 100644 +--- a/java/droidstubs.go ++++ b/java/droidstubs.go +@@ -386,7 +386,8 @@ + } + if apiVersions != nil { + cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String()) +- cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) ++ // STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD ++ // cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) + cmd.FlagWithInput("--apply-api-levels ", apiVersions) + } + } diff --git a/tools/finalization/build_soong_java_droidstubs.go.revert_hack.diff b/tools/finalization/build_soong_java_droidstubs.go.revert_hack.diff new file mode 100644 index 0000000000..7dec97c0f3 --- /dev/null +++ b/tools/finalization/build_soong_java_droidstubs.go.revert_hack.diff @@ -0,0 +1,26 @@ +From c0f6e8fe4c3b6803be97aeea6683631d616412f4 Mon Sep 17 00:00:00 2001 +From: Alex Buynytskyy <alexbuy@google.com> +Date: Thu, 08 Dec 2022 17:52:52 +0000 +Subject: [PATCH] Revert "Hacky workaround for half-finalized builds." + +This reverts commit 12eea1512f2612f41b5cf7004ee2e6a189d548d7. + +Reason for revert: finalization-2 + +Change-Id: Ifc801271628808693b1cb20206f8f81c9a6c694d +--- + +diff --git a/java/droidstubs.go b/java/droidstubs.go +index ec4a0f4..5777b18 100644 +--- a/java/droidstubs.go ++++ b/java/droidstubs.go +@@ -386,8 +386,7 @@ + } + if apiVersions != nil { + cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String()) +- // STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD +- // cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) ++ cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) + cmd.FlagWithInput("--apply-api-levels ", apiVersions) + } + } diff --git a/finalize-cleanup.sh b/tools/finalization/cleanup.sh index c62a97c190..cd87b1d129 100755 --- a/finalize-cleanup.sh +++ b/tools/finalization/cleanup.sh @@ -4,7 +4,11 @@ # set -ex function finalize_revert_local_changes_main() { - local top="$(dirname "$0")"/../.. + local top="$(dirname "$0")"/../../../.. + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # remove the out folder + $m clobber repo selfupdate diff --git a/tools/finalization/environment.sh b/tools/finalization/environment.sh new file mode 100755 index 0000000000..983e19dc4a --- /dev/null +++ b/tools/finalization/environment.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -ex + +export FINAL_BUG_ID='0' + +export FINAL_PLATFORM_CODENAME='UpsideDownCake' +export CURRENT_PLATFORM_CODENAME='VanillaIceCream' +export FINAL_PLATFORM_CODENAME_JAVA='UPSIDE_DOWN_CAKE' +export FINAL_PLATFORM_SDK_VERSION='34' +export FINAL_PLATFORM_VERSION='14' + +export FINAL_BUILD_PREFIX='UP1A' + +export FINAL_MAINLINE_EXTENSION='6'
\ No newline at end of file diff --git a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh new file mode 100755 index 0000000000..e23e585311 --- /dev/null +++ b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +set -ex + +function apply_droidstubs_hack() { + if ! grep -q 'STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD' "$top/build/soong/java/droidstubs.go" ; then + git -C "$top/build/soong" apply --allow-empty ../../build/make/tools/finalization/build_soong_java_droidstubs.go.apply_hack.diff + fi +} + +function finalize_bionic_ndk() { + # Adding __ANDROID_API_<>__. + # If this hasn't done then it's not used and not really needed. Still, let's check and add this. + local api_level="$top/bionic/libc/include/android/api-level.h" + if ! grep -q "\__.*$((${FINAL_PLATFORM_SDK_VERSION}))" $api_level ; then + local tmpfile=$(mktemp /tmp/finalization.XXXXXX) + echo " +/** Names the \"${FINAL_PLATFORM_CODENAME:0:1}\" API level ($FINAL_PLATFORM_SDK_VERSION), for comparison against \`__ANDROID_API__\`. */ +#define __ANDROID_API_${FINAL_PLATFORM_CODENAME:0:1}__ $FINAL_PLATFORM_SDK_VERSION" > "$tmpfile" + + local api_level="$top/bionic/libc/include/android/api-level.h" + sed -i -e "/__.*$((${FINAL_PLATFORM_SDK_VERSION}-1))/r""$tmpfile" $api_level + + rm "$tmpfile" + fi +} + +function finalize_modules_utils() { + local shortCodename="${FINAL_PLATFORM_CODENAME:0:1}" + local methodPlaceholder="INSERT_NEW_AT_LEAST_${shortCodename}_METHOD_HERE" + + local tmpfile=$(mktemp /tmp/finalization.XXXXXX) + echo " /** Checks if the device is running on a release version of Android $FINAL_PLATFORM_CODENAME or newer */ + @ChecksSdkIntAtLeast(api = $FINAL_PLATFORM_SDK_VERSION /* BUILD_VERSION_CODES.$FINAL_PLATFORM_CODENAME */) + public static boolean isAtLeast${FINAL_PLATFORM_CODENAME:0:1}() { + return SDK_INT >= $FINAL_PLATFORM_SDK_VERSION; + }" > "$tmpfile" + + local javaFuncRegex='\/\*\*[^{]*isAtLeast'"${shortCodename}"'() {[^{}]*}' + local javaFuncReplace="N;N;N;N;N;N;N;N; s/$javaFuncRegex/$methodPlaceholder/; /$javaFuncRegex/!{P;D};" + + local javaSdkLevel="$top/frameworks/libs/modules-utils/java/com/android/modules/utils/build/SdkLevel.java" + sed -i "$javaFuncReplace" $javaSdkLevel + + sed -i "/${methodPlaceholder}"'/{ + r '"$tmpfile"' + d}' $javaSdkLevel + + echo "// Checks if the device is running on release version of Android ${FINAL_PLATFORM_CODENAME:0:1} or newer. +inline bool IsAtLeast${FINAL_PLATFORM_CODENAME:0:1}() { return android_get_device_api_level() >= $FINAL_PLATFORM_SDK_VERSION; }" > "$tmpfile" + + local cppFuncRegex='\/\/[^{]*IsAtLeast'"${shortCodename}"'() {[^{}]*}' + local cppFuncReplace="N;N;N;N;N;N; s/$cppFuncRegex/$methodPlaceholder/; /$cppFuncRegex/!{P;D};" + + local cppSdkLevel="$top/frameworks/libs/modules-utils/build/include/android-modules-utils/sdk_level.h" + sed -i "$cppFuncReplace" $cppSdkLevel + sed -i "/${methodPlaceholder}"'/{ + r '"$tmpfile"' + d}' $cppSdkLevel + + rm "$tmpfile" +} + +function finalize_aidl_vndk_sdk_resources() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + local SDK_CODENAME="public static final int $FINAL_PLATFORM_CODENAME_JAVA = CUR_DEVELOPMENT;" + local SDK_VERSION="public static final int $FINAL_PLATFORM_CODENAME_JAVA = $FINAL_PLATFORM_SDK_VERSION;" + + # default target to modify tree and build SDK + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # The full process can be found at (INTERNAL) go/android-sdk-finalization. + + # apply droidstubs hack to prevent tools from incrementing an API version + apply_droidstubs_hack + + # bionic/NDK + finalize_bionic_ndk + + # VNDK definitions for new SDK version + cp "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-current.txt" \ + "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-$FINAL_PLATFORM_SDK_VERSION.txt" + + AIDL_TRANSITIVE_FREEZE=true $m aidl-freeze-api create_reference_dumps + + # Generate ABI dumps + ANDROID_BUILD_TOP="$top" \ + out/host/linux-x86/bin/create_reference_dumps \ + -p aosp_arm64 --build-variant user + + echo "NOTE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF (until 'DONE')" + # Update new versions of files. See update-vndk-list.sh (which requires envsetup.sh) + $m check-vndk-list || \ + { cp $top/out/soong/vndk/vndk.libraries.txt $top/build/make/target/product/gsi/current.txt; } + echo "DONE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF" + + # Finalize SDK + + # frameworks/libs/modules-utils + finalize_modules_utils + + # build/make + local version_defaults="$top/build/make/core/version_defaults.mk" + sed -i -e "s/PLATFORM_SDK_VERSION := .*/PLATFORM_SDK_VERSION := ${FINAL_PLATFORM_SDK_VERSION}/g" $version_defaults + sed -i -e "s/PLATFORM_VERSION_LAST_STABLE := .*/PLATFORM_VERSION_LAST_STABLE := ${FINAL_PLATFORM_VERSION}/g" $version_defaults + sed -i -e "s/sepolicy_major_vers := .*/sepolicy_major_vers := ${FINAL_PLATFORM_SDK_VERSION}/g" "$top/build/make/core/config.mk" + cp "$top/build/make/target/product/gsi/current.txt" "$top/build/make/target/product/gsi/$FINAL_PLATFORM_SDK_VERSION.txt" + + # build/soong + sed -i -e "/:.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\\t\t\t\"${FINAL_PLATFORM_CODENAME}\": ${FINAL_PLATFORM_SDK_VERSION}," "$top/build/soong/android/api_levels.go" + + # cts + echo ${FINAL_PLATFORM_VERSION} > "$top/cts/tests/tests/os/assets/platform_releases.txt" + sed -i -e "s/EXPECTED_SDK = $((${FINAL_PLATFORM_SDK_VERSION}-1))/EXPECTED_SDK = ${FINAL_PLATFORM_SDK_VERSION}/g" "$top/cts/tests/tests/os/src/android/os/cts/BuildVersionTest.java" + + # libcore + sed -i "s%$SDK_CODENAME%$SDK_VERSION%g" "$top/libcore/dalvik/src/main/java/dalvik/annotation/compat/VersionCodes.java" + + # platform_testing + local version_codes="$top/platform_testing/libraries/compatibility-common-util/src/com/android/compatibility/common/util/VersionCodes.java" + sed -i -e "/=.*$((${FINAL_PLATFORM_SDK_VERSION}-1));/a \\ ${SDK_VERSION}" $version_codes + + # Finalize resources + "$top/frameworks/base/tools/aapt2/tools/finalize_res.py" \ + "$top/frameworks/base/core/res/res/values/public-staging.xml" \ + "$top/frameworks/base/core/res/res/values/public-final.xml" + + # frameworks/base + sed -i "s%$SDK_CODENAME%$SDK_VERSION%g" "$top/frameworks/base/core/java/android/os/Build.java" + sed -i -e "/=.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\ SDK_${FINAL_PLATFORM_CODENAME_JAVA} = ${FINAL_PLATFORM_SDK_VERSION}," "$top/frameworks/base/tools/aapt/SdkConstants.h" + sed -i -e "/=.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\ SDK_${FINAL_PLATFORM_CODENAME_JAVA} = ${FINAL_PLATFORM_SDK_VERSION}," "$top/frameworks/base/tools/aapt2/SdkConstants.h" + + # Bump Mainline SDK extension version. + "$top/packages/modules/SdkExtensions/gen_sdk/bump_sdk.sh" ${FINAL_MAINLINE_EXTENSION} + local version_defaults="$top/build/make/core/version_defaults.mk" + sed -i -e "s/PLATFORM_SDK_EXTENSION_VERSION := .*/PLATFORM_SDK_EXTENSION_VERSION := ${FINAL_MAINLINE_EXTENSION}/g" $version_defaults + + # Force update current.txt + $m clobber + $m update-api +} + +finalize_aidl_vndk_sdk_resources + diff --git a/tools/finalization/finalize-sdk-rel.sh b/tools/finalization/finalize-sdk-rel.sh new file mode 100755 index 0000000000..56f3bc3c87 --- /dev/null +++ b/tools/finalization/finalize-sdk-rel.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -ex + +function revert_droidstubs_hack() { + if grep -q 'STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD' "$top/build/soong/java/droidstubs.go" ; then + git -C "$top/build/soong" apply --allow-empty ../../build/make/tools/finalization/build_soong_java_droidstubs.go.revert_hack.diff + fi +} + +function apply_prerelease_sdk_hack() { + if ! grep -q 'STOPSHIP: hack for the pre-release SDK' "$top/frameworks/base/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java" ; then + git -C "$top/frameworks/base" apply --allow-empty ../../build/make/tools/finalization/frameworks_base.apply_hack.diff + fi +} + +function finalize_sdk_rel() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + # default target to modify tree and build SDK + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # revert droidstubs hack now we are switching to REL + revert_droidstubs_hack + + # let the apps built with pre-release SDK parse + apply_prerelease_sdk_hack + + # adb keys + $m adb + LOGNAME=android-eng HOSTNAME=google.com "$top/out/host/linux-x86/bin/adb" keygen "$top/vendor/google/security/adb/${FINAL_PLATFORM_VERSION}.adb_key" + + # build/make/core/version_defaults.mk + sed -i -e "s/PLATFORM_VERSION_CODENAME.${FINAL_BUILD_PREFIX} := .*/PLATFORM_VERSION_CODENAME.${FINAL_BUILD_PREFIX} := REL/g" "$top/build/make/core/version_defaults.mk" + + # cts + echo "$FINAL_PLATFORM_VERSION" > "$top/cts/tests/tests/os/assets/platform_versions.txt" + if [ "$FINAL_PLATFORM_CODENAME" != "$CURRENT_PLATFORM_CODENAME" ]; then + echo "$CURRENT_PLATFORM_CODENAME" >> "./cts/tests/tests/os/assets/platform_versions.txt" + fi + git -C "$top/cts" mv hostsidetests/theme/assets/${FINAL_PLATFORM_CODENAME} hostsidetests/theme/assets/${FINAL_PLATFORM_SDK_VERSION} + + # system/sepolicy + mkdir -p "$top/system/sepolicy/prebuilts/api/${FINAL_PLATFORM_SDK_VERSION}.0/" + cp -r "$top/system/sepolicy/public/" "$top/system/sepolicy/prebuilts/api/${FINAL_PLATFORM_SDK_VERSION}.0/" + cp -r "$top/system/sepolicy/private/" "$top/system/sepolicy/prebuilts/api/${FINAL_PLATFORM_SDK_VERSION}.0/" + + # prebuilts/abi-dumps/ndk + mv "$top/prebuilts/abi-dumps/ndk/current" "$top/prebuilts/abi-dumps/ndk/$FINAL_PLATFORM_SDK_VERSION" + + # prebuilts/abi-dumps/vndk + mv "$top/prebuilts/abi-dumps/vndk/$CURRENT_PLATFORM_CODENAME" "$top/prebuilts/abi-dumps/vndk/$FINAL_PLATFORM_SDK_VERSION" + + # prebuilts/abi-dumps/platform + mv "$top/prebuilts/abi-dumps/platform/current" "$top/prebuilts/abi-dumps/platform/$FINAL_PLATFORM_SDK_VERSION" +} + +finalize_sdk_rel + diff --git a/tools/finalization/frameworks_base.apply_hack.diff b/tools/finalization/frameworks_base.apply_hack.diff new file mode 100644 index 0000000000..545c2305fd --- /dev/null +++ b/tools/finalization/frameworks_base.apply_hack.diff @@ -0,0 +1,129 @@ +From 3c9a5321dc94124367f2f4363d85a8f488f5d4d1 Mon Sep 17 00:00:00 2001 +From: Yurii Zubrytskyi <zyy@google.com> +Date: Wed, 04 May 2022 01:05:24 -0700 +Subject: [PATCH] HACK: allow apps with pre-release SDK RESTRICT AUTOMERGE + +Revert before releasing +Let the apps built with pre-release Tiramisu SDK parse ++ fix a test that didn't expect REL builds to throw + when checking for lettered versions + +Test: build +Bug: 225745567 +Bug: 231407096 +Change-Id: Ia0de2ab1a99e5f186f0d871e6225d88bf3308df6 +--- + +diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java +index c15b3e0..3f4df4d 100644 +--- a/core/java/android/content/pm/PackageParser.java ++++ b/core/java/android/content/pm/PackageParser.java +@@ -2628,6 +2628,15 @@ + return Build.VERSION_CODES.CUR_DEVELOPMENT; + } + ++ // STOPSHIP: hack for the pre-release SDK ++ if (platformSdkCodenames.length == 0 ++ && Build.VERSION.KNOWN_CODENAMES.stream().max(String::compareTo).orElse("").equals( ++ targetCode)) { ++ Slog.w(TAG, "Package requires development platform " + targetCode ++ + ", returning current version " + Build.VERSION.SDK_INT); ++ return Build.VERSION.SDK_INT; ++ } ++ + // Otherwise, we're looking at an incompatible pre-release SDK. + if (platformSdkCodenames.length > 0) { + outError[0] = "Requires development platform " + targetCode +@@ -2699,6 +2708,15 @@ + return Build.VERSION_CODES.CUR_DEVELOPMENT; + } + ++ // STOPSHIP: hack for the pre-release SDK ++ if (platformSdkCodenames.length == 0 ++ && Build.VERSION.KNOWN_CODENAMES.stream().max(String::compareTo).orElse("").equals( ++ minCode)) { ++ Slog.w(TAG, "Package requires min development platform " + minCode ++ + ", returning current version " + Build.VERSION.SDK_INT); ++ return Build.VERSION.SDK_INT; ++ } ++ + // Otherwise, we're looking at an incompatible pre-release SDK. + if (platformSdkCodenames.length > 0) { + outError[0] = "Requires development platform " + minCode +diff --git a/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java b/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java +index 3e1c5bb..8cc4cdb 100644 +--- a/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java ++++ b/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java +@@ -316,6 +316,15 @@ + return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT); + } + ++ // STOPSHIP: hack for the pre-release SDK ++ if (platformSdkCodenames.length == 0 ++ && Build.VERSION.KNOWN_CODENAMES.stream().max(String::compareTo).orElse("").equals( ++ minCode)) { ++ Slog.w(TAG, "Parsed package requires min development platform " + minCode ++ + ", returning current version " + Build.VERSION.SDK_INT); ++ return input.success(Build.VERSION.SDK_INT); ++ } ++ + // Otherwise, we're looking at an incompatible pre-release SDK. + if (platformSdkCodenames.length > 0) { + return input.error(PackageManager.INSTALL_FAILED_OLDER_SDK, +@@ -368,19 +377,27 @@ + return input.success(targetVers); + } + ++ // If it's a pre-release SDK and the codename matches this platform, it ++ // definitely targets this SDK. ++ if (matchTargetCode(platformSdkCodenames, targetCode)) { ++ return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT); ++ } ++ ++ // STOPSHIP: hack for the pre-release SDK ++ if (platformSdkCodenames.length == 0 ++ && Build.VERSION.KNOWN_CODENAMES.stream().max(String::compareTo).orElse("").equals( ++ targetCode)) { ++ Slog.w(TAG, "Parsed package requires development platform " + targetCode ++ + ", returning current version " + Build.VERSION.SDK_INT); ++ return input.success(Build.VERSION.SDK_INT); ++ } ++ + try { + if (allowUnknownCodenames && UnboundedSdkLevel.isAtMost(targetCode)) { + return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT); + } + } catch (IllegalArgumentException e) { +- // isAtMost() throws it when encountering an older SDK codename +- return input.error(PackageManager.INSTALL_FAILED_OLDER_SDK, e.getMessage()); +- } +- +- // If it's a pre-release SDK and the codename matches this platform, it +- // definitely targets this SDK. +- if (matchTargetCode(platformSdkCodenames, targetCode)) { +- return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT); ++ return input.error(PackageManager.INSTALL_FAILED_OLDER_SDK, "Bad package SDK"); + } + + // Otherwise, we're looking at an incompatible pre-release SDK. +diff --git a/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java b/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java +index 92c7871..687e8f7 100644 +--- a/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java ++++ b/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java +@@ -446,14 +446,14 @@ + + " <library \n" + + " name=\"foo\"\n" + + " file=\"" + mFooJar + "\"\n" +- + " on-bootclasspath-before=\"Q\"\n" ++ + " on-bootclasspath-before=\"A\"\n" + + " on-bootclasspath-since=\"W\"\n" + + " />\n\n" + + " </permissions>"; + parseSharedLibraries(contents); + assertFooIsOnlySharedLibrary(); + SystemConfig.SharedLibraryEntry entry = mSysConfig.getSharedLibraries().get("foo"); +- assertThat(entry.onBootclasspathBefore).isEqualTo("Q"); ++ assertThat(entry.onBootclasspathBefore).isEqualTo("A"); + assertThat(entry.onBootclasspathSince).isEqualTo("W"); + } + diff --git a/tools/finalization/frameworks_base.revert_hack.diff b/tools/finalization/frameworks_base.revert_hack.diff new file mode 100644 index 0000000000..1d147b1ad9 --- /dev/null +++ b/tools/finalization/frameworks_base.revert_hack.diff @@ -0,0 +1,125 @@ +From b4ae5c71f327d00081bbb0b7b26d48eb88761fbc Mon Sep 17 00:00:00 2001 +From: Alex Buynytskyy <alexbuy@google.com> +Date: Tue, 21 Feb 2023 01:43:14 +0000 +Subject: [PATCH] Revert "HACK: allow apps with pre-release SDK RESTRICT AUTOMERGE" + +This reverts commit 3c9a5321dc94124367f2f4363d85a8f488f5d4d1. + +Reason for revert: not needed anymore + +Change-Id: I5c5e3af78a41e7bd8cbc99464dccc57c345105f3 +--- + +diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java +index 3f4df4d..c15b3e0 100644 +--- a/core/java/android/content/pm/PackageParser.java ++++ b/core/java/android/content/pm/PackageParser.java +@@ -2628,15 +2628,6 @@ + return Build.VERSION_CODES.CUR_DEVELOPMENT; + } + +- // STOPSHIP: hack for the pre-release SDK +- if (platformSdkCodenames.length == 0 +- && Build.VERSION.KNOWN_CODENAMES.stream().max(String::compareTo).orElse("").equals( +- targetCode)) { +- Slog.w(TAG, "Package requires development platform " + targetCode +- + ", returning current version " + Build.VERSION.SDK_INT); +- return Build.VERSION.SDK_INT; +- } +- + // Otherwise, we're looking at an incompatible pre-release SDK. + if (platformSdkCodenames.length > 0) { + outError[0] = "Requires development platform " + targetCode +@@ -2708,15 +2699,6 @@ + return Build.VERSION_CODES.CUR_DEVELOPMENT; + } + +- // STOPSHIP: hack for the pre-release SDK +- if (platformSdkCodenames.length == 0 +- && Build.VERSION.KNOWN_CODENAMES.stream().max(String::compareTo).orElse("").equals( +- minCode)) { +- Slog.w(TAG, "Package requires min development platform " + minCode +- + ", returning current version " + Build.VERSION.SDK_INT); +- return Build.VERSION.SDK_INT; +- } +- + // Otherwise, we're looking at an incompatible pre-release SDK. + if (platformSdkCodenames.length > 0) { + outError[0] = "Requires development platform " + minCode +diff --git a/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java b/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java +index 8cc4cdb..3e1c5bb 100644 +--- a/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java ++++ b/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java +@@ -316,15 +316,6 @@ + return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT); + } + +- // STOPSHIP: hack for the pre-release SDK +- if (platformSdkCodenames.length == 0 +- && Build.VERSION.KNOWN_CODENAMES.stream().max(String::compareTo).orElse("").equals( +- minCode)) { +- Slog.w(TAG, "Parsed package requires min development platform " + minCode +- + ", returning current version " + Build.VERSION.SDK_INT); +- return input.success(Build.VERSION.SDK_INT); +- } +- + // Otherwise, we're looking at an incompatible pre-release SDK. + if (platformSdkCodenames.length > 0) { + return input.error(PackageManager.INSTALL_FAILED_OLDER_SDK, +@@ -377,27 +368,19 @@ + return input.success(targetVers); + } + +- // If it's a pre-release SDK and the codename matches this platform, it +- // definitely targets this SDK. +- if (matchTargetCode(platformSdkCodenames, targetCode)) { +- return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT); +- } +- +- // STOPSHIP: hack for the pre-release SDK +- if (platformSdkCodenames.length == 0 +- && Build.VERSION.KNOWN_CODENAMES.stream().max(String::compareTo).orElse("").equals( +- targetCode)) { +- Slog.w(TAG, "Parsed package requires development platform " + targetCode +- + ", returning current version " + Build.VERSION.SDK_INT); +- return input.success(Build.VERSION.SDK_INT); +- } +- + try { + if (allowUnknownCodenames && UnboundedSdkLevel.isAtMost(targetCode)) { + return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT); + } + } catch (IllegalArgumentException e) { +- return input.error(PackageManager.INSTALL_FAILED_OLDER_SDK, "Bad package SDK"); ++ // isAtMost() throws it when encountering an older SDK codename ++ return input.error(PackageManager.INSTALL_FAILED_OLDER_SDK, e.getMessage()); ++ } ++ ++ // If it's a pre-release SDK and the codename matches this platform, it ++ // definitely targets this SDK. ++ if (matchTargetCode(platformSdkCodenames, targetCode)) { ++ return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT); + } + + // Otherwise, we're looking at an incompatible pre-release SDK. +diff --git a/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java b/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java +index 687e8f7..92c7871 100644 +--- a/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java ++++ b/services/tests/servicestests/src/com/android/server/systemconfig/SystemConfigTest.java +@@ -446,14 +446,14 @@ + + " <library \n" + + " name=\"foo\"\n" + + " file=\"" + mFooJar + "\"\n" +- + " on-bootclasspath-before=\"A\"\n" ++ + " on-bootclasspath-before=\"Q\"\n" + + " on-bootclasspath-since=\"W\"\n" + + " />\n\n" + + " </permissions>"; + parseSharedLibraries(contents); + assertFooIsOnlySharedLibrary(); + SystemConfig.SharedLibraryEntry entry = mSysConfig.getSharedLibraries().get("foo"); +- assertThat(entry.onBootclasspathBefore).isEqualTo("A"); ++ assertThat(entry.onBootclasspathBefore).isEqualTo("Q"); + assertThat(entry.onBootclasspathSince).isEqualTo("W"); + } + diff --git a/tools/finalization/localonly-finalize-mainline-sdk.sh b/tools/finalization/localonly-finalize-mainline-sdk.sh new file mode 100755 index 0000000000..104b6acb04 --- /dev/null +++ b/tools/finalization/localonly-finalize-mainline-sdk.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -ex + +function finalize_locally_mainline_sdk() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + # Build Platform SDKs. + $top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=sdk TARGET_BUILD_VARIANT=userdebug sdk dist sdk_repo + + # Build Modules SDKs. + TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true "$top/vendor/google/build/mainline_modules_sdks.sh" + + # Update prebuilts. + # "$top/prebuilts/build-tools/path/linux-x86/python3" "$top/packages/modules/common/tools/finalize_sdk.py" -l -b 0 -f ${FINAL_MAINLINE_EXTENSION} -r '' 0 + "$top/prebuilts/build-tools/path/linux-x86/python3" "$top/prebuilts/sdk/update_prebuilts.py" --local_mode -f ${FINAL_PLATFORM_SDK_VERSION} -e ${FINAL_MAINLINE_EXTENSION} --bug 1 1 +} + +finalize_locally_mainline_sdk + diff --git a/tools/finalization/step-1.sh b/tools/finalization/step-1.sh new file mode 100755 index 0000000000..cf21e4511f --- /dev/null +++ b/tools/finalization/step-1.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Script to perform a 1st step of Android Finalization: API/SDK finalization, create CLs and upload to Gerrit. + +set -ex + +function commit_step_1_changes() { + set +e + repo forall -c '\ + if [[ $(git status --short) ]]; then + repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization" ; + git add -A . ; + git commit -m "$FINAL_PLATFORM_CODENAME is now $FINAL_PLATFORM_SDK_VERSION" \ + -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization +Bug: $FINAL_BUG_ID +Test: build"; + repo upload --cbr --no-verify -o nokeycheck -t -y . ; + fi' +} + +function finalize_step_1_main() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # vndk etc finalization + source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh + + # move all changes to finalization branch/topic and upload to gerrit + commit_step_1_changes + + # build to confirm everything is OK + AIDL_FROZEN_REL=true $m +} + +finalize_step_1_main diff --git a/tools/finalization/step-2.sh b/tools/finalization/step-2.sh new file mode 100755 index 0000000000..d0b24ae1fc --- /dev/null +++ b/tools/finalization/step-2.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Script to perform a 2nd step of Android Finalization: REL finalization, create CLs and upload to Gerrit. + +function commit_step_2_changes() { + repo forall -c '\ + if [[ $(git status --short) ]]; then + repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization-Rel" ; + git add -A . ; + git commit -m "$FINAL_PLATFORM_CODENAME/$FINAL_PLATFORM_SDK_VERSION is now REL" \ + -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization +Bug: $FINAL_BUG_ID +Test: build"; + + repo upload --cbr --no-verify -o nokeycheck -t -y . ; + fi' +} + +function finalize_step_2_main() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # prebuilts etc + source $top/build/make/tools/finalization/finalize-sdk-rel.sh + + # move all changes to finalization branch/topic and upload to gerrit + commit_step_2_changes + + # build to confirm everything is OK + AIDL_FROZEN_REL=true $m +} + +finalize_step_2_main diff --git a/tools/generate_gts_shared_report.py b/tools/generate_gts_shared_report.py new file mode 100644 index 0000000000..11c9364189 --- /dev/null +++ b/tools/generate_gts_shared_report.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2022 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Checks and generates a report for gts modules that should be open-sourced. + +Usage: + generate_gts_open_source_report.py + --gtsv-metalic [gts-verifier meta_lic] + --gts-test-metalic [android-gts meta_lic] + --checkshare [COMPLIANCE_CHECKSHARE] + --gts-test-dir [directory of android-gts] + --output [output file] + +Output example: + GTS-Verifier: PASS/FAIL + GTS-Modules: PASS/FAIL + GtsIncrementalInstallTestCases_BackgroundProcess + GtsUnsignedNetworkStackTestCases +""" +import sys +import argparse +import subprocess +import re + +def _get_args(): + """Parses input arguments.""" + parser = argparse.ArgumentParser() + parser.add_argument( + '--gtsv-metalic', required=True, + help='license meta_lic file path of gts-verifier.zip') + parser.add_argument( + '--gts-test-metalic', required=True, + help='license meta_lic file path of android-gts.zip') + parser.add_argument( + '--checkshare', required=True, + help='path of the COMPLIANCE_CHECKSHARE tool') + parser.add_argument( + '--gts-test-dir', required=True, + help='directory of android-gts') + parser.add_argument( + '-o', '--output', required=True, + help='file path of the output report') + return parser.parse_args() + +def _check_gtsv(checkshare: str, gtsv_metalic: str) -> str: + """Checks gts-verifier license. + + Args: + checkshare: path of the COMPLIANCE_CHECKSHARE tool + gtsv_metalic: license meta_lic file path of gts-verifier.zip + + Returns: + PASS when gts-verifier.zip doesn't need to be shared, and FAIL + when gts-verifier.zip need to be shared. + """ + cmd = f'{checkshare} {gtsv_metalic}' + proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + proc.communicate() + return 'PASS' if proc.returncode == 0 else 'FAIL' + +def _check_gts_test(checkshare: str, gts_test_metalic: str, + gts_test_dir: str) -> tuple[str, set[str]]: + """Checks android-gts license. + + Args: + checkshare: path of the COMPLIANCE_CHECKSHARE tool + gts_test_metalic: license meta_lic file path of android-gts.zip + gts_test_dir: directory of android-gts + + Returns: + Check result (PASS when android-gts doesn't need to be shared, + FAIL when some gts modules need to be shared) and gts modules + that need to be shared. + """ + cmd = f'{checkshare} {gts_test_metalic}' + proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + _, str_stderr = map(lambda b: b.decode(), proc.communicate()) + if proc.returncode == 0: + return 'PASS', [] + open_source_modules = set() + for error_line in str_stderr.split('\n'): + # Skip the empty liness + if not error_line: + continue + module_meta_lic = error_line.strip().split()[0] + groups = re.fullmatch( + re.compile(f'.*/{gts_test_dir}/(.*)'), module_meta_lic) + if groups: + open_source_modules.add( + groups[1].removesuffix('.meta_lic')) + return 'FAIL', open_source_modules + + +def main(argv): + args = _get_args() + + gtsv_metalic = args.gtsv_metalic + gts_test_metalic = args.gts_test_metalic + output_file = args.output + checkshare = args.checkshare + gts_test_dir = args.gts_test_dir + + with open(output_file, 'w') as file: + result = _check_gtsv(checkshare, gtsv_metalic) + file.write(f'GTS-Verifier: {result}\n') + result, open_source_modules = _check_gts_test( + checkshare, gts_test_metalic, gts_test_dir) + file.write(f'GTS-Modules: {result}\n') + for open_source_module in open_source_modules: + file.write(f'\t{open_source_module}\n') + +if __name__ == "__main__": + main(sys.argv)
\ No newline at end of file diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index b45b0a301f..e154a0f60a 100644 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -1001,7 +1001,8 @@ def AddImagesToTargetFiles(filename): if has_init_boot: banner("init_boot") init_boot_image = common.GetBootableImage( - "IMAGES/init_boot.img", "init_boot.img", OPTIONS.input_tmp, "INIT_BOOT") + "IMAGES/init_boot.img", "init_boot.img", OPTIONS.input_tmp, "INIT_BOOT", + dev_nodes=True) if init_boot_image: partitions['init_boot'] = os.path.join( OPTIONS.input_tmp, "IMAGES", "init_boot.img") diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 9919029854..8d16ca0d44 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -302,6 +302,8 @@ def RunAndCheckOutput(args, verbose=None, **kwargs): Raises: ExternalError: On non-zero exit from the command. """ + if verbose is None: + verbose = OPTIONS.verbose proc = Run(args, verbose=verbose, **kwargs) output, _ = proc.communicate() if output is None: @@ -1545,14 +1547,20 @@ def BuildVBMeta(image_path, partitions, name, needed_partitions): def _MakeRamdisk(sourcedir, fs_config_file=None, + dev_node_file=None, ramdisk_format=RamdiskFormat.GZ): ramdisk_img = tempfile.NamedTemporaryFile() - if fs_config_file is not None and os.access(fs_config_file, os.F_OK): - cmd = ["mkbootfs", "-f", fs_config_file, - os.path.join(sourcedir, "RAMDISK")] - else: - cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")] + cmd = ["mkbootfs"] + + if fs_config_file and os.access(fs_config_file, os.F_OK): + cmd.extend(["-f", fs_config_file]) + + if dev_node_file and os.access(dev_node_file, os.F_OK): + cmd.extend(["-n", dev_node_file]) + + cmd.append(os.path.join(sourcedir, "RAMDISK")) + p1 = Run(cmd, stdout=subprocess.PIPE) if ramdisk_format == RamdiskFormat.LZ4: p2 = Run(["lz4", "-l", "-12", "--favor-decSpeed"], stdin=p1.stdout, @@ -1570,7 +1578,8 @@ def _MakeRamdisk(sourcedir, fs_config_file=None, return ramdisk_img -def _BuildBootableImage(image_name, sourcedir, fs_config_file, info_dict=None, +def _BuildBootableImage(image_name, sourcedir, fs_config_file, + dev_node_file=None, info_dict=None, has_ramdisk=False, two_step_image=False): """Build a bootable image from the specified sourcedir. @@ -1612,7 +1621,7 @@ def _BuildBootableImage(image_name, sourcedir, fs_config_file, info_dict=None, if has_ramdisk: ramdisk_format = GetRamdiskFormat(info_dict) - ramdisk_img = _MakeRamdisk(sourcedir, fs_config_file, + ramdisk_img = _MakeRamdisk(sourcedir, fs_config_file, dev_node_file, ramdisk_format=ramdisk_format) # use MKBOOTIMG from environ, or "mkbootimg" if empty or not set @@ -1820,7 +1829,8 @@ def HasRamdisk(partition_name, info_dict=None): def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, - info_dict=None, two_step_image=False): + info_dict=None, two_step_image=False, + dev_nodes=False): """Return a File object with the desired bootable image. Look for it in 'unpack_dir'/BOOTABLE_IMAGES under the name 'prebuilt_name', @@ -1856,6 +1866,8 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt" data = _BuildBootableImage(prebuilt_name, os.path.join(unpack_dir, tree_subdir), os.path.join(unpack_dir, fs_config), + os.path.join(unpack_dir, 'META/ramdisk_node_list') + if dev_nodes else None, info_dict, has_ramdisk, two_step_image) if data: return File(name, data) @@ -2893,13 +2905,12 @@ def ZipDelete(zip_filename, entries, force=False): fd, new_zipfile = tempfile.mkstemp(dir=os.path.dirname(zip_filename)) os.close(fd) + cmd = ["zip2zip", "-i", zip_filename, "-o", new_zipfile] + for entry in entries: + cmd.append("-x") + cmd.append(entry) + RunAndCheckOutput(cmd) - with zipfile.ZipFile(new_zipfile, 'w') as zout: - for item in zin.infolist(): - if item.filename in entries: - continue - buffer = zin.read(item.filename) - zout.writestr(item, buffer) os.replace(new_zipfile, zip_filename) diff --git a/tools/releasetools/merge/merge_target_files.py b/tools/releasetools/merge/merge_target_files.py index c95ceadcf6..54122b0b05 100755 --- a/tools/releasetools/merge/merge_target_files.py +++ b/tools/releasetools/merge/merge_target_files.py @@ -156,6 +156,15 @@ def move_only_exists(source, destination): shutil.move(source, destination) +def remove_file_if_exists(file_name): + """Remove the file if it exists and skip otherwise.""" + + try: + os.remove(file_name) + except FileNotFoundError: + pass + + def create_merged_package(temp_dir): """Merges two target files packages into one target files structure. @@ -210,8 +219,7 @@ def rebuild_image_with_sepolicy(target_files_dir): If odm is present then odm is preferred -- otherwise vendor is used. """ partition = 'vendor' - if os.path.exists(os.path.join(target_files_dir, 'ODM')) or os.path.exists( - os.path.join(target_files_dir, 'IMAGES/odm.img')): + if os.path.exists(os.path.join(target_files_dir, 'ODM')): partition = 'odm' partition_img = '{}.img'.format(partition) partition_map = '{}.map'.format(partition) @@ -245,7 +253,8 @@ def rebuild_image_with_sepolicy(target_files_dir): if not OPTIONS.vendor_otatools: # Remove the partition from the merged target-files archive. It will be # rebuilt later automatically by generate_missing_images(). - os.remove(os.path.join(target_files_dir, 'IMAGES', partition_img)) + remove_file_if_exists( + os.path.join(target_files_dir, 'IMAGES', partition_img)) return # TODO(b/192253131): Remove the need for vendor_otatools by fixing @@ -274,7 +283,8 @@ def rebuild_image_with_sepolicy(target_files_dir): symlinks=True) # Delete then rebuild the partition. - os.remove(os.path.join(vendor_target_files_dir, 'IMAGES', partition_img)) + remove_file_if_exists( + os.path.join(vendor_target_files_dir, 'IMAGES', partition_img)) rebuild_partition_command = [ os.path.join(vendor_otatools_dir, 'bin', 'add_img_to_target_files'), '--verbose', diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index d6c39c6812..78c1c2f653 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -727,30 +727,34 @@ def GetTargetFilesZipForCustomImagesUpdates(input_file, custom_images): Returns: The filename of a target-files.zip which has renamed the custom images in - the IMAGS/ to their partition names. + the IMAGES/ to their partition names. """ - # Use zip2zip to avoid extracting the zipfile. + + # First pass: use zip2zip to copy the target files contents, excluding + # the "custom" images that will be replaced. target_file = common.MakeTempFile(prefix="targetfiles-", suffix=".zip") cmd = ['zip2zip', '-i', input_file, '-o', target_file] - with zipfile.ZipFile(input_file, allowZip64=True) as input_zip: - namelist = input_zip.namelist() - - # Write {custom_image}.img as {custom_partition}.img. + images = {} for custom_partition, custom_image in custom_images.items(): default_custom_image = '{}.img'.format(custom_partition) if default_custom_image != custom_image: - logger.info("Update custom partition '%s' with '%s'", - custom_partition, custom_image) - # Default custom image need to be deleted first. - namelist.remove('IMAGES/{}'.format(default_custom_image)) - # IMAGES/{custom_image}.img:IMAGES/{custom_partition}.img. - cmd.extend(['IMAGES/{}:IMAGES/{}'.format(custom_image, - default_custom_image)]) - - cmd.extend(['{}:{}'.format(name, name) for name in namelist]) + src = 'IMAGES/' + custom_image + dst = 'IMAGES/' + default_custom_image + cmd.extend(['-x', dst]) + images[dst] = src + common.RunAndCheckOutput(cmd) + # Second pass: write {custom_image}.img as {custom_partition}.img. + with zipfile.ZipFile(input_file, allowZip64=True) as input_zip: + with zipfile.ZipFile(target_file, 'a', allowZip64=True) as output_zip: + for dst, src in images.items(): + data = input_zip.read(src) + logger.info("Update custom partition '%s'", dst) + common.ZipWriteStr(output_zip, dst, data) + output_zip.close() + return target_file @@ -1341,6 +1345,14 @@ def main(argv): source_spl = source_build_prop.GetProp(SECURITY_PATCH_LEVEL_PROP_NAME) target_spl = target_build_prop.GetProp(SECURITY_PATCH_LEVEL_PROP_NAME) is_spl_downgrade = target_spl < source_spl + if is_spl_downgrade and target_build_prop.GetProp("ro.build.tags") == "release-keys": + raise common.ExternalError( + "Target security patch level {} is older than source SPL {} " + "A locked bootloader will reject SPL downgrade no matter " + "what(even if data wipe is done), so SPL downgrade on any " + "release-keys build is not allowed.".format(target_spl, source_spl)) + + logger.info("SPL downgrade on %s", target_build_prop.GetProp("ro.build.tags")) if is_spl_downgrade and not OPTIONS.spl_downgrade and not OPTIONS.downgrade: raise common.ExternalError( "Target security patch level {} is older than source SPL {} applying " |