Merge "Add dexoptanalyzer to art PRODUCT_PACKAGES"
diff --git a/core/Makefile b/core/Makefile
index cbe9eed..1dc3f52 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -849,6 +849,8 @@
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
+$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
+$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
diff --git a/core/binary.mk b/core/binary.mk
index 4db3d51..4986c85 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -57,6 +57,7 @@
my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES)
my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
+my_arflags :=
ifneq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH)))))
my_native_coverage := true
@@ -1736,6 +1737,7 @@
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(my_arflags)
# this is really the way to get the files onto the command line instead
# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index 3a59ee3..38cf86d 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -3,6 +3,7 @@
##############################################
my_sanitize := $(strip $(LOCAL_SANITIZE))
+my_sanitize_diag := $(strip $(LOCAL_SANITIZE_DIAG))
# SANITIZE_HOST is only in effect if the module is already using clang (host
# modules that haven't set `LOCAL_CLANG := false` and device modules that
@@ -61,6 +62,12 @@
my_sanitize :=
endif
+# If CFI is disabled globally, remove it from my_sanitize.
+ifeq ($(strip $(ENABLE_CFI)),)
+ my_sanitize := $(filter-out cfi,$(my_sanitize))
+ my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
+endif
+
my_nosanitize = $(strip $(LOCAL_NOSANITIZE))
ifneq ($(my_nosanitize),)
my_sanitize := $(filter-out $(my_nosanitize),$(my_sanitize))
@@ -136,8 +143,13 @@
endif
ifneq ($(filter cfi,$(my_sanitize)),)
+ # __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp).
+ # LLVM is not set up to do this on a function basis, so force Thumb on the
+ # entire module.
+ LOCAL_ARM_MODE := thumb
my_cflags += -flto -fsanitize-cfi-cross-dso -fvisibility=default
my_ldflags += -flto -fsanitize-cfi-cross-dso -fsanitize=cfi -Wl,-plugin-opt,O1 -Wl,-export-dynamic-symbol=__cfi_check
+ my_arflags += --plugin $(LLVM_PREBUILTS_PATH)/../lib64/LLVMgold.so
endif
# If local or global modules need ASAN, add linker flags.
@@ -195,8 +207,8 @@
my_cflags += -fsanitize-recover=$(recover_arg)
endif
-ifneq ($(strip $(LOCAL_SANITIZE_DIAG)),)
- notrap_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_DIAG)),
+ifneq ($(my_sanitize_diag),)
+ notrap_arg := $(subst $(space),$(comma),$(my_sanitize_diag)),
my_cflags += -fno-sanitize-trap=$(notrap_arg)
# Diagnostic requires a runtime library, unless ASan or TSan are also enabled.
ifeq ($(filter address thread,$(my_sanitize)),)
diff --git a/core/definitions.mk b/core/definitions.mk
index dd53e7e..d77cea9 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1581,6 +1581,7 @@
$(extract-and-include-target-whole-static-libs)
$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
+ $(PRIVATE_ARFLAGS) \
$@,$(PRIVATE_ALL_OBJECTS))
endef
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index 5831e24..839e14f 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -15,7 +15,7 @@
ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
# Only support prebuilt shared and static libraries for translated arch
- ifeq ($(filter SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
+ ifeq ($(filter SHARED_LIBRARIES STATIC_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
LOCAL_MULTILIB := first
endif
endif
diff --git a/core/soong_config.mk b/core/soong_config.mk
index da39981..7b1be47 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -63,6 +63,7 @@
echo ' "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \
echo ' "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \
echo ' "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false),'; \
+ echo ' "EnableCFI": $(if $(filter true,$(ENABLE_CFI)),true,false),'; \
echo ''; \
echo ' "ArtUseReadBarrier": $(if $(filter true,$(PRODUCT_ART_USE_READ_BARRIER)),true,false),'; \
echo ''; \
diff --git a/core/tasks/check_boot_jars/package_whitelist.txt b/core/tasks/check_boot_jars/package_whitelist.txt
index ae69099..1889117 100644
--- a/core/tasks/check_boot_jars/package_whitelist.txt
+++ b/core/tasks/check_boot_jars/package_whitelist.txt
@@ -29,6 +29,11 @@
java\.sql
java\.text
java\.text\.spi
+java\.time
+java\.time\.chrono
+java\.time\.format
+java\.time\.temporal
+java\.time\.zone
java\.util
java\.util\.concurrent
java\.util\.concurrent\.atomic
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index af6bb98..9585eb0 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -26,7 +26,8 @@
bootanimation \
bootstat \
cmd \
- debuggerd \
+ crash_dump \
+ debuggerd\
dumpstate \
dumpsys \
fastboot \
@@ -75,6 +76,7 @@
servicemanager \
sh \
surfaceflinger \
+ tombstoned \
toolbox \
toybox \
tzdatacheck \
@@ -85,13 +87,14 @@
nonplat_file_contexts \
nonplat_mac_permissions.xml \
nonplat_seapp_contexts \
+ nonplat_service_contexts \
plat_file_contexts \
plat_mac_permissions.xml \
plat_seapp_contexts \
+ plat_service_contexts \
property_contexts \
selinux_version \
- sepolicy \
- service_contexts
+ sepolicy
# AID Generation for
# <pwd.h> and <grp.h>
diff --git a/target/product/telephony.mk b/target/product/telephony.mk
index e840ba1..38a8caa 100644
--- a/target/product/telephony.mk
+++ b/target/product/telephony.mk
@@ -19,6 +19,7 @@
PRODUCT_PACKAGES := \
CarrierConfig \
+ CarrierDefaultApp \
Dialer \
CallLogBackup \
CellBroadcastReceiver \
diff --git a/tools/makeparallel/Makefile b/tools/makeparallel/Makefile
index 4e12b10..82a4abf 100644
--- a/tools/makeparallel/Makefile
+++ b/tools/makeparallel/Makefile
@@ -65,8 +65,9 @@
makeparallel_test: $(MAKEPARALLEL)
@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -j1234
@EXPECTED="-j123" $(MAKEPARALLEL_TEST) -j123
- @EXPECTED="-j1" $(MAKEPARALLEL_TEST) -j1
- @EXPECTED="-j1" $(MAKEPARALLEL_TEST)
+ @EXPECTED="" $(MAKEPARALLEL_TEST) -j1
+ @EXPECTED="-j$$(($$(nproc) + 2))" $(MAKEPARALLEL_TEST) -j
+ @EXPECTED="" $(MAKEPARALLEL_TEST)
@EXPECTED="-j1234" $(MAKEPARALLEL_NINJA_TEST) -j1234
@EXPECTED="-j123" $(MAKEPARALLEL_NINJA_TEST) -j123
@@ -87,8 +88,6 @@
@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -j1234 -k
@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -kt -j1234
- @EXPECTED="-j1" $(MAKEPARALLEL_TEST) A=-j1234
- @EXPECTED="-j1" $(MAKEPARALLEL_TEST) A\ -j1234=-j1234
- @EXPECTED="-j1234" $(MAKEPARALLEL_TEST) A\ -j1234=-j1234 -j1234
+ @EXPECTED="" $(MAKEPARALLEL_TEST) A=-j1234
@EXPECTED="-j1234 args" ARGS="args" $(MAKEPARALLEL_TEST) -j1234
diff --git a/tools/makeparallel/makeparallel.cpp b/tools/makeparallel/makeparallel.cpp
index 4ae8f61..0e1e45c 100644
--- a/tools/makeparallel/makeparallel.cpp
+++ b/tools/makeparallel/makeparallel.cpp
@@ -317,20 +317,38 @@
}
}
- std::string jarg = "-j" + std::to_string(tokens + 1);
+ std::string jarg;
+ if (parallel) {
+ if (tokens == 0) {
+ if (ninja) {
+ // ninja is parallel by default
+ jarg = "";
+ } else {
+ // make -j with no argument, guess a reasonable parallelism like ninja does
+ jarg = "-j" + std::to_string(sysconf(_SC_NPROCESSORS_ONLN) + 2);
+ }
+ } else {
+ jarg = "-j" + std::to_string(tokens + 1);
+ }
+ }
+
if (ninja) {
if (!parallel) {
// ninja is parallel by default, pass -j1 to disable parallelism if make wasn't parallel
args.push_back(strdup("-j1"));
- } else if (tokens > 0) {
- args.push_back(strdup(jarg.c_str()));
+ } else {
+ if (jarg != "") {
+ args.push_back(strdup(jarg.c_str()));
+ }
}
if (keep_going) {
args.push_back(strdup("-k0"));
}
} else {
- args.push_back(strdup(jarg.c_str()));
+ if (jarg != "") {
+ args.push_back(strdup(jarg.c_str()));
+ }
}
args.insert(args.end(), &argv[2], &argv[argc]);
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 8309463..c80d4bd 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -43,10 +43,12 @@
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 @@
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 @@
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 @@
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 @@
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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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()
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 1708d86..73cd07e 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -462,6 +462,10 @@
build_command.extend(["-L", prop_dict["mount_point"]])
if "extfs_inode_count" in prop_dict:
build_command.extend(["-i", prop_dict["extfs_inode_count"]])
+ if "flash_erase_block_size" in prop_dict:
+ build_command.extend(["-e", prop_dict["flash_erase_block_size"]])
+ if "flash_logical_block_size" in prop_dict:
+ build_command.extend(["-o", prop_dict["flash_logical_block_size"]])
if "selinux_fc" in prop_dict:
build_command.append(prop_dict["selinux_fc"])
elif fs_type.startswith("squash"):
@@ -665,6 +669,8 @@
copy_prop("fs_type", "fs_type")
copy_prop("userdata_fs_type", "fs_type")
copy_prop("userdata_size", "partition_size")
+ copy_prop("flash_logical_block_size","flash_logical_block_size")
+ copy_prop("flash_erase_block_size", "flash_erase_block_size")
elif mount_point == "cache":
copy_prop("cache_fs_type", "fs_type")
copy_prop("cache_size", "partition_size")
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 4ad30ec..7b3e9ba 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -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 @@
"""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 @@
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 @@
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 @@
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 @@
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 @@
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 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 @@
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 @@
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 @@
"""
def Usage(docstring):
- print docstring.rstrip("\n")
- print COMMON_DOCSTRING
+ print(docstring.rstrip("\n"))
+ print(COMMON_DOCSTRING)
def ParseOptions(argv,
@@ -871,7 +871,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
if found:
break
- print "putting script in", sh_location
+ print("putting script in", sh_location)
output_sink(sh_location, sh)
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 84e0e63..fd98ad2 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -26,10 +26,12 @@
"""
+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 @@
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 @@
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 @@
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)
diff --git a/tools/releasetools/make_recovery_patch.py b/tools/releasetools/make_recovery_patch.py
index 08d1450..7c6007e 100755
--- a/tools/releasetools/make_recovery_patch.py
+++ b/tools/releasetools/make_recovery_patch.py
@@ -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
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 4d5b8b8..bad3f4c 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -75,9 +75,6 @@
-e (--extra_script) <file>
Insert the contents of file at the end of the update script.
- -a (--aslr_mode) <on|off>
- Specify whether to turn on ASLR for the package (on by default).
-
-2 (--two_step)
Generate a 'two-step' OTA package, where recovery is updated
first, so that any changes made to the system partition are done
@@ -121,10 +118,12 @@
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
@@ -148,7 +147,6 @@
OPTIONS.wipe_user_data = False
OPTIONS.downgrade = False
OPTIONS.extra_script = None
-OPTIONS.aslr_mode = True
OPTIONS.worker_threads = multiprocessing.cpu_count() // 2
if OPTIONS.worker_threads == 0:
OPTIONS.worker_threads = 1
@@ -292,14 +290,14 @@
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 +483,11 @@
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 +531,11 @@
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 +1046,8 @@
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 +1093,19 @@
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 +1116,7 @@
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 +1379,7 @@
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 +1391,9 @@
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 +1420,14 @@
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 +1515,7 @@
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 +1717,8 @@
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 +1757,7 @@
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 +1792,9 @@
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 +1820,9 @@
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)
@@ -1987,11 +1985,6 @@
OPTIONS.oem_no_mount = True
elif o in ("-e", "--extra_script"):
OPTIONS.extra_script = a
- elif o in ("-a", "--aslr_mode"):
- if a in ("on", "On", "true", "True", "yes", "Yes"):
- OPTIONS.aslr_mode = True
- else:
- OPTIONS.aslr_mode = False
elif o in ("-t", "--worker_threads"):
if a.isdigit():
OPTIONS.worker_threads = int(a)
@@ -2029,7 +2022,7 @@
return True
args = common.ParseOptions(argv, __doc__,
- extra_opts="b:k:i:d:we:t:a:2o:",
+ extra_opts="b:k:i:d:we:t:2o:",
extra_long_opts=[
"board_config=",
"package_key=",
@@ -2040,7 +2033,6 @@
"downgrade",
"extra_script=",
"worker_threads=",
- "aslr_mode=",
"two_step",
"no_signing",
"block",
@@ -2087,11 +2079,11 @@
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 +2091,20 @@
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 +2117,7 @@
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 +2150,7 @@
# 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 +2164,14 @@
# 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 +2186,7 @@
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 +2197,7 @@
SignOutput(temp_zip_file.name, args[1])
temp_zip_file.close()
- print "done."
+ print("done.")
if __name__ == '__main__':
@@ -2213,9 +2205,7 @@
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()