Loading tools/releasetools/add_img_to_target_files.py +15 −16 Original line number Original line Diff line number Diff line Loading @@ -636,19 +636,22 @@ def AddImagesToTargetFiles(filename): """ """ if os.path.isdir(filename): if os.path.isdir(filename): OPTIONS.input_tmp = os.path.abspath(filename) OPTIONS.input_tmp = os.path.abspath(filename) input_zip = None else: else: OPTIONS.input_tmp, input_zip = common.UnzipTemp(filename) OPTIONS.input_tmp = common.UnzipTemp(filename) if not OPTIONS.add_missing: if not OPTIONS.add_missing: if os.path.isdir(os.path.join(OPTIONS.input_tmp, "IMAGES")): if os.path.isdir(os.path.join(OPTIONS.input_tmp, "IMAGES")): print("target_files appears to already contain images.") print("target_files appears to already contain images.") sys.exit(1) sys.exit(1) # {vendor,product}.img is unlike system.img or system_other.img. Because it could OPTIONS.info_dict = common.LoadInfoDict(OPTIONS.input_tmp, OPTIONS.input_tmp) # be built from source, or dropped into target_files.zip as a prebuilt blob. # We consider either of them as {vendor,product}.img being available, which could has_recovery = OPTIONS.info_dict.get("no_recovery") != "true" # be used when generating vbmeta.img for AVB. # {vendor,product}.img is unlike system.img or system_other.img. Because it # could be built from source, or dropped into target_files.zip as a prebuilt # blob. We consider either of them as {vendor,product}.img being available, # which could be used when generating vbmeta.img for AVB. has_vendor = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR")) or has_vendor = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR")) or os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", "vendor.img"))) "vendor.img"))) Loading @@ -658,16 +661,14 @@ def AddImagesToTargetFiles(filename): has_system_other = os.path.isdir(os.path.join(OPTIONS.input_tmp, has_system_other = os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM_OTHER")) "SYSTEM_OTHER")) if input_zip: # Set up the output destination. It writes to the given directory for dir OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.input_tmp) # mode; otherwise appends to the given ZIP. if os.path.isdir(filename): common.ZipClose(input_zip) output_zip = None else: output_zip = zipfile.ZipFile(filename, "a", output_zip = zipfile.ZipFile(filename, "a", compression=zipfile.ZIP_DEFLATED, compression=zipfile.ZIP_DEFLATED, allowZip64=True) allowZip64=True) else: OPTIONS.info_dict = common.LoadInfoDict(filename, filename) output_zip = None # Always make input_tmp/IMAGES available, since we may stage boot / recovery # Always make input_tmp/IMAGES available, since we may stage boot / recovery # images there even under zip mode. The directory will be cleaned up as part # images there even under zip mode. The directory will be cleaned up as part Loading @@ -676,8 +677,6 @@ def AddImagesToTargetFiles(filename): if not os.path.isdir(images_dir): if not os.path.isdir(images_dir): os.makedirs(images_dir) os.makedirs(images_dir) has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true") # A map between partition names and their paths, which could be used when # A map between partition names and their paths, which could be used when # generating AVB vbmeta image. # generating AVB vbmeta image. partitions = dict() partitions = dict() Loading tools/releasetools/check_target_files_signatures.py +1 −3 Original line number Original line Diff line number Diff line Loading @@ -248,7 +248,7 @@ class TargetFiles(object): if compressed_extension: if compressed_extension: apk_extensions.append("*.apk" + compressed_extension) apk_extensions.append("*.apk" + compressed_extension) d, z = common.UnzipTemp(filename, apk_extensions) d = common.UnzipTemp(filename, apk_extensions) try: try: self.apks = {} self.apks = {} self.apks_by_basename = {} self.apks_by_basename = {} Loading Loading @@ -283,8 +283,6 @@ class TargetFiles(object): finally: finally: shutil.rmtree(d) shutil.rmtree(d) z.close() def CheckSharedUids(self): def CheckSharedUids(self): """Look for any instances where packages signed with different """Look for any instances where packages signed with different certs request the same sharedUserId.""" certs request the same sharedUserId.""" Loading tools/releasetools/common.py +2 −3 Original line number Original line Diff line number Diff line Loading @@ -584,8 +584,7 @@ def UnzipTemp(filename, pattern=None): then unzip bar.zip into that_dir/BOOTABLE_IMAGES. then unzip bar.zip into that_dir/BOOTABLE_IMAGES. Returns: Returns: (tempdir, zipobj): tempdir is the name of the temprary directory; zipobj is The name of the temporary directory. a zipfile.ZipFile (of the main file), open for reading. """ """ def unzip_to_dir(filename, dirname): def unzip_to_dir(filename, dirname): Loading @@ -607,7 +606,7 @@ def UnzipTemp(filename, pattern=None): else: else: unzip_to_dir(filename, tmp) unzip_to_dir(filename, tmp) return tmp, zipfile.ZipFile(filename, "r") return tmp def GetSparseImage(which, tmpdir, input_zip, allow_shared_blocks): def GetSparseImage(which, tmpdir, input_zip, allow_shared_blocks): Loading tools/releasetools/img_from_target_files.py +1 −2 Original line number Original line Diff line number Diff line Loading @@ -71,8 +71,7 @@ def main(argv): common.Usage(__doc__) common.Usage(__doc__) sys.exit(1) sys.exit(1) OPTIONS.input_tmp, input_zip = common.UnzipTemp( OPTIONS.input_tmp = common.UnzipTemp(args[0], ["IMAGES/*", "OTA/*"]) args[0], ["IMAGES/*", "OTA/*"]) output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED) output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED) CopyInfo(output_zip) CopyInfo(output_zip) Loading tools/releasetools/ota_from_target_files.py +13 −13 Original line number Original line Diff line number Diff line Loading @@ -1248,8 +1248,11 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): target_file = common.MakeTempFile(prefix="targetfiles-", suffix=".zip") target_file = common.MakeTempFile(prefix="targetfiles-", suffix=".zip") target_zip = zipfile.ZipFile(target_file, 'w', allowZip64=True) target_zip = zipfile.ZipFile(target_file, 'w', allowZip64=True) input_tmp, input_zip = common.UnzipTemp(input_file, UNZIP_PATTERN) input_tmp = common.UnzipTemp(input_file, UNZIP_PATTERN) for info in input_zip.infolist(): with zipfile.ZipFile(input_file, 'r') as input_zip: infolist = input_zip.infolist() for info in infolist: unzipped_file = os.path.join(input_tmp, *info.filename.split('/')) unzipped_file = os.path.join(input_tmp, *info.filename.split('/')) if info.filename == 'IMAGES/system_other.img': if info.filename == 'IMAGES/system_other.img': common.ZipWrite(target_zip, unzipped_file, arcname='IMAGES/system.img') common.ZipWrite(target_zip, unzipped_file, arcname='IMAGES/system.img') Loading @@ -1266,7 +1269,6 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): elif info.filename.startswith(('META/', 'IMAGES/')): elif info.filename.startswith(('META/', 'IMAGES/')): common.ZipWrite(target_zip, unzipped_file, arcname=info.filename) common.ZipWrite(target_zip, unzipped_file, arcname=info.filename) common.ZipClose(input_zip) common.ZipClose(target_zip) common.ZipClose(target_zip) return target_file return target_file Loading Loading @@ -1643,11 +1645,9 @@ def main(argv): if OPTIONS.extracted_input is not None: if OPTIONS.extracted_input is not None: OPTIONS.input_tmp = OPTIONS.extracted_input OPTIONS.input_tmp = OPTIONS.extracted_input input_zip = zipfile.ZipFile(args[0], "r") else: else: print("unzipping target target-files...") print("unzipping target target-files...") OPTIONS.input_tmp, input_zip = common.UnzipTemp( OPTIONS.input_tmp = common.UnzipTemp(args[0], UNZIP_PATTERN) args[0], UNZIP_PATTERN) OPTIONS.target_tmp = OPTIONS.input_tmp OPTIONS.target_tmp = OPTIONS.input_tmp # If the caller explicitly specified the device-specific extensions path via # If the caller explicitly specified the device-specific extensions path via Loading Loading @@ -1679,15 +1679,16 @@ def main(argv): # Generate a full OTA. # Generate a full OTA. if OPTIONS.incremental_source is None: if OPTIONS.incremental_source is None: with zipfile.ZipFile(args[0], 'r') as input_zip: WriteFullOTAPackage(input_zip, output_zip) WriteFullOTAPackage(input_zip, output_zip) # Generate an incremental OTA. # Generate an incremental OTA. else: else: print("unzipping source target-files...") print("unzipping source target-files...") OPTIONS.source_tmp, source_zip = common.UnzipTemp( OPTIONS.source_tmp = common.UnzipTemp( OPTIONS.incremental_source, OPTIONS.incremental_source, UNZIP_PATTERN) UNZIP_PATTERN) with zipfile.ZipFile(args[0], 'r') as input_zip, \ zipfile.ZipFile(OPTIONS.incremental_source, 'r') as source_zip: WriteBlockIncrementalOTAPackage(input_zip, source_zip, output_zip) WriteBlockIncrementalOTAPackage(input_zip, source_zip, output_zip) if OPTIONS.log_diff: if OPTIONS.log_diff: Loading @@ -1696,7 +1697,6 @@ def main(argv): target_files_diff.recursiveDiff( target_files_diff.recursiveDiff( '', OPTIONS.source_tmp, OPTIONS.input_tmp, out_file) '', OPTIONS.source_tmp, OPTIONS.input_tmp, out_file) common.ZipClose(input_zip) common.ZipClose(output_zip) common.ZipClose(output_zip) # Sign the generated zip package unless no_signing is specified. # Sign the generated zip package unless no_signing is specified. Loading Loading
tools/releasetools/add_img_to_target_files.py +15 −16 Original line number Original line Diff line number Diff line Loading @@ -636,19 +636,22 @@ def AddImagesToTargetFiles(filename): """ """ if os.path.isdir(filename): if os.path.isdir(filename): OPTIONS.input_tmp = os.path.abspath(filename) OPTIONS.input_tmp = os.path.abspath(filename) input_zip = None else: else: OPTIONS.input_tmp, input_zip = common.UnzipTemp(filename) OPTIONS.input_tmp = common.UnzipTemp(filename) if not OPTIONS.add_missing: if not OPTIONS.add_missing: if os.path.isdir(os.path.join(OPTIONS.input_tmp, "IMAGES")): if os.path.isdir(os.path.join(OPTIONS.input_tmp, "IMAGES")): print("target_files appears to already contain images.") print("target_files appears to already contain images.") sys.exit(1) sys.exit(1) # {vendor,product}.img is unlike system.img or system_other.img. Because it could OPTIONS.info_dict = common.LoadInfoDict(OPTIONS.input_tmp, OPTIONS.input_tmp) # be built from source, or dropped into target_files.zip as a prebuilt blob. # We consider either of them as {vendor,product}.img being available, which could has_recovery = OPTIONS.info_dict.get("no_recovery") != "true" # be used when generating vbmeta.img for AVB. # {vendor,product}.img is unlike system.img or system_other.img. Because it # could be built from source, or dropped into target_files.zip as a prebuilt # blob. We consider either of them as {vendor,product}.img being available, # which could be used when generating vbmeta.img for AVB. has_vendor = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR")) or has_vendor = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR")) or os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", "vendor.img"))) "vendor.img"))) Loading @@ -658,16 +661,14 @@ def AddImagesToTargetFiles(filename): has_system_other = os.path.isdir(os.path.join(OPTIONS.input_tmp, has_system_other = os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM_OTHER")) "SYSTEM_OTHER")) if input_zip: # Set up the output destination. It writes to the given directory for dir OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.input_tmp) # mode; otherwise appends to the given ZIP. if os.path.isdir(filename): common.ZipClose(input_zip) output_zip = None else: output_zip = zipfile.ZipFile(filename, "a", output_zip = zipfile.ZipFile(filename, "a", compression=zipfile.ZIP_DEFLATED, compression=zipfile.ZIP_DEFLATED, allowZip64=True) allowZip64=True) else: OPTIONS.info_dict = common.LoadInfoDict(filename, filename) output_zip = None # Always make input_tmp/IMAGES available, since we may stage boot / recovery # Always make input_tmp/IMAGES available, since we may stage boot / recovery # images there even under zip mode. The directory will be cleaned up as part # images there even under zip mode. The directory will be cleaned up as part Loading @@ -676,8 +677,6 @@ def AddImagesToTargetFiles(filename): if not os.path.isdir(images_dir): if not os.path.isdir(images_dir): os.makedirs(images_dir) os.makedirs(images_dir) has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true") # A map between partition names and their paths, which could be used when # A map between partition names and their paths, which could be used when # generating AVB vbmeta image. # generating AVB vbmeta image. partitions = dict() partitions = dict() Loading
tools/releasetools/check_target_files_signatures.py +1 −3 Original line number Original line Diff line number Diff line Loading @@ -248,7 +248,7 @@ class TargetFiles(object): if compressed_extension: if compressed_extension: apk_extensions.append("*.apk" + compressed_extension) apk_extensions.append("*.apk" + compressed_extension) d, z = common.UnzipTemp(filename, apk_extensions) d = common.UnzipTemp(filename, apk_extensions) try: try: self.apks = {} self.apks = {} self.apks_by_basename = {} self.apks_by_basename = {} Loading Loading @@ -283,8 +283,6 @@ class TargetFiles(object): finally: finally: shutil.rmtree(d) shutil.rmtree(d) z.close() def CheckSharedUids(self): def CheckSharedUids(self): """Look for any instances where packages signed with different """Look for any instances where packages signed with different certs request the same sharedUserId.""" certs request the same sharedUserId.""" Loading
tools/releasetools/common.py +2 −3 Original line number Original line Diff line number Diff line Loading @@ -584,8 +584,7 @@ def UnzipTemp(filename, pattern=None): then unzip bar.zip into that_dir/BOOTABLE_IMAGES. then unzip bar.zip into that_dir/BOOTABLE_IMAGES. Returns: Returns: (tempdir, zipobj): tempdir is the name of the temprary directory; zipobj is The name of the temporary directory. a zipfile.ZipFile (of the main file), open for reading. """ """ def unzip_to_dir(filename, dirname): def unzip_to_dir(filename, dirname): Loading @@ -607,7 +606,7 @@ def UnzipTemp(filename, pattern=None): else: else: unzip_to_dir(filename, tmp) unzip_to_dir(filename, tmp) return tmp, zipfile.ZipFile(filename, "r") return tmp def GetSparseImage(which, tmpdir, input_zip, allow_shared_blocks): def GetSparseImage(which, tmpdir, input_zip, allow_shared_blocks): Loading
tools/releasetools/img_from_target_files.py +1 −2 Original line number Original line Diff line number Diff line Loading @@ -71,8 +71,7 @@ def main(argv): common.Usage(__doc__) common.Usage(__doc__) sys.exit(1) sys.exit(1) OPTIONS.input_tmp, input_zip = common.UnzipTemp( OPTIONS.input_tmp = common.UnzipTemp(args[0], ["IMAGES/*", "OTA/*"]) args[0], ["IMAGES/*", "OTA/*"]) output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED) output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED) CopyInfo(output_zip) CopyInfo(output_zip) Loading
tools/releasetools/ota_from_target_files.py +13 −13 Original line number Original line Diff line number Diff line Loading @@ -1248,8 +1248,11 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): target_file = common.MakeTempFile(prefix="targetfiles-", suffix=".zip") target_file = common.MakeTempFile(prefix="targetfiles-", suffix=".zip") target_zip = zipfile.ZipFile(target_file, 'w', allowZip64=True) target_zip = zipfile.ZipFile(target_file, 'w', allowZip64=True) input_tmp, input_zip = common.UnzipTemp(input_file, UNZIP_PATTERN) input_tmp = common.UnzipTemp(input_file, UNZIP_PATTERN) for info in input_zip.infolist(): with zipfile.ZipFile(input_file, 'r') as input_zip: infolist = input_zip.infolist() for info in infolist: unzipped_file = os.path.join(input_tmp, *info.filename.split('/')) unzipped_file = os.path.join(input_tmp, *info.filename.split('/')) if info.filename == 'IMAGES/system_other.img': if info.filename == 'IMAGES/system_other.img': common.ZipWrite(target_zip, unzipped_file, arcname='IMAGES/system.img') common.ZipWrite(target_zip, unzipped_file, arcname='IMAGES/system.img') Loading @@ -1266,7 +1269,6 @@ def GetTargetFilesZipForSecondaryImages(input_file, skip_postinstall=False): elif info.filename.startswith(('META/', 'IMAGES/')): elif info.filename.startswith(('META/', 'IMAGES/')): common.ZipWrite(target_zip, unzipped_file, arcname=info.filename) common.ZipWrite(target_zip, unzipped_file, arcname=info.filename) common.ZipClose(input_zip) common.ZipClose(target_zip) common.ZipClose(target_zip) return target_file return target_file Loading Loading @@ -1643,11 +1645,9 @@ def main(argv): if OPTIONS.extracted_input is not None: if OPTIONS.extracted_input is not None: OPTIONS.input_tmp = OPTIONS.extracted_input OPTIONS.input_tmp = OPTIONS.extracted_input input_zip = zipfile.ZipFile(args[0], "r") else: else: print("unzipping target target-files...") print("unzipping target target-files...") OPTIONS.input_tmp, input_zip = common.UnzipTemp( OPTIONS.input_tmp = common.UnzipTemp(args[0], UNZIP_PATTERN) args[0], UNZIP_PATTERN) OPTIONS.target_tmp = OPTIONS.input_tmp OPTIONS.target_tmp = OPTIONS.input_tmp # If the caller explicitly specified the device-specific extensions path via # If the caller explicitly specified the device-specific extensions path via Loading Loading @@ -1679,15 +1679,16 @@ def main(argv): # Generate a full OTA. # Generate a full OTA. if OPTIONS.incremental_source is None: if OPTIONS.incremental_source is None: with zipfile.ZipFile(args[0], 'r') as input_zip: WriteFullOTAPackage(input_zip, output_zip) WriteFullOTAPackage(input_zip, output_zip) # Generate an incremental OTA. # Generate an incremental OTA. else: else: print("unzipping source target-files...") print("unzipping source target-files...") OPTIONS.source_tmp, source_zip = common.UnzipTemp( OPTIONS.source_tmp = common.UnzipTemp( OPTIONS.incremental_source, OPTIONS.incremental_source, UNZIP_PATTERN) UNZIP_PATTERN) with zipfile.ZipFile(args[0], 'r') as input_zip, \ zipfile.ZipFile(OPTIONS.incremental_source, 'r') as source_zip: WriteBlockIncrementalOTAPackage(input_zip, source_zip, output_zip) WriteBlockIncrementalOTAPackage(input_zip, source_zip, output_zip) if OPTIONS.log_diff: if OPTIONS.log_diff: Loading @@ -1696,7 +1697,6 @@ def main(argv): target_files_diff.recursiveDiff( target_files_diff.recursiveDiff( '', OPTIONS.source_tmp, OPTIONS.input_tmp, out_file) '', OPTIONS.source_tmp, OPTIONS.input_tmp, out_file) common.ZipClose(input_zip) common.ZipClose(output_zip) common.ZipClose(output_zip) # Sign the generated zip package unless no_signing is specified. # Sign the generated zip package unless no_signing is specified. Loading