Remove the obsolete logic in img_from_target_files.py.
img_from_target_files.py used to handle the case that a given TF.zip not containing the image entries under IMAGES/. That is only the case for pre-Lollipop releases. Also unzip the needed files only since we know that for sure now. Test: img_from_target_files.py with an existing bullhead-TF.zip gives the same bullhead-img.zip. Change-Id: I892379ba388df80ae63be9d3ce647fbb77fd4753
This commit is contained in:
parent
fe7aeb1de7
commit
2bb109709a
1 changed files with 12 additions and 52 deletions
|
@ -71,63 +71,23 @@ def main(argv):
|
|||
common.Usage(__doc__)
|
||||
sys.exit(1)
|
||||
|
||||
OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0])
|
||||
OPTIONS.input_tmp, input_zip = common.UnzipTemp(
|
||||
args[0], ["IMAGES/*", "OTA/*"])
|
||||
output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED)
|
||||
CopyInfo(output_zip)
|
||||
|
||||
try:
|
||||
done = False
|
||||
images_path = os.path.join(OPTIONS.input_tmp, "IMAGES")
|
||||
if os.path.exists(images_path):
|
||||
# If this is a new target-files, it already contains the images,
|
||||
# and all we have to do is copy them to the output zip.
|
||||
images = os.listdir(images_path)
|
||||
if images:
|
||||
for image in images:
|
||||
if bootable_only and image not in ("boot.img", "recovery.img"):
|
||||
continue
|
||||
if not image.endswith(".img"):
|
||||
continue
|
||||
if image == "recovery-two-step.img":
|
||||
continue
|
||||
common.ZipWrite(
|
||||
output_zip, os.path.join(images_path, image), image)
|
||||
done = True
|
||||
|
||||
if not done:
|
||||
# We have an old target-files that doesn't already contain the
|
||||
# images, so build them.
|
||||
import add_img_to_target_files
|
||||
|
||||
OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.input_tmp)
|
||||
|
||||
boot_image = common.GetBootableImage(
|
||||
"boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
|
||||
if boot_image:
|
||||
boot_image.AddToZip(output_zip)
|
||||
|
||||
if OPTIONS.info_dict.get("no_recovery") != "true":
|
||||
recovery_image = common.GetBootableImage(
|
||||
"recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
|
||||
if recovery_image:
|
||||
recovery_image.AddToZip(output_zip)
|
||||
|
||||
def banner(s):
|
||||
print("\n\n++++ " + s + " ++++\n\n")
|
||||
|
||||
if not bootable_only:
|
||||
banner("AddSystem")
|
||||
add_img_to_target_files.AddSystem(output_zip, prefix="")
|
||||
try:
|
||||
input_zip.getinfo("VENDOR/")
|
||||
banner("AddVendor")
|
||||
add_img_to_target_files.AddVendor(output_zip, prefix="")
|
||||
except KeyError:
|
||||
pass # no vendor partition for this device
|
||||
banner("AddUserdata")
|
||||
add_img_to_target_files.AddUserdata(output_zip, prefix="")
|
||||
banner("AddCache")
|
||||
add_img_to_target_files.AddCache(output_zip, prefix="")
|
||||
# A target-files zip must contain the images since Lollipop.
|
||||
assert os.path.exists(images_path)
|
||||
for image in sorted(os.listdir(images_path)):
|
||||
if bootable_only and image not in ("boot.img", "recovery.img"):
|
||||
continue
|
||||
if not image.endswith(".img"):
|
||||
continue
|
||||
if image == "recovery-two-step.img":
|
||||
continue
|
||||
common.ZipWrite(output_zip, os.path.join(images_path, image), image)
|
||||
|
||||
finally:
|
||||
print("cleaning up...")
|
||||
|
|
Loading…
Reference in a new issue