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