From 8d4b72405e691eec0fc216553893e1341d052d8b Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Tue, 4 Jan 2022 15:15:35 +0800 Subject: [PATCH] Fix the signing error on no-system-image targets Currently when running sign_target_files_apks on a no-system-image target, it will raise the following error: ValueError: max() arg is an empty sequence This is because there is no APK files in the target_files.zip. Fixing this by setting maxsize to zero in this case. Bug: 213028932 Test: lunch gki_arm64-userdebug; make dist Test: sign_target_files_apks \ --gki_signing_key=external/avb/test/data/testkey_rsa4096.pem \ --gki_signing_algorithm=SHA256_RSA4096 \ --gki_signing_extra_args="--prop gki:prop1 --prop gki:prop2" \ ./out/dist/*-target_files-eng.*.zip signed.zip Change-Id: I40daecbc2ff3f89d3e635d1a4a1c1dea31ba9a27 --- tools/releasetools/sign_target_files_apks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py index 3f65df1691..d7dda8a8f8 100755 --- a/tools/releasetools/sign_target_files_apks.py +++ b/tools/releasetools/sign_target_files_apks.py @@ -520,9 +520,14 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info, compressed_extension): # maxsize measures the maximum filename length, including the ones to be # skipped. - maxsize = max( - [len(os.path.basename(i.filename)) for i in input_tf_zip.infolist() - if GetApkFileInfo(i.filename, compressed_extension, [])[0]]) + try: + maxsize = max( + [len(os.path.basename(i.filename)) for i in input_tf_zip.infolist() + if GetApkFileInfo(i.filename, compressed_extension, [])[0]]) + except ValueError: + # Sets this to zero for targets without APK files, e.g., gki_arm64. + maxsize = 0 + system_root_image = misc_info.get("system_root_image") == "true" for info in input_tf_zip.infolist():