From f040245dd2d53b48f4a159f563164fa304cd63d2 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sun, 28 Jan 2024 11:08:16 +0100 Subject: [PATCH] releasetools: Fix fstab path detection when input_file is a path to zip If _FindAndLoadRecoveryFstab() is called with a path to target files zip file, then it'll always attempt to read the fallback recovery.fstab path. By making sure to pass zipfile.ZipFile(), it'll be able to read the zip file ToC and use the correct path instead. Test: Generate signed ota package for gts4lv Change-Id: I4f3b975c677b7928999d0fe4fb137c868d7a206e Signed-off-by: RITEFANG <1721985272@qq.com> --- tools/releasetools/common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 898d1f13c3..12520ff10d 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -965,7 +965,11 @@ def LoadInfoDict(input_file, repacking=False): makeint(b.replace(".img", "_size")) # Load recovery fstab if applicable. - d["fstab"] = _FindAndLoadRecoveryFstab(d, input_file, read_helper) + if isinstance(input_file, str) and zipfile.is_zipfile(input_file): + with zipfile.ZipFile(input_file, 'r', allowZip64=True) as input_zip: + d["fstab"] = _FindAndLoadRecoveryFstab(d, input_zip, read_helper) + else: + d["fstab"] = _FindAndLoadRecoveryFstab(d, input_file, read_helper) ramdisk_format = GetRamdiskFormat(d) # Tries to load the build props for all partitions with care_map, including