From e7d0377f4af826fbc8f98864a01da835112e2f8c Mon Sep 17 00:00:00 2001 From: Tianjie Date: Wed, 14 Jul 2021 15:56:37 -0700 Subject: [PATCH 1/2] Write the vbmeta digest to the output zipfile also During signing, we write the entry directly to the output zip, intead of a temp directory. Add the logic to write vbmeta_digest.txt to output zipfile too. So the digest file will show up in the signed target files. Bug: 189926233 Test: add_img_to_target_files -a Change-Id: Ibf28a8f97512bda8c8c695e06190e1fb6573c53e (cherry picked from commit c3bf3d00a3077b66aa178f00fb789d34a042c9e8) --- tools/releasetools/add_img_to_target_files.py | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index c583d013b3..babfc7dcad 100644 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -704,6 +704,31 @@ def AddApexInfo(output_zip): common.ZipWrite(output_zip, output_file, arc_name) +def AddVbmetaDigest(output_zip): + """Write the vbmeta digest to the output dir and zipfile.""" + + # Calculate the vbmeta digest and put the result in to META/ + boot_images = OPTIONS.info_dict.get("boot_images") + # Disable the digest calculation if the target_file is used as a container + # for boot images. + boot_container = boot_images and len(boot_images.split()) >= 2 + if (OPTIONS.info_dict.get("avb_enable") == "true" and not boot_container and + OPTIONS.info_dict.get("avb_building_vbmeta_image") == "true"): + avbtool = OPTIONS.info_dict["avb_avbtool"] + digest = verity_utils.CalculateVbmetaDigest(OPTIONS.input_tmp, avbtool) + vbmeta_digest_txt = os.path.join(OPTIONS.input_tmp, "META", + "vbmeta_digest.txt") + with open(vbmeta_digest_txt, 'w') as f: + f.write(digest) + # writes to the output zipfile + if output_zip: + arc_name = "META/vbmeta_digest.txt" + if arc_name in output_zip.namelist(): + OPTIONS.replace_updated_files_list.append(arc_name) + else: + common.ZipWriteStr(output_zip, arc_name, digest) + + def AddImagesToTargetFiles(filename): """Creates and adds images (boot/recovery/system/...) to a target_files.zip. @@ -957,19 +982,7 @@ def AddImagesToTargetFiles(filename): with open(pack_radioimages_txt) as f: AddPackRadioImages(output_zip, f.readlines()) - # Calculate the vbmeta digest and put the result in to META/ - boot_images = OPTIONS.info_dict.get("boot_images") - # Disable the digest calculation if the target_file is used as a container - # for boot images. - boot_container = boot_images and len(boot_images.split()) >= 2 - if (OPTIONS.info_dict.get("avb_enable") == "true" and not boot_container and - OPTIONS.info_dict.get("avb_building_vbmeta_image") == "true"): - avbtool = OPTIONS.info_dict["avb_avbtool"] - digest = verity_utils.CalculateVbmetaDigest(OPTIONS.input_tmp, avbtool) - vbmeta_digest_txt = os.path.join(OPTIONS.input_tmp, "META", - "vbmeta_digest.txt") - with open(vbmeta_digest_txt, 'w') as f: - f.write(digest) + AddVbmetaDigest(output_zip) if output_zip: common.ZipClose(output_zip) From 2d6bfdb30cbf996953c7872877dca3a828a91b70 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Thu, 15 Jul 2021 16:14:17 +0100 Subject: [PATCH 2/2] Fix typo in MODULE_BUILD_FROM_SOURCE variable. Test: env MODULE_BUILD_FROM_SOURCE=true \ TARGET_PRODUCT=cf_x86_64_phone build/soong/soong_ui.bash \ --dumpvar-mode SOONG_CONFIG_art_module_source_build returns true Test: env TARGET_PRODUCT=cf_x86_64_phone build/soong/soong_ui.bash \ --dumpvar-mode SOONG_CONFIG_art_module_source_build returns false Bug: 191978129 Change-Id: I2056b198bc0b944a6736ff21077b902df13c1479 --- core/android_soong_config_vars.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index 69e4679466..9673c45c85 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -41,7 +41,7 @@ else ifeq (,$(filter-out modules_% mainline_modules_%,$(TARGET_PRODUCT))) # Always build from source for the module targets. This ought to be covered by # the TARGET_BUILD_APPS check above, but there are test builds that don't set it. SOONG_CONFIG_art_module_source_build := true -else ifdef MODULES_BUILD_FROM_SOURCE +else ifdef MODULE_BUILD_FROM_SOURCE # Build from source if other Mainline modules are. SOONG_CONFIG_art_module_source_build := true else ifneq (,$(filter true,$(NATIVE_COVERAGE) $(CLANG_COVERAGE)))