Loading tools/releasetools/add_img_to_target_files.py +21 −19 Original line number Original line Diff line number Diff line Loading @@ -43,10 +43,12 @@ Usage: add_img_to_target_files [flag] target_files are signing the target files. are signing the target files. """ """ from __future__ import print_function import sys import sys if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." print("Python 2.7 or newer is required.", file=sys.stderr) sys.exit(1) sys.exit(1) import datetime import datetime Loading Loading @@ -89,7 +91,7 @@ def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "system.img already exists in %s, no need to rebuild..." % (prefix,) print("system.img already exists in %s, no need to rebuild..." % (prefix,)) return prebuilt_path return prebuilt_path def output_sink(fn, data): def output_sink(fn, data): Loading @@ -98,7 +100,7 @@ def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None): ofile.close() ofile.close() if OPTIONS.rebuild_recovery: if OPTIONS.rebuild_recovery: print "Building new recovery patch" print("Building new recovery patch") common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink, recovery_img, common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink, recovery_img, boot_img, info_dict=OPTIONS.info_dict) boot_img, info_dict=OPTIONS.info_dict) Loading @@ -123,7 +125,8 @@ def AddSystemOther(output_zip, prefix="IMAGES/"): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system_other.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system_other.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "system_other.img already exists in %s, no need to rebuild..." % (prefix,) print("system_other.img already exists in %s, no need to rebuild..." % ( prefix,)) return return imgname = BuildSystemOther(OPTIONS.input_tmp, OPTIONS.info_dict) imgname = BuildSystemOther(OPTIONS.input_tmp, OPTIONS.info_dict) Loading @@ -141,7 +144,7 @@ def AddVendor(output_zip, prefix="IMAGES/"): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "vendor.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "vendor.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "vendor.img already exists in %s, no need to rebuild..." % (prefix,) print("vendor.img already exists in %s, no need to rebuild..." % (prefix,)) return prebuilt_path return prebuilt_path block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map") block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map") Loading @@ -159,7 +162,7 @@ def BuildVendor(input_dir, info_dict, block_list=None): def CreateImage(input_dir, info_dict, what, block_list=None): def CreateImage(input_dir, info_dict, what, block_list=None): print "creating " + what + ".img..." print("creating " + what + ".img...") img = common.MakeTempFile(prefix=what + "-", suffix=".img") img = common.MakeTempFile(prefix=what + "-", suffix=".img") Loading Loading @@ -223,7 +226,8 @@ def AddUserdata(output_zip, prefix="IMAGES/"): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "userdata.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "userdata.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "userdata.img already exists in %s, no need to rebuild..." % (prefix,) print("userdata.img already exists in %s, no need to rebuild..." % ( prefix,)) return return # Skip userdata.img if no size. # Skip userdata.img if no size. Loading @@ -231,7 +235,7 @@ def AddUserdata(output_zip, prefix="IMAGES/"): if not image_props.get("partition_size"): if not image_props.get("partition_size"): return return print "creating userdata.img..." print("creating userdata.img...") # Use a fixed timestamp (01/01/2009) when packaging the image. # Use a fixed timestamp (01/01/2009) when packaging the image. # Bug: 24377993 # Bug: 24377993 Loading Loading @@ -321,7 +325,7 @@ def AddCache(output_zip, prefix="IMAGES/"): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "cache.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "cache.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "cache.img already exists in %s, no need to rebuild..." % (prefix,) print("cache.img already exists in %s, no need to rebuild..." % (prefix,)) return return image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "cache") image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "cache") Loading @@ -329,7 +333,7 @@ def AddCache(output_zip, prefix="IMAGES/"): if "fs_type" not in image_props: if "fs_type" not in image_props: return return print "creating cache.img..." print("creating cache.img...") # Use a fixed timestamp (01/01/2009) when packaging the image. # Use a fixed timestamp (01/01/2009) when packaging the image. # Bug: 24377993 # Bug: 24377993 Loading Loading @@ -364,7 +368,7 @@ def AddImagesToTargetFiles(filename): if not OPTIONS.add_missing: if not OPTIONS.add_missing: for n in input_zip.namelist(): for n in input_zip.namelist(): if n.startswith("IMAGES/"): if n.startswith("IMAGES/"): print "target_files appears to already contain images." print("target_files appears to already contain images.") sys.exit(1) sys.exit(1) try: try: Loading @@ -386,13 +390,13 @@ def AddImagesToTargetFiles(filename): system_root_image = (OPTIONS.info_dict.get("system_root_image", None) == "true") system_root_image = (OPTIONS.info_dict.get("system_root_image", None) == "true") def banner(s): def banner(s): print "\n\n++++ " + s + " ++++\n\n" print("\n\n++++ " + s + " ++++\n\n") prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") boot_image = None boot_image = None if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): banner("boot") banner("boot") print "boot.img already exists in IMAGES/, no need to rebuild..." print("boot.img already exists in IMAGES/, no need to rebuild...") if OPTIONS.rebuild_recovery: if OPTIONS.rebuild_recovery: boot_image = common.GetBootableImage( boot_image = common.GetBootableImage( "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") Loading @@ -408,7 +412,7 @@ def AddImagesToTargetFiles(filename): banner("recovery") banner("recovery") prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "recovery.img already exists in IMAGES/, no need to rebuild..." print("recovery.img already exists in IMAGES/, no need to rebuild...") if OPTIONS.rebuild_recovery: if OPTIONS.rebuild_recovery: recovery_image = common.GetBootableImage( recovery_image = common.GetBootableImage( "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, Loading Loading @@ -474,7 +478,7 @@ def AddImagesToTargetFiles(filename): img_name = line.strip() + ".img" img_name = line.strip() + ".img" prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name) prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name) if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "%s already exists, no need to overwrite..." % (img_name,) print("%s already exists, no need to overwrite..." % (img_name,)) continue continue img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name) img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name) Loading Loading @@ -530,16 +534,14 @@ def main(argv): sys.exit(1) sys.exit(1) AddImagesToTargetFiles(args[0]) AddImagesToTargetFiles(args[0]) print "done." print("done.") if __name__ == '__main__': if __name__ == '__main__': try: try: common.CloseInheritedPipes() common.CloseInheritedPipes() main(sys.argv[1:]) main(sys.argv[1:]) except common.ExternalError as e: except common.ExternalError as e: print print("\n ERROR: %s\n" % (e,)) print " ERROR: %s" % (e,) print sys.exit(1) sys.exit(1) finally: finally: common.Cleanup() common.Cleanup() tools/releasetools/common.py +33 −33 Original line number Original line Diff line number Diff line Loading @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # See the License for the specific language governing permissions and # limitations under the License. # limitations under the License. from __future__ import print_function import copy import copy import errno import errno import getopt import getopt Loading Loading @@ -109,7 +111,7 @@ def Run(args, **kwargs): """Create and return a subprocess.Popen object, printing the command """Create and return a subprocess.Popen object, printing the command line on the terminal if -v was specified.""" line on the terminal if -v was specified.""" if OPTIONS.verbose: if OPTIONS.verbose: print " running: ", " ".join(args) print(" running: ", " ".join(args)) return subprocess.Popen(args, **kwargs) return subprocess.Popen(args, **kwargs) Loading Loading @@ -208,8 +210,8 @@ def LoadInfoDict(input_file, input_dir=None): if os.path.exists(system_base_fs_file): if os.path.exists(system_base_fs_file): d["system_base_fs_file"] = system_base_fs_file d["system_base_fs_file"] = system_base_fs_file else: else: print "Warning: failed to find system base fs file: %s" % ( print("Warning: failed to find system base fs file: %s" % ( system_base_fs_file,) system_base_fs_file,)) del d["system_base_fs_file"] del d["system_base_fs_file"] if "vendor_base_fs_file" in d: if "vendor_base_fs_file" in d: Loading @@ -218,8 +220,8 @@ def LoadInfoDict(input_file, input_dir=None): if os.path.exists(vendor_base_fs_file): if os.path.exists(vendor_base_fs_file): d["vendor_base_fs_file"] = vendor_base_fs_file d["vendor_base_fs_file"] = vendor_base_fs_file else: else: print "Warning: failed to find vendor base fs file: %s" % ( print("Warning: failed to find vendor base fs file: %s" % ( vendor_base_fs_file,) vendor_base_fs_file,)) del d["vendor_base_fs_file"] del d["vendor_base_fs_file"] try: try: Loading Loading @@ -270,7 +272,7 @@ def LoadBuildProp(read_helper): try: try: data = read_helper("SYSTEM/build.prop") data = read_helper("SYSTEM/build.prop") except KeyError: except KeyError: print "Warning: could not find SYSTEM/build.prop in %s" % zip print("Warning: could not find SYSTEM/build.prop in %s" % (zip,)) data = "" data = "" return LoadDictionaryFromLines(data.split("\n")) return LoadDictionaryFromLines(data.split("\n")) Loading Loading @@ -299,7 +301,7 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path, try: try: data = read_helper(recovery_fstab_path) data = read_helper(recovery_fstab_path) except KeyError: except KeyError: print "Warning: could not find {}".format(recovery_fstab_path) print("Warning: could not find {}".format(recovery_fstab_path)) data = "" data = "" if fstab_version == 1: if fstab_version == 1: Loading Loading @@ -331,7 +333,7 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path, if i.startswith("length="): if i.startswith("length="): length = int(i[7:]) length = int(i[7:]) else: else: print "%s: unknown option \"%s\"" % (mount_point, i) print("%s: unknown option \"%s\"" % (mount_point, i)) d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[1], d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[1], device=pieces[2], length=length, device=pieces[2], length=length, Loading Loading @@ -389,7 +391,7 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path, def DumpInfoDict(d): def DumpInfoDict(d): for k, v in sorted(d.items()): for k, v in sorted(d.items()): print "%-25s = (%s) %s" % (k, type(v).__name__, v) print("%-25s = (%s) %s" % (k, type(v).__name__, v)) def AppendAVBSigningArgs(cmd): def AppendAVBSigningArgs(cmd): Loading Loading @@ -565,15 +567,15 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, prebuilt_path = os.path.join(unpack_dir, "BOOTABLE_IMAGES", prebuilt_name) prebuilt_path = os.path.join(unpack_dir, "BOOTABLE_IMAGES", prebuilt_name) if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "using prebuilt %s from BOOTABLE_IMAGES..." % (prebuilt_name,) print("using prebuilt %s from BOOTABLE_IMAGES..." % (prebuilt_name,)) return File.FromLocalFile(name, prebuilt_path) return File.FromLocalFile(name, prebuilt_path) prebuilt_path = os.path.join(unpack_dir, "IMAGES", prebuilt_name) prebuilt_path = os.path.join(unpack_dir, "IMAGES", prebuilt_name) if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "using prebuilt %s from IMAGES..." % (prebuilt_name,) print("using prebuilt %s from IMAGES..." % (prebuilt_name,)) return File.FromLocalFile(name, prebuilt_path) return File.FromLocalFile(name, prebuilt_path) print "building image from target_files %s..." % (tree_subdir,) print("building image from target_files %s..." % (tree_subdir,)) if info_dict is None: if info_dict is None: info_dict = OPTIONS.info_dict info_dict = OPTIONS.info_dict Loading Loading @@ -792,11 +794,9 @@ def CheckSize(data, target, info_dict): if pct >= 99.0: if pct >= 99.0: raise ExternalError(msg) raise ExternalError(msg) elif pct >= 95.0: elif pct >= 95.0: print print("\n WARNING: %s\n" % (msg,)) print " WARNING: ", msg print elif OPTIONS.verbose: elif OPTIONS.verbose: print " ", msg print(" ", msg) def ReadApkCerts(tf_zip): def ReadApkCerts(tf_zip): Loading Loading @@ -845,8 +845,8 @@ COMMON_DOCSTRING = """ """ """ def Usage(docstring): def Usage(docstring): print docstring.rstrip("\n") print(docstring.rstrip("\n")) print COMMON_DOCSTRING print(COMMON_DOCSTRING) def ParseOptions(argv, def ParseOptions(argv, Loading @@ -871,7 +871,7 @@ def ParseOptions(argv, list(extra_long_opts)) list(extra_long_opts)) except getopt.GetoptError as err: except getopt.GetoptError as err: Usage(docstring) Usage(docstring) print "**", str(err), "**" print("**", str(err), "**") sys.exit(2) sys.exit(2) for o, a in opts: for o, a in opts: Loading Loading @@ -969,7 +969,7 @@ class PasswordManager(object): current[i] = "" current[i] = "" if not first: if not first: print "key file %s still missing some passwords." % (self.pwfile,) print("key file %s still missing some passwords." % (self.pwfile,)) answer = raw_input("try to edit again? [y]> ").strip() answer = raw_input("try to edit again? [y]> ").strip() if answer and answer[0] not in 'yY': if answer and answer[0] not in 'yY': raise RuntimeError("key passwords unavailable") raise RuntimeError("key passwords unavailable") Loading Loading @@ -1029,13 +1029,13 @@ class PasswordManager(object): continue continue m = re.match(r"^\[\[\[\s*(.*?)\s*\]\]\]\s*(\S+)$", line) m = re.match(r"^\[\[\[\s*(.*?)\s*\]\]\]\s*(\S+)$", line) if not m: if not m: print "failed to parse password file: ", line print("failed to parse password file: ", line) else: else: result[m.group(2)] = m.group(1) result[m.group(2)] = m.group(1) f.close() f.close() except IOError as e: except IOError as e: if e.errno != errno.ENOENT: if e.errno != errno.ENOENT: print "error reading password file: ", str(e) print("error reading password file: ", str(e)) return result return result Loading Loading @@ -1156,10 +1156,10 @@ class DeviceSpecificParams(object): if x == ".py": if x == ".py": f = b f = b info = imp.find_module(f, [d]) info = imp.find_module(f, [d]) print "loaded device-specific extensions from", path print("loaded device-specific extensions from", path) self.module = imp.load_module("device_specific", *info) self.module = imp.load_module("device_specific", *info) except ImportError: except ImportError: print "unable to load device-specific module; assuming none" print("unable to load device-specific module; assuming none") def _DoCall(self, function_name, *args, **kwargs): def _DoCall(self, function_name, *args, **kwargs): """Call the named function in the device-specific module, passing """Call the named function in the device-specific module, passing Loading Loading @@ -1294,7 +1294,7 @@ class Difference(object): th.start() th.start() th.join(timeout=300) # 5 mins th.join(timeout=300) # 5 mins if th.is_alive(): if th.is_alive(): print "WARNING: diff command timed out" print("WARNING: diff command timed out") p.terminate() p.terminate() th.join(5) th.join(5) if th.is_alive(): if th.is_alive(): Loading @@ -1302,8 +1302,8 @@ class Difference(object): th.join() th.join() if err or p.returncode != 0: if err or p.returncode != 0: print "WARNING: failure running %s:\n%s\n" % ( print("WARNING: failure running %s:\n%s\n" % ( diff_program, "".join(err)) diff_program, "".join(err))) self.patch = None self.patch = None return None, None, None return None, None, None diff = ptemp.read() diff = ptemp.read() Loading @@ -1325,7 +1325,7 @@ class Difference(object): def ComputeDifferences(diffs): def ComputeDifferences(diffs): """Call ComputePatch on all the Difference objects in 'diffs'.""" """Call ComputePatch on all the Difference objects in 'diffs'.""" print len(diffs), "diffs to compute" print(len(diffs), "diffs to compute") # Do the largest files first, to try and reduce the long-pole effect. # Do the largest files first, to try and reduce the long-pole effect. by_size = [(i.tf.size, i) for i in diffs] by_size = [(i.tf.size, i) for i in diffs] Loading @@ -1351,13 +1351,13 @@ def ComputeDifferences(diffs): else: else: name = "%s (%s)" % (tf.name, sf.name) name = "%s (%s)" % (tf.name, sf.name) if patch is None: if patch is None: print "patching failed! %s" % (name,) print("patching failed! %s" % (name,)) else: else: print "%8.2f sec %8d / %8d bytes (%6.2f%%) %s" % ( print("%8.2f sec %8d / %8d bytes (%6.2f%%) %s" % ( dur, len(patch), tf.size, 100.0 * len(patch) / tf.size, name) dur, len(patch), tf.size, 100.0 * len(patch) / tf.size, name)) lock.release() lock.release() except Exception as e: except Exception as e: print e print(e) raise raise # start worker threads; wait for them all to finish. # start worker threads; wait for them all to finish. Loading Loading @@ -1736,6 +1736,6 @@ fi if found: if found: break break print "putting script in", sh_location print("putting script in", sh_location) output_sink(sh_location, sh) output_sink(sh_location, sh) tools/releasetools/img_from_target_files.py +7 −7 Original line number Original line Diff line number Diff line Loading @@ -26,10 +26,12 @@ Usage: img_from_target_files [flags] input_target_files output_image_zip """ """ from __future__ import print_function import sys import sys if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." print("Python 2.7 or newer is required.", file=sys.stderr) sys.exit(1) sys.exit(1) import os import os Loading Loading @@ -111,7 +113,7 @@ def main(argv): recovery_image.AddToZip(output_zip) recovery_image.AddToZip(output_zip) def banner(s): def banner(s): print "\n\n++++ " + s + " ++++\n\n" print("\n\n++++ " + s + " ++++\n\n") if not bootable_only: if not bootable_only: banner("AddSystem") banner("AddSystem") Loading @@ -128,11 +130,11 @@ def main(argv): add_img_to_target_files.AddCache(output_zip, prefix="") add_img_to_target_files.AddCache(output_zip, prefix="") finally: finally: print "cleaning up..." print("cleaning up...") common.ZipClose(output_zip) common.ZipClose(output_zip) shutil.rmtree(OPTIONS.input_tmp) shutil.rmtree(OPTIONS.input_tmp) print "done." print("done.") if __name__ == '__main__': if __name__ == '__main__': Loading @@ -140,7 +142,5 @@ if __name__ == '__main__': common.CloseInheritedPipes() common.CloseInheritedPipes() main(sys.argv[1:]) main(sys.argv[1:]) except common.ExternalError as e: except common.ExternalError as e: print print("\n ERROR: %s\n" % (e,)) print " ERROR: %s" % (e,) print sys.exit(1) sys.exit(1) tools/releasetools/make_recovery_patch.py +3 −1 Original line number Original line Diff line number Diff line Loading @@ -14,10 +14,12 @@ # See the License for the specific language governing permissions and # See the License for the specific language governing permissions and # limitations under the License. # limitations under the License. from __future__ import print_function import sys import sys if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." print("Python 2.7 or newer is required.", file=sys.stderr) sys.exit(1) sys.exit(1) import os import os Loading tools/releasetools/ota_from_target_files.py +45 −45 Original line number Original line Diff line number Diff line Loading @@ -121,10 +121,12 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package Specify the arguments needed for payload signer. Specify the arguments needed for payload signer. """ """ from __future__ import print_function import sys import sys if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." print("Python 2.7 or newer is required.", file=sys.stderr) sys.exit(1) sys.exit(1) import multiprocessing import multiprocessing Loading Loading @@ -292,14 +294,14 @@ class Item(object): def Dump(self, indent=0): def Dump(self, indent=0): if self.uid is not None: if self.uid is not None: print "%s%s %d %d %o" % ( print("%s%s %d %d %o" % ( " " * indent, self.name, self.uid, self.gid, self.mode) " " * indent, self.name, self.uid, self.gid, self.mode)) else: else: print "%s%s %s %s %s" % ( print("%s%s %s %s %s" % ( " " * indent, self.name, self.uid, self.gid, self.mode) " " * indent, self.name, self.uid, self.gid, self.mode)) if self.is_dir: if self.is_dir: print "%s%s" % (" "*indent, self.descendants) print("%s%s" % (" " * indent, self.descendants)) print "%s%s" % (" "*indent, self.best_subtree) print("%s%s" % (" " * indent, self.best_subtree)) for i in self.children: for i in self.children: i.Dump(indent=indent+1) i.Dump(indent=indent+1) Loading Loading @@ -485,11 +487,11 @@ def _WriteRecoveryImageToBoot(script, output_zip): OPTIONS.input_tmp, "RECOVERY") OPTIONS.input_tmp, "RECOVERY") common.ZipWriteStr( common.ZipWriteStr( output_zip, recovery_two_step_img_name, recovery_two_step_img.data) output_zip, recovery_two_step_img_name, recovery_two_step_img.data) print "two-step package: using %s in stage 1/3" % ( print("two-step package: using %s in stage 1/3" % ( recovery_two_step_img_name,) recovery_two_step_img_name,)) script.WriteRawImage("/boot", recovery_two_step_img_name) script.WriteRawImage("/boot", recovery_two_step_img_name) else: else: print "two-step package: using recovery.img in stage 1/3" print("two-step package: using recovery.img in stage 1/3") # The "recovery.img" entry has been written into package earlier. # The "recovery.img" entry has been written into package earlier. script.WriteRawImage("/boot", "recovery.img") script.WriteRawImage("/boot", "recovery.img") Loading Loading @@ -533,11 +535,11 @@ def GetImage(which, tmpdir, info_dict): path = os.path.join(tmpdir, "IMAGES", which + ".img") path = os.path.join(tmpdir, "IMAGES", which + ".img") mappath = os.path.join(tmpdir, "IMAGES", which + ".map") mappath = os.path.join(tmpdir, "IMAGES", which + ".map") if os.path.exists(path) and os.path.exists(mappath): if os.path.exists(path) and os.path.exists(mappath): print "using %s.img from target-files" % (which,) print("using %s.img from target-files" % (which,)) # This is a 'new' target-files, which already has the image in it. # This is a 'new' target-files, which already has the image in it. else: else: print "building %s.img from target-files" % (which,) print("building %s.img from target-files" % (which,)) # This is an 'old' target-files, which does not contain images # This is an 'old' target-files, which does not contain images # already built. Build them. # already built. Build them. Loading Loading @@ -1048,8 +1050,8 @@ else if get_stage("%(bcb_dev)s") != "3/3" then else: else: include_full_boot = False include_full_boot = False print "boot target: %d source: %d diff: %d" % ( print("boot target: %d source: %d diff: %d" % ( target_boot.size, source_boot.size, len(d)) target_boot.size, source_boot.size, len(d))) common.ZipWriteStr(output_zip, "patch/boot.img.p", d) common.ZipWriteStr(output_zip, "patch/boot.img.p", d) Loading Loading @@ -1095,19 +1097,19 @@ else if OPTIONS.two_step: if OPTIONS.two_step: common.ZipWriteStr(output_zip, "boot.img", target_boot.data) common.ZipWriteStr(output_zip, "boot.img", target_boot.data) script.WriteRawImage("/boot", "boot.img") script.WriteRawImage("/boot", "boot.img") print "writing full boot image (forced by two-step mode)" print("writing full boot image (forced by two-step mode)") if not OPTIONS.two_step: if not OPTIONS.two_step: if updating_boot: if updating_boot: if include_full_boot: if include_full_boot: print "boot image changed; including full." print("boot image changed; including full.") script.Print("Installing boot image...") script.Print("Installing boot image...") script.WriteRawImage("/boot", "boot.img") script.WriteRawImage("/boot", "boot.img") else: else: # Produce the boot image by applying a patch to the current # Produce the boot image by applying a patch to the current # contents of the boot partition, and write it back to the # contents of the boot partition, and write it back to the # partition. # partition. print "boot image changed; including patch." print("boot image changed; including patch.") script.Print("Patching boot image...") script.Print("Patching boot image...") script.ShowProgress(0.1, 10) script.ShowProgress(0.1, 10) script.ApplyPatch("%s:%s:%d:%s:%d:%s" script.ApplyPatch("%s:%s:%d:%s:%d:%s" Loading @@ -1118,7 +1120,7 @@ else target_boot.size, target_boot.sha1, target_boot.size, target_boot.sha1, source_boot.sha1, "patch/boot.img.p") source_boot.sha1, "patch/boot.img.p") else: else: print "boot image unchanged; skipping." print("boot image unchanged; skipping.") # Do device-specific installation (eg, write radio image). # Do device-specific installation (eg, write radio image). device_specific.IncrementalOTA_InstallEnd() device_specific.IncrementalOTA_InstallEnd() Loading Loading @@ -1381,7 +1383,7 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file, care_map_data = target_zip.read(care_map_path) care_map_data = target_zip.read(care_map_path) common.ZipWriteStr(output_zip, "care_map.txt", care_map_data) common.ZipWriteStr(output_zip, "care_map.txt", care_map_data) else: else: print "Warning: cannot find care map file in target_file package" print("Warning: cannot find care map file in target_file package") common.ZipClose(target_zip) common.ZipClose(target_zip) # Sign the whole package to comply with the Android OTA package format. # Sign the whole package to comply with the Android OTA package format. Loading @@ -1393,9 +1395,9 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file, class FileDifference(object): class FileDifference(object): def __init__(self, partition, source_zip, target_zip, output_zip): def __init__(self, partition, source_zip, target_zip, output_zip): self.deferred_patch_list = None self.deferred_patch_list = None print "Loading target..." print("Loading target...") self.target_data = target_data = LoadPartitionFiles(target_zip, partition) self.target_data = target_data = LoadPartitionFiles(target_zip, partition) print "Loading source..." print("Loading source...") self.source_data = source_data = LoadPartitionFiles(source_zip, partition) self.source_data = source_data = LoadPartitionFiles(source_zip, partition) self.verbatim_targets = verbatim_targets = [] self.verbatim_targets = verbatim_targets = [] Loading @@ -1422,14 +1424,14 @@ class FileDifference(object): assert fn == tf.name assert fn == tf.name sf = ClosestFileMatch(tf, matching_file_cache, renames) sf = ClosestFileMatch(tf, matching_file_cache, renames) if sf is not None and sf.name != tf.name: if sf is not None and sf.name != tf.name: print "File has moved from " + sf.name + " to " + tf.name print("File has moved from " + sf.name + " to " + tf.name) renames[sf.name] = tf renames[sf.name] = tf if sf is None or fn in OPTIONS.require_verbatim: if sf is None or fn in OPTIONS.require_verbatim: # This file should be included verbatim # This file should be included verbatim if fn in OPTIONS.prohibit_verbatim: if fn in OPTIONS.prohibit_verbatim: raise common.ExternalError("\"%s\" must be sent verbatim" % (fn,)) raise common.ExternalError("\"%s\" must be sent verbatim" % (fn,)) print "send", fn, "verbatim" print("send", fn, "verbatim") tf.AddToZip(output_zip) tf.AddToZip(output_zip) verbatim_targets.append((fn, tf.size, tf.sha1)) verbatim_targets.append((fn, tf.size, tf.sha1)) if fn in target_data.keys(): if fn in target_data.keys(): Loading Loading @@ -1517,7 +1519,7 @@ class FileDifference(object): if len(self.renames) > 0: if len(self.renames) > 0: script.Print("Renaming files...") script.Print("Renaming files...") for src, tgt in self.renames.iteritems(): for src, tgt in self.renames.iteritems(): print "Renaming " + src + " to " + tgt.name print("Renaming " + src + " to " + tgt.name) script.RenameFile(src, tgt.name) script.RenameFile(src, tgt.name) Loading Loading @@ -1719,8 +1721,8 @@ else if get_stage("%(bcb_dev)s") != "3/3" then if updating_boot: if updating_boot: d = common.Difference(target_boot, source_boot) d = common.Difference(target_boot, source_boot) _, _, d = d.ComputePatch() _, _, d = d.ComputePatch() print "boot target: %d source: %d diff: %d" % ( print("boot target: %d source: %d diff: %d" % ( target_boot.size, source_boot.size, len(d)) target_boot.size, source_boot.size, len(d))) common.ZipWriteStr(output_zip, "patch/boot.img.p", d) common.ZipWriteStr(output_zip, "patch/boot.img.p", d) Loading Loading @@ -1759,7 +1761,7 @@ else if OPTIONS.two_step: if OPTIONS.two_step: common.ZipWriteStr(output_zip, "boot.img", target_boot.data) common.ZipWriteStr(output_zip, "boot.img", target_boot.data) script.WriteRawImage("/boot", "boot.img") script.WriteRawImage("/boot", "boot.img") print "writing full boot image (forced by two-step mode)" print("writing full boot image (forced by two-step mode)") script.Print("Removing unneeded files...") script.Print("Removing unneeded files...") system_diff.RemoveUnneededFiles(script, ("/system/recovery.img",)) system_diff.RemoveUnneededFiles(script, ("/system/recovery.img",)) Loading Loading @@ -1794,9 +1796,9 @@ else source_boot.sha1, "patch/boot.img.p") source_boot.sha1, "patch/boot.img.p") so_far += target_boot.size so_far += target_boot.size script.SetProgress(so_far / total_patch_size) script.SetProgress(so_far / total_patch_size) print "boot image changed; including." print("boot image changed; including.") else: else: print "boot image unchanged; skipping." print("boot image unchanged; skipping.") system_items = ItemSet("system", "META/filesystem_config.txt") system_items = ItemSet("system", "META/filesystem_config.txt") if vendor_diff: if vendor_diff: Loading @@ -1822,9 +1824,9 @@ else script.DeleteFiles(["/system/recovery-from-boot.p", script.DeleteFiles(["/system/recovery-from-boot.p", "/system/etc/recovery.img", "/system/etc/recovery.img", "/system/etc/install-recovery.sh"]) "/system/etc/install-recovery.sh"]) print "recovery image changed; including as patch from boot." print("recovery image changed; including as patch from boot.") else: else: print "recovery image unchanged; skipping." print("recovery image unchanged; skipping.") script.ShowProgress(0.1, 10) script.ShowProgress(0.1, 10) Loading Loading @@ -2087,11 +2089,11 @@ def main(argv): common.ZipClose(source_zip) common.ZipClose(source_zip) if OPTIONS.verbose: if OPTIONS.verbose: print "--- target info ---" print("--- target info ---") common.DumpInfoDict(OPTIONS.info_dict) common.DumpInfoDict(OPTIONS.info_dict) if OPTIONS.incremental_source is not None: if OPTIONS.incremental_source is not None: print "--- source info ---" print("--- source info ---") common.DumpInfoDict(OPTIONS.source_info_dict) common.DumpInfoDict(OPTIONS.source_info_dict) WriteABOTAPackageWithBrilloScript( WriteABOTAPackageWithBrilloScript( Loading @@ -2099,20 +2101,20 @@ def main(argv): output_file=args[1], output_file=args[1], source_file=OPTIONS.incremental_source) source_file=OPTIONS.incremental_source) print "done." print("done.") return return if OPTIONS.extra_script is not None: if OPTIONS.extra_script is not None: OPTIONS.extra_script = open(OPTIONS.extra_script).read() OPTIONS.extra_script = open(OPTIONS.extra_script).read() print "unzipping target target-files..." print("unzipping target target-files...") OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0]) OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0]) OPTIONS.target_tmp = OPTIONS.input_tmp OPTIONS.target_tmp = OPTIONS.input_tmp OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp) OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp) if OPTIONS.verbose: if OPTIONS.verbose: print "--- target info ---" print("--- target info ---") common.DumpInfoDict(OPTIONS.info_dict) common.DumpInfoDict(OPTIONS.info_dict) # If the caller explicitly specified the device-specific extensions # If the caller explicitly specified the device-specific extensions Loading @@ -2125,7 +2127,7 @@ def main(argv): if OPTIONS.device_specific is None: if OPTIONS.device_specific is None: from_input = os.path.join(OPTIONS.input_tmp, "META", "releasetools.py") from_input = os.path.join(OPTIONS.input_tmp, "META", "releasetools.py") if os.path.exists(from_input): if os.path.exists(from_input): print "(using device-specific extensions from target_files)" print("(using device-specific extensions from target_files)") OPTIONS.device_specific = from_input OPTIONS.device_specific = from_input else: else: OPTIONS.device_specific = OPTIONS.info_dict.get("tool_extensions", None) OPTIONS.device_specific = OPTIONS.info_dict.get("tool_extensions", None) Loading Loading @@ -2158,7 +2160,7 @@ def main(argv): # Non A/B OTAs rely on /cache partition to store temporary files. # Non A/B OTAs rely on /cache partition to store temporary files. cache_size = OPTIONS.info_dict.get("cache_size", None) cache_size = OPTIONS.info_dict.get("cache_size", None) if cache_size is None: if cache_size is None: print "--- can't determine the cache partition size ---" print("--- can't determine the cache partition size ---") OPTIONS.cache_size = cache_size OPTIONS.cache_size = cache_size # Generate a verify package. # Generate a verify package. Loading @@ -2172,14 +2174,14 @@ def main(argv): # Generate an incremental OTA. It will fall back to generate a full OTA on # Generate an incremental OTA. It will fall back to generate a full OTA on # failure unless no_fallback_to_full is specified. # failure unless no_fallback_to_full is specified. else: else: print "unzipping source target-files..." print("unzipping source target-files...") OPTIONS.source_tmp, source_zip = common.UnzipTemp( OPTIONS.source_tmp, source_zip = common.UnzipTemp( OPTIONS.incremental_source) OPTIONS.incremental_source) OPTIONS.target_info_dict = OPTIONS.info_dict OPTIONS.target_info_dict = OPTIONS.info_dict OPTIONS.source_info_dict = common.LoadInfoDict(source_zip, OPTIONS.source_info_dict = common.LoadInfoDict(source_zip, OPTIONS.source_tmp) OPTIONS.source_tmp) if OPTIONS.verbose: if OPTIONS.verbose: print "--- source info ---" print("--- source info ---") common.DumpInfoDict(OPTIONS.source_info_dict) common.DumpInfoDict(OPTIONS.source_info_dict) try: try: WriteIncrementalOTAPackage(input_zip, source_zip, output_zip) WriteIncrementalOTAPackage(input_zip, source_zip, output_zip) Loading @@ -2194,7 +2196,7 @@ def main(argv): except ValueError: except ValueError: if not OPTIONS.fallback_to_full: if not OPTIONS.fallback_to_full: raise raise print "--- failed to build incremental; falling back to full ---" print("--- failed to build incremental; falling back to full ---") OPTIONS.incremental_source = None OPTIONS.incremental_source = None WriteFullOTAPackage(input_zip, output_zip) WriteFullOTAPackage(input_zip, output_zip) Loading @@ -2205,7 +2207,7 @@ def main(argv): SignOutput(temp_zip_file.name, args[1]) SignOutput(temp_zip_file.name, args[1]) temp_zip_file.close() temp_zip_file.close() print "done." print("done.") if __name__ == '__main__': if __name__ == '__main__': Loading @@ -2213,9 +2215,7 @@ if __name__ == '__main__': common.CloseInheritedPipes() common.CloseInheritedPipes() main(sys.argv[1:]) main(sys.argv[1:]) except common.ExternalError as e: except common.ExternalError as e: print print("\n ERROR: %s\n" % (e,)) print " ERROR: %s" % (e,) print sys.exit(1) sys.exit(1) finally: finally: common.Cleanup() common.Cleanup() Loading
tools/releasetools/add_img_to_target_files.py +21 −19 Original line number Original line Diff line number Diff line Loading @@ -43,10 +43,12 @@ Usage: add_img_to_target_files [flag] target_files are signing the target files. are signing the target files. """ """ from __future__ import print_function import sys import sys if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." print("Python 2.7 or newer is required.", file=sys.stderr) sys.exit(1) sys.exit(1) import datetime import datetime Loading Loading @@ -89,7 +91,7 @@ def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "system.img already exists in %s, no need to rebuild..." % (prefix,) print("system.img already exists in %s, no need to rebuild..." % (prefix,)) return prebuilt_path return prebuilt_path def output_sink(fn, data): def output_sink(fn, data): Loading @@ -98,7 +100,7 @@ def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None): ofile.close() ofile.close() if OPTIONS.rebuild_recovery: if OPTIONS.rebuild_recovery: print "Building new recovery patch" print("Building new recovery patch") common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink, recovery_img, common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink, recovery_img, boot_img, info_dict=OPTIONS.info_dict) boot_img, info_dict=OPTIONS.info_dict) Loading @@ -123,7 +125,8 @@ def AddSystemOther(output_zip, prefix="IMAGES/"): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system_other.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system_other.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "system_other.img already exists in %s, no need to rebuild..." % (prefix,) print("system_other.img already exists in %s, no need to rebuild..." % ( prefix,)) return return imgname = BuildSystemOther(OPTIONS.input_tmp, OPTIONS.info_dict) imgname = BuildSystemOther(OPTIONS.input_tmp, OPTIONS.info_dict) Loading @@ -141,7 +144,7 @@ def AddVendor(output_zip, prefix="IMAGES/"): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "vendor.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "vendor.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "vendor.img already exists in %s, no need to rebuild..." % (prefix,) print("vendor.img already exists in %s, no need to rebuild..." % (prefix,)) return prebuilt_path return prebuilt_path block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map") block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map") Loading @@ -159,7 +162,7 @@ def BuildVendor(input_dir, info_dict, block_list=None): def CreateImage(input_dir, info_dict, what, block_list=None): def CreateImage(input_dir, info_dict, what, block_list=None): print "creating " + what + ".img..." print("creating " + what + ".img...") img = common.MakeTempFile(prefix=what + "-", suffix=".img") img = common.MakeTempFile(prefix=what + "-", suffix=".img") Loading Loading @@ -223,7 +226,8 @@ def AddUserdata(output_zip, prefix="IMAGES/"): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "userdata.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "userdata.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "userdata.img already exists in %s, no need to rebuild..." % (prefix,) print("userdata.img already exists in %s, no need to rebuild..." % ( prefix,)) return return # Skip userdata.img if no size. # Skip userdata.img if no size. Loading @@ -231,7 +235,7 @@ def AddUserdata(output_zip, prefix="IMAGES/"): if not image_props.get("partition_size"): if not image_props.get("partition_size"): return return print "creating userdata.img..." print("creating userdata.img...") # Use a fixed timestamp (01/01/2009) when packaging the image. # Use a fixed timestamp (01/01/2009) when packaging the image. # Bug: 24377993 # Bug: 24377993 Loading Loading @@ -321,7 +325,7 @@ def AddCache(output_zip, prefix="IMAGES/"): prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "cache.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "cache.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "cache.img already exists in %s, no need to rebuild..." % (prefix,) print("cache.img already exists in %s, no need to rebuild..." % (prefix,)) return return image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "cache") image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "cache") Loading @@ -329,7 +333,7 @@ def AddCache(output_zip, prefix="IMAGES/"): if "fs_type" not in image_props: if "fs_type" not in image_props: return return print "creating cache.img..." print("creating cache.img...") # Use a fixed timestamp (01/01/2009) when packaging the image. # Use a fixed timestamp (01/01/2009) when packaging the image. # Bug: 24377993 # Bug: 24377993 Loading Loading @@ -364,7 +368,7 @@ def AddImagesToTargetFiles(filename): if not OPTIONS.add_missing: if not OPTIONS.add_missing: for n in input_zip.namelist(): for n in input_zip.namelist(): if n.startswith("IMAGES/"): if n.startswith("IMAGES/"): print "target_files appears to already contain images." print("target_files appears to already contain images.") sys.exit(1) sys.exit(1) try: try: Loading @@ -386,13 +390,13 @@ def AddImagesToTargetFiles(filename): system_root_image = (OPTIONS.info_dict.get("system_root_image", None) == "true") system_root_image = (OPTIONS.info_dict.get("system_root_image", None) == "true") def banner(s): def banner(s): print "\n\n++++ " + s + " ++++\n\n" print("\n\n++++ " + s + " ++++\n\n") prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") boot_image = None boot_image = None if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): banner("boot") banner("boot") print "boot.img already exists in IMAGES/, no need to rebuild..." print("boot.img already exists in IMAGES/, no need to rebuild...") if OPTIONS.rebuild_recovery: if OPTIONS.rebuild_recovery: boot_image = common.GetBootableImage( boot_image = common.GetBootableImage( "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") Loading @@ -408,7 +412,7 @@ def AddImagesToTargetFiles(filename): banner("recovery") banner("recovery") prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img") prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img") if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "recovery.img already exists in IMAGES/, no need to rebuild..." print("recovery.img already exists in IMAGES/, no need to rebuild...") if OPTIONS.rebuild_recovery: if OPTIONS.rebuild_recovery: recovery_image = common.GetBootableImage( recovery_image = common.GetBootableImage( "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, Loading Loading @@ -474,7 +478,7 @@ def AddImagesToTargetFiles(filename): img_name = line.strip() + ".img" img_name = line.strip() + ".img" prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name) prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name) if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "%s already exists, no need to overwrite..." % (img_name,) print("%s already exists, no need to overwrite..." % (img_name,)) continue continue img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name) img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name) Loading Loading @@ -530,16 +534,14 @@ def main(argv): sys.exit(1) sys.exit(1) AddImagesToTargetFiles(args[0]) AddImagesToTargetFiles(args[0]) print "done." print("done.") if __name__ == '__main__': if __name__ == '__main__': try: try: common.CloseInheritedPipes() common.CloseInheritedPipes() main(sys.argv[1:]) main(sys.argv[1:]) except common.ExternalError as e: except common.ExternalError as e: print print("\n ERROR: %s\n" % (e,)) print " ERROR: %s" % (e,) print sys.exit(1) sys.exit(1) finally: finally: common.Cleanup() common.Cleanup()
tools/releasetools/common.py +33 −33 Original line number Original line Diff line number Diff line Loading @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # See the License for the specific language governing permissions and # limitations under the License. # limitations under the License. from __future__ import print_function import copy import copy import errno import errno import getopt import getopt Loading Loading @@ -109,7 +111,7 @@ def Run(args, **kwargs): """Create and return a subprocess.Popen object, printing the command """Create and return a subprocess.Popen object, printing the command line on the terminal if -v was specified.""" line on the terminal if -v was specified.""" if OPTIONS.verbose: if OPTIONS.verbose: print " running: ", " ".join(args) print(" running: ", " ".join(args)) return subprocess.Popen(args, **kwargs) return subprocess.Popen(args, **kwargs) Loading Loading @@ -208,8 +210,8 @@ def LoadInfoDict(input_file, input_dir=None): if os.path.exists(system_base_fs_file): if os.path.exists(system_base_fs_file): d["system_base_fs_file"] = system_base_fs_file d["system_base_fs_file"] = system_base_fs_file else: else: print "Warning: failed to find system base fs file: %s" % ( print("Warning: failed to find system base fs file: %s" % ( system_base_fs_file,) system_base_fs_file,)) del d["system_base_fs_file"] del d["system_base_fs_file"] if "vendor_base_fs_file" in d: if "vendor_base_fs_file" in d: Loading @@ -218,8 +220,8 @@ def LoadInfoDict(input_file, input_dir=None): if os.path.exists(vendor_base_fs_file): if os.path.exists(vendor_base_fs_file): d["vendor_base_fs_file"] = vendor_base_fs_file d["vendor_base_fs_file"] = vendor_base_fs_file else: else: print "Warning: failed to find vendor base fs file: %s" % ( print("Warning: failed to find vendor base fs file: %s" % ( vendor_base_fs_file,) vendor_base_fs_file,)) del d["vendor_base_fs_file"] del d["vendor_base_fs_file"] try: try: Loading Loading @@ -270,7 +272,7 @@ def LoadBuildProp(read_helper): try: try: data = read_helper("SYSTEM/build.prop") data = read_helper("SYSTEM/build.prop") except KeyError: except KeyError: print "Warning: could not find SYSTEM/build.prop in %s" % zip print("Warning: could not find SYSTEM/build.prop in %s" % (zip,)) data = "" data = "" return LoadDictionaryFromLines(data.split("\n")) return LoadDictionaryFromLines(data.split("\n")) Loading Loading @@ -299,7 +301,7 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path, try: try: data = read_helper(recovery_fstab_path) data = read_helper(recovery_fstab_path) except KeyError: except KeyError: print "Warning: could not find {}".format(recovery_fstab_path) print("Warning: could not find {}".format(recovery_fstab_path)) data = "" data = "" if fstab_version == 1: if fstab_version == 1: Loading Loading @@ -331,7 +333,7 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path, if i.startswith("length="): if i.startswith("length="): length = int(i[7:]) length = int(i[7:]) else: else: print "%s: unknown option \"%s\"" % (mount_point, i) print("%s: unknown option \"%s\"" % (mount_point, i)) d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[1], d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[1], device=pieces[2], length=length, device=pieces[2], length=length, Loading Loading @@ -389,7 +391,7 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path, def DumpInfoDict(d): def DumpInfoDict(d): for k, v in sorted(d.items()): for k, v in sorted(d.items()): print "%-25s = (%s) %s" % (k, type(v).__name__, v) print("%-25s = (%s) %s" % (k, type(v).__name__, v)) def AppendAVBSigningArgs(cmd): def AppendAVBSigningArgs(cmd): Loading Loading @@ -565,15 +567,15 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, prebuilt_path = os.path.join(unpack_dir, "BOOTABLE_IMAGES", prebuilt_name) prebuilt_path = os.path.join(unpack_dir, "BOOTABLE_IMAGES", prebuilt_name) if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "using prebuilt %s from BOOTABLE_IMAGES..." % (prebuilt_name,) print("using prebuilt %s from BOOTABLE_IMAGES..." % (prebuilt_name,)) return File.FromLocalFile(name, prebuilt_path) return File.FromLocalFile(name, prebuilt_path) prebuilt_path = os.path.join(unpack_dir, "IMAGES", prebuilt_name) prebuilt_path = os.path.join(unpack_dir, "IMAGES", prebuilt_name) if os.path.exists(prebuilt_path): if os.path.exists(prebuilt_path): print "using prebuilt %s from IMAGES..." % (prebuilt_name,) print("using prebuilt %s from IMAGES..." % (prebuilt_name,)) return File.FromLocalFile(name, prebuilt_path) return File.FromLocalFile(name, prebuilt_path) print "building image from target_files %s..." % (tree_subdir,) print("building image from target_files %s..." % (tree_subdir,)) if info_dict is None: if info_dict is None: info_dict = OPTIONS.info_dict info_dict = OPTIONS.info_dict Loading Loading @@ -792,11 +794,9 @@ def CheckSize(data, target, info_dict): if pct >= 99.0: if pct >= 99.0: raise ExternalError(msg) raise ExternalError(msg) elif pct >= 95.0: elif pct >= 95.0: print print("\n WARNING: %s\n" % (msg,)) print " WARNING: ", msg print elif OPTIONS.verbose: elif OPTIONS.verbose: print " ", msg print(" ", msg) def ReadApkCerts(tf_zip): def ReadApkCerts(tf_zip): Loading Loading @@ -845,8 +845,8 @@ COMMON_DOCSTRING = """ """ """ def Usage(docstring): def Usage(docstring): print docstring.rstrip("\n") print(docstring.rstrip("\n")) print COMMON_DOCSTRING print(COMMON_DOCSTRING) def ParseOptions(argv, def ParseOptions(argv, Loading @@ -871,7 +871,7 @@ def ParseOptions(argv, list(extra_long_opts)) list(extra_long_opts)) except getopt.GetoptError as err: except getopt.GetoptError as err: Usage(docstring) Usage(docstring) print "**", str(err), "**" print("**", str(err), "**") sys.exit(2) sys.exit(2) for o, a in opts: for o, a in opts: Loading Loading @@ -969,7 +969,7 @@ class PasswordManager(object): current[i] = "" current[i] = "" if not first: if not first: print "key file %s still missing some passwords." % (self.pwfile,) print("key file %s still missing some passwords." % (self.pwfile,)) answer = raw_input("try to edit again? [y]> ").strip() answer = raw_input("try to edit again? [y]> ").strip() if answer and answer[0] not in 'yY': if answer and answer[0] not in 'yY': raise RuntimeError("key passwords unavailable") raise RuntimeError("key passwords unavailable") Loading Loading @@ -1029,13 +1029,13 @@ class PasswordManager(object): continue continue m = re.match(r"^\[\[\[\s*(.*?)\s*\]\]\]\s*(\S+)$", line) m = re.match(r"^\[\[\[\s*(.*?)\s*\]\]\]\s*(\S+)$", line) if not m: if not m: print "failed to parse password file: ", line print("failed to parse password file: ", line) else: else: result[m.group(2)] = m.group(1) result[m.group(2)] = m.group(1) f.close() f.close() except IOError as e: except IOError as e: if e.errno != errno.ENOENT: if e.errno != errno.ENOENT: print "error reading password file: ", str(e) print("error reading password file: ", str(e)) return result return result Loading Loading @@ -1156,10 +1156,10 @@ class DeviceSpecificParams(object): if x == ".py": if x == ".py": f = b f = b info = imp.find_module(f, [d]) info = imp.find_module(f, [d]) print "loaded device-specific extensions from", path print("loaded device-specific extensions from", path) self.module = imp.load_module("device_specific", *info) self.module = imp.load_module("device_specific", *info) except ImportError: except ImportError: print "unable to load device-specific module; assuming none" print("unable to load device-specific module; assuming none") def _DoCall(self, function_name, *args, **kwargs): def _DoCall(self, function_name, *args, **kwargs): """Call the named function in the device-specific module, passing """Call the named function in the device-specific module, passing Loading Loading @@ -1294,7 +1294,7 @@ class Difference(object): th.start() th.start() th.join(timeout=300) # 5 mins th.join(timeout=300) # 5 mins if th.is_alive(): if th.is_alive(): print "WARNING: diff command timed out" print("WARNING: diff command timed out") p.terminate() p.terminate() th.join(5) th.join(5) if th.is_alive(): if th.is_alive(): Loading @@ -1302,8 +1302,8 @@ class Difference(object): th.join() th.join() if err or p.returncode != 0: if err or p.returncode != 0: print "WARNING: failure running %s:\n%s\n" % ( print("WARNING: failure running %s:\n%s\n" % ( diff_program, "".join(err)) diff_program, "".join(err))) self.patch = None self.patch = None return None, None, None return None, None, None diff = ptemp.read() diff = ptemp.read() Loading @@ -1325,7 +1325,7 @@ class Difference(object): def ComputeDifferences(diffs): def ComputeDifferences(diffs): """Call ComputePatch on all the Difference objects in 'diffs'.""" """Call ComputePatch on all the Difference objects in 'diffs'.""" print len(diffs), "diffs to compute" print(len(diffs), "diffs to compute") # Do the largest files first, to try and reduce the long-pole effect. # Do the largest files first, to try and reduce the long-pole effect. by_size = [(i.tf.size, i) for i in diffs] by_size = [(i.tf.size, i) for i in diffs] Loading @@ -1351,13 +1351,13 @@ def ComputeDifferences(diffs): else: else: name = "%s (%s)" % (tf.name, sf.name) name = "%s (%s)" % (tf.name, sf.name) if patch is None: if patch is None: print "patching failed! %s" % (name,) print("patching failed! %s" % (name,)) else: else: print "%8.2f sec %8d / %8d bytes (%6.2f%%) %s" % ( print("%8.2f sec %8d / %8d bytes (%6.2f%%) %s" % ( dur, len(patch), tf.size, 100.0 * len(patch) / tf.size, name) dur, len(patch), tf.size, 100.0 * len(patch) / tf.size, name)) lock.release() lock.release() except Exception as e: except Exception as e: print e print(e) raise raise # start worker threads; wait for them all to finish. # start worker threads; wait for them all to finish. Loading Loading @@ -1736,6 +1736,6 @@ fi if found: if found: break break print "putting script in", sh_location print("putting script in", sh_location) output_sink(sh_location, sh) output_sink(sh_location, sh)
tools/releasetools/img_from_target_files.py +7 −7 Original line number Original line Diff line number Diff line Loading @@ -26,10 +26,12 @@ Usage: img_from_target_files [flags] input_target_files output_image_zip """ """ from __future__ import print_function import sys import sys if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." print("Python 2.7 or newer is required.", file=sys.stderr) sys.exit(1) sys.exit(1) import os import os Loading Loading @@ -111,7 +113,7 @@ def main(argv): recovery_image.AddToZip(output_zip) recovery_image.AddToZip(output_zip) def banner(s): def banner(s): print "\n\n++++ " + s + " ++++\n\n" print("\n\n++++ " + s + " ++++\n\n") if not bootable_only: if not bootable_only: banner("AddSystem") banner("AddSystem") Loading @@ -128,11 +130,11 @@ def main(argv): add_img_to_target_files.AddCache(output_zip, prefix="") add_img_to_target_files.AddCache(output_zip, prefix="") finally: finally: print "cleaning up..." print("cleaning up...") common.ZipClose(output_zip) common.ZipClose(output_zip) shutil.rmtree(OPTIONS.input_tmp) shutil.rmtree(OPTIONS.input_tmp) print "done." print("done.") if __name__ == '__main__': if __name__ == '__main__': Loading @@ -140,7 +142,5 @@ if __name__ == '__main__': common.CloseInheritedPipes() common.CloseInheritedPipes() main(sys.argv[1:]) main(sys.argv[1:]) except common.ExternalError as e: except common.ExternalError as e: print print("\n ERROR: %s\n" % (e,)) print " ERROR: %s" % (e,) print sys.exit(1) sys.exit(1)
tools/releasetools/make_recovery_patch.py +3 −1 Original line number Original line Diff line number Diff line Loading @@ -14,10 +14,12 @@ # See the License for the specific language governing permissions and # See the License for the specific language governing permissions and # limitations under the License. # limitations under the License. from __future__ import print_function import sys import sys if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." print("Python 2.7 or newer is required.", file=sys.stderr) sys.exit(1) sys.exit(1) import os import os Loading
tools/releasetools/ota_from_target_files.py +45 −45 Original line number Original line Diff line number Diff line Loading @@ -121,10 +121,12 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package Specify the arguments needed for payload signer. Specify the arguments needed for payload signer. """ """ from __future__ import print_function import sys import sys if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." print("Python 2.7 or newer is required.", file=sys.stderr) sys.exit(1) sys.exit(1) import multiprocessing import multiprocessing Loading Loading @@ -292,14 +294,14 @@ class Item(object): def Dump(self, indent=0): def Dump(self, indent=0): if self.uid is not None: if self.uid is not None: print "%s%s %d %d %o" % ( print("%s%s %d %d %o" % ( " " * indent, self.name, self.uid, self.gid, self.mode) " " * indent, self.name, self.uid, self.gid, self.mode)) else: else: print "%s%s %s %s %s" % ( print("%s%s %s %s %s" % ( " " * indent, self.name, self.uid, self.gid, self.mode) " " * indent, self.name, self.uid, self.gid, self.mode)) if self.is_dir: if self.is_dir: print "%s%s" % (" "*indent, self.descendants) print("%s%s" % (" " * indent, self.descendants)) print "%s%s" % (" "*indent, self.best_subtree) print("%s%s" % (" " * indent, self.best_subtree)) for i in self.children: for i in self.children: i.Dump(indent=indent+1) i.Dump(indent=indent+1) Loading Loading @@ -485,11 +487,11 @@ def _WriteRecoveryImageToBoot(script, output_zip): OPTIONS.input_tmp, "RECOVERY") OPTIONS.input_tmp, "RECOVERY") common.ZipWriteStr( common.ZipWriteStr( output_zip, recovery_two_step_img_name, recovery_two_step_img.data) output_zip, recovery_two_step_img_name, recovery_two_step_img.data) print "two-step package: using %s in stage 1/3" % ( print("two-step package: using %s in stage 1/3" % ( recovery_two_step_img_name,) recovery_two_step_img_name,)) script.WriteRawImage("/boot", recovery_two_step_img_name) script.WriteRawImage("/boot", recovery_two_step_img_name) else: else: print "two-step package: using recovery.img in stage 1/3" print("two-step package: using recovery.img in stage 1/3") # The "recovery.img" entry has been written into package earlier. # The "recovery.img" entry has been written into package earlier. script.WriteRawImage("/boot", "recovery.img") script.WriteRawImage("/boot", "recovery.img") Loading Loading @@ -533,11 +535,11 @@ def GetImage(which, tmpdir, info_dict): path = os.path.join(tmpdir, "IMAGES", which + ".img") path = os.path.join(tmpdir, "IMAGES", which + ".img") mappath = os.path.join(tmpdir, "IMAGES", which + ".map") mappath = os.path.join(tmpdir, "IMAGES", which + ".map") if os.path.exists(path) and os.path.exists(mappath): if os.path.exists(path) and os.path.exists(mappath): print "using %s.img from target-files" % (which,) print("using %s.img from target-files" % (which,)) # This is a 'new' target-files, which already has the image in it. # This is a 'new' target-files, which already has the image in it. else: else: print "building %s.img from target-files" % (which,) print("building %s.img from target-files" % (which,)) # This is an 'old' target-files, which does not contain images # This is an 'old' target-files, which does not contain images # already built. Build them. # already built. Build them. Loading Loading @@ -1048,8 +1050,8 @@ else if get_stage("%(bcb_dev)s") != "3/3" then else: else: include_full_boot = False include_full_boot = False print "boot target: %d source: %d diff: %d" % ( print("boot target: %d source: %d diff: %d" % ( target_boot.size, source_boot.size, len(d)) target_boot.size, source_boot.size, len(d))) common.ZipWriteStr(output_zip, "patch/boot.img.p", d) common.ZipWriteStr(output_zip, "patch/boot.img.p", d) Loading Loading @@ -1095,19 +1097,19 @@ else if OPTIONS.two_step: if OPTIONS.two_step: common.ZipWriteStr(output_zip, "boot.img", target_boot.data) common.ZipWriteStr(output_zip, "boot.img", target_boot.data) script.WriteRawImage("/boot", "boot.img") script.WriteRawImage("/boot", "boot.img") print "writing full boot image (forced by two-step mode)" print("writing full boot image (forced by two-step mode)") if not OPTIONS.two_step: if not OPTIONS.two_step: if updating_boot: if updating_boot: if include_full_boot: if include_full_boot: print "boot image changed; including full." print("boot image changed; including full.") script.Print("Installing boot image...") script.Print("Installing boot image...") script.WriteRawImage("/boot", "boot.img") script.WriteRawImage("/boot", "boot.img") else: else: # Produce the boot image by applying a patch to the current # Produce the boot image by applying a patch to the current # contents of the boot partition, and write it back to the # contents of the boot partition, and write it back to the # partition. # partition. print "boot image changed; including patch." print("boot image changed; including patch.") script.Print("Patching boot image...") script.Print("Patching boot image...") script.ShowProgress(0.1, 10) script.ShowProgress(0.1, 10) script.ApplyPatch("%s:%s:%d:%s:%d:%s" script.ApplyPatch("%s:%s:%d:%s:%d:%s" Loading @@ -1118,7 +1120,7 @@ else target_boot.size, target_boot.sha1, target_boot.size, target_boot.sha1, source_boot.sha1, "patch/boot.img.p") source_boot.sha1, "patch/boot.img.p") else: else: print "boot image unchanged; skipping." print("boot image unchanged; skipping.") # Do device-specific installation (eg, write radio image). # Do device-specific installation (eg, write radio image). device_specific.IncrementalOTA_InstallEnd() device_specific.IncrementalOTA_InstallEnd() Loading Loading @@ -1381,7 +1383,7 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file, care_map_data = target_zip.read(care_map_path) care_map_data = target_zip.read(care_map_path) common.ZipWriteStr(output_zip, "care_map.txt", care_map_data) common.ZipWriteStr(output_zip, "care_map.txt", care_map_data) else: else: print "Warning: cannot find care map file in target_file package" print("Warning: cannot find care map file in target_file package") common.ZipClose(target_zip) common.ZipClose(target_zip) # Sign the whole package to comply with the Android OTA package format. # Sign the whole package to comply with the Android OTA package format. Loading @@ -1393,9 +1395,9 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file, class FileDifference(object): class FileDifference(object): def __init__(self, partition, source_zip, target_zip, output_zip): def __init__(self, partition, source_zip, target_zip, output_zip): self.deferred_patch_list = None self.deferred_patch_list = None print "Loading target..." print("Loading target...") self.target_data = target_data = LoadPartitionFiles(target_zip, partition) self.target_data = target_data = LoadPartitionFiles(target_zip, partition) print "Loading source..." print("Loading source...") self.source_data = source_data = LoadPartitionFiles(source_zip, partition) self.source_data = source_data = LoadPartitionFiles(source_zip, partition) self.verbatim_targets = verbatim_targets = [] self.verbatim_targets = verbatim_targets = [] Loading @@ -1422,14 +1424,14 @@ class FileDifference(object): assert fn == tf.name assert fn == tf.name sf = ClosestFileMatch(tf, matching_file_cache, renames) sf = ClosestFileMatch(tf, matching_file_cache, renames) if sf is not None and sf.name != tf.name: if sf is not None and sf.name != tf.name: print "File has moved from " + sf.name + " to " + tf.name print("File has moved from " + sf.name + " to " + tf.name) renames[sf.name] = tf renames[sf.name] = tf if sf is None or fn in OPTIONS.require_verbatim: if sf is None or fn in OPTIONS.require_verbatim: # This file should be included verbatim # This file should be included verbatim if fn in OPTIONS.prohibit_verbatim: if fn in OPTIONS.prohibit_verbatim: raise common.ExternalError("\"%s\" must be sent verbatim" % (fn,)) raise common.ExternalError("\"%s\" must be sent verbatim" % (fn,)) print "send", fn, "verbatim" print("send", fn, "verbatim") tf.AddToZip(output_zip) tf.AddToZip(output_zip) verbatim_targets.append((fn, tf.size, tf.sha1)) verbatim_targets.append((fn, tf.size, tf.sha1)) if fn in target_data.keys(): if fn in target_data.keys(): Loading Loading @@ -1517,7 +1519,7 @@ class FileDifference(object): if len(self.renames) > 0: if len(self.renames) > 0: script.Print("Renaming files...") script.Print("Renaming files...") for src, tgt in self.renames.iteritems(): for src, tgt in self.renames.iteritems(): print "Renaming " + src + " to " + tgt.name print("Renaming " + src + " to " + tgt.name) script.RenameFile(src, tgt.name) script.RenameFile(src, tgt.name) Loading Loading @@ -1719,8 +1721,8 @@ else if get_stage("%(bcb_dev)s") != "3/3" then if updating_boot: if updating_boot: d = common.Difference(target_boot, source_boot) d = common.Difference(target_boot, source_boot) _, _, d = d.ComputePatch() _, _, d = d.ComputePatch() print "boot target: %d source: %d diff: %d" % ( print("boot target: %d source: %d diff: %d" % ( target_boot.size, source_boot.size, len(d)) target_boot.size, source_boot.size, len(d))) common.ZipWriteStr(output_zip, "patch/boot.img.p", d) common.ZipWriteStr(output_zip, "patch/boot.img.p", d) Loading Loading @@ -1759,7 +1761,7 @@ else if OPTIONS.two_step: if OPTIONS.two_step: common.ZipWriteStr(output_zip, "boot.img", target_boot.data) common.ZipWriteStr(output_zip, "boot.img", target_boot.data) script.WriteRawImage("/boot", "boot.img") script.WriteRawImage("/boot", "boot.img") print "writing full boot image (forced by two-step mode)" print("writing full boot image (forced by two-step mode)") script.Print("Removing unneeded files...") script.Print("Removing unneeded files...") system_diff.RemoveUnneededFiles(script, ("/system/recovery.img",)) system_diff.RemoveUnneededFiles(script, ("/system/recovery.img",)) Loading Loading @@ -1794,9 +1796,9 @@ else source_boot.sha1, "patch/boot.img.p") source_boot.sha1, "patch/boot.img.p") so_far += target_boot.size so_far += target_boot.size script.SetProgress(so_far / total_patch_size) script.SetProgress(so_far / total_patch_size) print "boot image changed; including." print("boot image changed; including.") else: else: print "boot image unchanged; skipping." print("boot image unchanged; skipping.") system_items = ItemSet("system", "META/filesystem_config.txt") system_items = ItemSet("system", "META/filesystem_config.txt") if vendor_diff: if vendor_diff: Loading @@ -1822,9 +1824,9 @@ else script.DeleteFiles(["/system/recovery-from-boot.p", script.DeleteFiles(["/system/recovery-from-boot.p", "/system/etc/recovery.img", "/system/etc/recovery.img", "/system/etc/install-recovery.sh"]) "/system/etc/install-recovery.sh"]) print "recovery image changed; including as patch from boot." print("recovery image changed; including as patch from boot.") else: else: print "recovery image unchanged; skipping." print("recovery image unchanged; skipping.") script.ShowProgress(0.1, 10) script.ShowProgress(0.1, 10) Loading Loading @@ -2087,11 +2089,11 @@ def main(argv): common.ZipClose(source_zip) common.ZipClose(source_zip) if OPTIONS.verbose: if OPTIONS.verbose: print "--- target info ---" print("--- target info ---") common.DumpInfoDict(OPTIONS.info_dict) common.DumpInfoDict(OPTIONS.info_dict) if OPTIONS.incremental_source is not None: if OPTIONS.incremental_source is not None: print "--- source info ---" print("--- source info ---") common.DumpInfoDict(OPTIONS.source_info_dict) common.DumpInfoDict(OPTIONS.source_info_dict) WriteABOTAPackageWithBrilloScript( WriteABOTAPackageWithBrilloScript( Loading @@ -2099,20 +2101,20 @@ def main(argv): output_file=args[1], output_file=args[1], source_file=OPTIONS.incremental_source) source_file=OPTIONS.incremental_source) print "done." print("done.") return return if OPTIONS.extra_script is not None: if OPTIONS.extra_script is not None: OPTIONS.extra_script = open(OPTIONS.extra_script).read() OPTIONS.extra_script = open(OPTIONS.extra_script).read() print "unzipping target target-files..." print("unzipping target target-files...") OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0]) OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0]) OPTIONS.target_tmp = OPTIONS.input_tmp OPTIONS.target_tmp = OPTIONS.input_tmp OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp) OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp) if OPTIONS.verbose: if OPTIONS.verbose: print "--- target info ---" print("--- target info ---") common.DumpInfoDict(OPTIONS.info_dict) common.DumpInfoDict(OPTIONS.info_dict) # If the caller explicitly specified the device-specific extensions # If the caller explicitly specified the device-specific extensions Loading @@ -2125,7 +2127,7 @@ def main(argv): if OPTIONS.device_specific is None: if OPTIONS.device_specific is None: from_input = os.path.join(OPTIONS.input_tmp, "META", "releasetools.py") from_input = os.path.join(OPTIONS.input_tmp, "META", "releasetools.py") if os.path.exists(from_input): if os.path.exists(from_input): print "(using device-specific extensions from target_files)" print("(using device-specific extensions from target_files)") OPTIONS.device_specific = from_input OPTIONS.device_specific = from_input else: else: OPTIONS.device_specific = OPTIONS.info_dict.get("tool_extensions", None) OPTIONS.device_specific = OPTIONS.info_dict.get("tool_extensions", None) Loading Loading @@ -2158,7 +2160,7 @@ def main(argv): # Non A/B OTAs rely on /cache partition to store temporary files. # Non A/B OTAs rely on /cache partition to store temporary files. cache_size = OPTIONS.info_dict.get("cache_size", None) cache_size = OPTIONS.info_dict.get("cache_size", None) if cache_size is None: if cache_size is None: print "--- can't determine the cache partition size ---" print("--- can't determine the cache partition size ---") OPTIONS.cache_size = cache_size OPTIONS.cache_size = cache_size # Generate a verify package. # Generate a verify package. Loading @@ -2172,14 +2174,14 @@ def main(argv): # Generate an incremental OTA. It will fall back to generate a full OTA on # Generate an incremental OTA. It will fall back to generate a full OTA on # failure unless no_fallback_to_full is specified. # failure unless no_fallback_to_full is specified. else: else: print "unzipping source target-files..." print("unzipping source target-files...") OPTIONS.source_tmp, source_zip = common.UnzipTemp( OPTIONS.source_tmp, source_zip = common.UnzipTemp( OPTIONS.incremental_source) OPTIONS.incremental_source) OPTIONS.target_info_dict = OPTIONS.info_dict OPTIONS.target_info_dict = OPTIONS.info_dict OPTIONS.source_info_dict = common.LoadInfoDict(source_zip, OPTIONS.source_info_dict = common.LoadInfoDict(source_zip, OPTIONS.source_tmp) OPTIONS.source_tmp) if OPTIONS.verbose: if OPTIONS.verbose: print "--- source info ---" print("--- source info ---") common.DumpInfoDict(OPTIONS.source_info_dict) common.DumpInfoDict(OPTIONS.source_info_dict) try: try: WriteIncrementalOTAPackage(input_zip, source_zip, output_zip) WriteIncrementalOTAPackage(input_zip, source_zip, output_zip) Loading @@ -2194,7 +2196,7 @@ def main(argv): except ValueError: except ValueError: if not OPTIONS.fallback_to_full: if not OPTIONS.fallback_to_full: raise raise print "--- failed to build incremental; falling back to full ---" print("--- failed to build incremental; falling back to full ---") OPTIONS.incremental_source = None OPTIONS.incremental_source = None WriteFullOTAPackage(input_zip, output_zip) WriteFullOTAPackage(input_zip, output_zip) Loading @@ -2205,7 +2207,7 @@ def main(argv): SignOutput(temp_zip_file.name, args[1]) SignOutput(temp_zip_file.name, args[1]) temp_zip_file.close() temp_zip_file.close() print "done." print("done.") if __name__ == '__main__': if __name__ == '__main__': Loading @@ -2213,9 +2215,7 @@ if __name__ == '__main__': common.CloseInheritedPipes() common.CloseInheritedPipes() main(sys.argv[1:]) main(sys.argv[1:]) except common.ExternalError as e: except common.ExternalError as e: print print("\n ERROR: %s\n" % (e,)) print " ERROR: %s" % (e,) print sys.exit(1) sys.exit(1) finally: finally: common.Cleanup() common.Cleanup()