Merge changes from topic "board_partition_reserved_size"
* changes:
build_image.py recognize BOARD_PRODUCT_SERVICESIMAGE_PARTITION_RESERVED_SIZE
build_image.py recognize BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE
diff --git a/core/Makefile b/core/Makefile
index 549d1ab..c46d6d7 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1285,7 +1285,7 @@
$(hide) echo "recovery_as_boot=true" >> $(1))
$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
$(hide) echo "system_root_image=true" >> $(1)
- $(hide) echo "ramdisk_dir=$(TARGET_ROOT_OUT)" >> $(1))
+ $(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1))
$(if $(USE_LOGICAL_PARTITIONS),$(hide) echo "use_logical_partitions=true" >> $(1))
$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
endef
diff --git a/target/board/BoardConfigEmuCommon.mk b/target/board/BoardConfigEmuCommon.mk
index 1d58eab..e8a562a 100644
--- a/target/board/BoardConfigEmuCommon.mk
+++ b/target/board/BoardConfigEmuCommon.mk
@@ -11,9 +11,6 @@
BOARD_USES_GENERIC_AUDIO := true
TARGET_BOOTLOADER_BOARD_NAME := goldfish_$(TARGET_ARCH)
-TARGET_USES_64_BIT_BINDER := true
-TARGET_USES_MKE2FS := true
-
# no hardware camera
USE_CAMERA_STUB := true
@@ -29,22 +26,14 @@
USE_OPENGL_RENDERER := true
TARGET_COPY_OUT_VENDOR := vendor
+
# ~100 MB vendor image. Please adjust system image / vendor image sizes
# when finalizing them.
BOARD_VENDORIMAGE_PARTITION_SIZE := 100000000
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_FLASH_BLOCK_SIZE := 512
-TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
DEVICE_MATRIX_FILE := device/generic/goldfish/compatibility_matrix.xml
-# Android generic system image always create metadata partition
-BOARD_USES_METADATA_PARTITION := true
-
-# Set this to create /cache mount point for non-A/B devices that mounts /cache.
-# The partition size doesn't matter, just to make build pass.
-BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
-BOARD_CACHEIMAGE_PARTITION_SIZE := 16777216
-
BOARD_SEPOLICY_DIRS += device/generic/goldfish/sepolicy/common
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
diff --git a/target/board/BoardConfigGsiCommon.mk b/target/board/BoardConfigGsiCommon.mk
index 237cd28..24614de 100644
--- a/target/board/BoardConfigGsiCommon.mk
+++ b/target/board/BoardConfigGsiCommon.mk
@@ -3,6 +3,13 @@
# Common compile-time definitions for GSI
#
+# system.img is always ext4 with sparse option
+TARGET_USERIMAGES_USE_EXT4 := true
+# TODO(b/63790380): emulator doesn't support sparse yet
+#TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+TARGET_USES_MKE2FS := true
+
# Android Verified Boot (AVB):
# Builds a special vbmeta.img that disables AVB verification.
# Otherwise, AVB will prevent the device from booting the generic system.img.
@@ -20,9 +27,20 @@
endif
BOARD_VNDK_VERSION := current
-# Pi GSI supports system-as-root
+# system-as-root is mandatory from Android P
TARGET_NO_RECOVERY := true
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
+# 64 bits binder interface is mandatory from Android P
+TARGET_USES_64_BIT_BINDER := true
+
+# Android generic system image always create metadata partition
+BOARD_USES_METADATA_PARTITION := true
+
+# Set this to create /cache mount point for non-A/B devices that mounts /cache.
+# The partition size doesn't matter, just to make build pass.
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_CACHEIMAGE_PARTITION_SIZE := 16777216
+
# Audio: must using XML format for Treblized devices
USE_XML_AUDIO_POLICY_CONF := 1
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 38d294b..8113ae3 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -48,7 +48,6 @@
include build/make/target/board/BoardConfigEmuCommon.mk
include build/make/target/board/BoardConfigGsiCommon.mk
-TARGET_USERIMAGES_USE_EXT4 := true
# Partition size is default 1.5GB (1536MB) for 64 bits projects
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736
BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index caf0cee..ad6d229 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -55,7 +55,6 @@
include build/make/target/board/BoardConfigEmuCommon.mk
include build/make/target/board/BoardConfigGsiCommon.mk
-TARGET_USERIMAGES_USE_EXT4 := true
# Partition size is default 1.5GB (1536MB) for 64 bits projects
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736
BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index 9a45188..c8ba2cf 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -23,6 +23,5 @@
include build/make/target/board/BoardConfigEmuCommon.mk
include build/make/target/board/BoardConfigGsiCommon.mk
-TARGET_USERIMAGES_USE_EXT4 := true
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2684354560
BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
diff --git a/target/board/generic_x86_64/BoardConfig.mk b/target/board/generic_x86_64/BoardConfig.mk
index a24263d..1bae7f8 100755
--- a/target/board/generic_x86_64/BoardConfig.mk
+++ b/target/board/generic_x86_64/BoardConfig.mk
@@ -27,6 +27,5 @@
include build/make/target/board/BoardConfigEmuCommon.mk
include build/make/target/board/BoardConfigGsiCommon.mk
-TARGET_USERIMAGES_USE_EXT4 := true
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2684354560 # 2.5 GB
BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
diff --git a/target/product/aosp_arm.mk b/target/product/aosp_arm.mk
index 8c8f407..a052b3a 100644
--- a/target/product/aosp_arm.mk
+++ b/target/product/aosp_arm.mk
@@ -14,6 +14,13 @@
# limitations under the License.
#
+# The system image of aosp_arm-userdebug is a GSI for the devices with:
+# - ARM 32 bits user space
+# - 64 bits binder interface
+# - system-as-root
+# - VNDK enforcement
+# - compatible property override enabled
+
PRODUCT_PROPERTY_OVERRIDES += \
rild.libpath=/vendor/lib/libreference-ril.so
@@ -27,6 +34,13 @@
include $(SRC_TARGET_DIR)/product/full.mk
+# Enable A/B update
+AB_OTA_UPDATER := true
+AB_OTA_PARTITIONS := system
+PRODUCT_PACKAGES += \
+ update_engine \
+ update_verifier
+
# Needed by Pi newly launched device to pass VtsTrebleSysProp on GSI
PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE := true
diff --git a/target/product/aosp_arm64.mk b/target/product/aosp_arm64.mk
index aeff3f0..efbc300 100644
--- a/target/product/aosp_arm64.mk
+++ b/target/product/aosp_arm64.mk
@@ -14,6 +14,13 @@
# limitations under the License.
#
+# The system image of aosp_arm64-userdebug is a GSI for the devices with:
+# - ARM 64 bits user space
+# - 64 bits binder interface
+# - system-as-root
+# - VNDK enforcement
+# - compatible property override enabled
+
PRODUCT_PROPERTY_OVERRIDES += \
rild.libpath=/vendor/lib64/libreference-ril.so
@@ -44,6 +51,13 @@
include $(SRC_TARGET_DIR)/product/emulator.mk
+# Enable A/B update
+AB_OTA_UPDATER := true
+AB_OTA_PARTITIONS := system
+PRODUCT_PACKAGES += \
+ update_engine \
+ update_verifier
+
# Needed by Pi newly launched device to pass VtsTrebleSysProp on GSI
PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE := true
diff --git a/target/product/aosp_arm64_ab.mk b/target/product/aosp_arm64_ab.mk
index c96cb91..d389c74 100644
--- a/target/product/aosp_arm64_ab.mk
+++ b/target/product/aosp_arm64_ab.mk
@@ -19,8 +19,14 @@
# on the generic system image, place them in build/make/target/board/
# treble_system.prop.
+# aosp_arm64_ab-userdebug is a Legacy GSI for the devices with:
+# - ARM 64 bits user space
+# - 64 bits binder interface
+# - system-as-root
+
include build/make/target/product/treble_common_64.mk
+# Enable A/B update
AB_OTA_UPDATER := true
AB_OTA_PARTITIONS := system
PRODUCT_PACKAGES += \
diff --git a/target/product/aosp_arm_ab.mk b/target/product/aosp_arm_ab.mk
index 98b2f99..5845d3b 100644
--- a/target/product/aosp_arm_ab.mk
+++ b/target/product/aosp_arm_ab.mk
@@ -19,8 +19,14 @@
# on the generic system image, place them in build/make/target/board/
# treble_system.prop.
+# aosp_arm_ab-userdebug is a Legacy GSI for the devices with:
+# - ARM 32 bits user space
+# - 32 bits binder interface
+# - system-as-root
+
include build/make/target/product/treble_common_32.mk
+# Enable A/B update
AB_OTA_UPDATER := true
AB_OTA_PARTITIONS := system
PRODUCT_PACKAGES += \
diff --git a/target/product/aosp_x86.mk b/target/product/aosp_x86.mk
index b044149..7929a3e 100644
--- a/target/product/aosp_x86.mk
+++ b/target/product/aosp_x86.mk
@@ -14,6 +14,13 @@
# limitations under the License.
#
+# The system image of aosp_x86-userdebug is a GSI for the devices with:
+# - x86 32 bits user space
+# - 64 bits binder interface
+# - system-as-root
+# - VNDK enforcement
+# - compatible property override enabled
+
PRODUCT_PROPERTY_OVERRIDES += \
rild.libpath=/vendor/lib/libreference-ril.so
@@ -28,6 +35,13 @@
include $(SRC_TARGET_DIR)/product/full_x86.mk
+# Enable A/B update
+AB_OTA_UPDATER := true
+AB_OTA_PARTITIONS := system
+PRODUCT_PACKAGES += \
+ update_engine \
+ update_verifier
+
# Needed by Pi newly launched device to pass VtsTrebleSysProp on GSI
PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE := true
diff --git a/target/product/aosp_x86_64.mk b/target/product/aosp_x86_64.mk
index 4d2589e..5a934a9 100644
--- a/target/product/aosp_x86_64.mk
+++ b/target/product/aosp_x86_64.mk
@@ -14,6 +14,13 @@
# limitations under the License.
#
+# The system image of aosp_x86_64-userdebug is a GSI for the devices with:
+# - x86 64 bits user space
+# - 64 bits binder interface
+# - system-as-root
+# - VNDK enforcement
+# - compatible property override enabled
+
PRODUCT_PROPERTY_OVERRIDES += \
rild.libpath=/vendor/lib64/libreference-ril.so
@@ -41,6 +48,13 @@
include $(SRC_TARGET_DIR)/product/emulator.mk
+# Enable A/B update
+AB_OTA_UPDATER := true
+AB_OTA_PARTITIONS := system
+PRODUCT_PACKAGES += \
+ update_engine \
+ update_verifier
+
# Needed by Pi newly launched device to pass VtsTrebleSysProp on GSI
PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE := true
diff --git a/target/product/aosp_x86_64_ab.mk b/target/product/aosp_x86_64_ab.mk
index 4590dc5..d9163d7 100644
--- a/target/product/aosp_x86_64_ab.mk
+++ b/target/product/aosp_x86_64_ab.mk
@@ -19,8 +19,14 @@
# on the generic system image, place them in build/make/target/board/
# treble_system.prop.
+# aosp_x86_64_ab-userdebug is a Legacy GSI for the devices with:
+# - x86 64 bits user space
+# - 64 bits binder interface
+# - system-as-root
+
include build/make/target/product/treble_common_64.mk
+# Enable A/B update
AB_OTA_UPDATER := true
AB_OTA_PARTITIONS := system
PRODUCT_PACKAGES += \
diff --git a/target/product/aosp_x86_ab.mk b/target/product/aosp_x86_ab.mk
index 404a4da..4fff3d1 100644
--- a/target/product/aosp_x86_ab.mk
+++ b/target/product/aosp_x86_ab.mk
@@ -19,8 +19,14 @@
# on the generic system image, place them in build/make/target/board/
# treble_system.prop.
+# aosp_x86_ab-userdebug is a Legacy GSI for the devices with:
+# - x86 32 bits user space
+# - 32 bits binder interface
+# - system-as-root
+
include build/make/target/product/treble_common_32.mk
+# Enable A/B update
AB_OTA_UPDATER := true
AB_OTA_PARTITIONS := system
PRODUCT_PACKAGES += \
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 8b3f857..3311e3d 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -290,7 +290,10 @@
procrank \
showmap \
sqlite3 \
- strace
+ strace \
+ unwind_info \
+ unwind_reg_info \
+ unwind_symbols \
# The set of packages whose code can be loaded by the system server.
PRODUCT_SYSTEM_SERVER_APPS += \
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index e82e66a..c7d93d3 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -163,7 +163,7 @@
def RangeSha1(self, ranges):
h = sha1()
- for data in self._GetRangeData(ranges):
+ for data in self._GetRangeData(ranges): # pylint: disable=not-an-iterable
h.update(data)
return h.hexdigest()
@@ -177,7 +177,7 @@
return sha1(self.data).hexdigest()
def WriteRangeDataToFd(self, ranges, fd):
- for data in self._GetRangeData(ranges):
+ for data in self._GetRangeData(ranges): # pylint: disable=not-an-iterable
fd.write(data)
@@ -320,46 +320,45 @@
print(''.join([' {}\n'.format(name) for name in values]))
-# BlockImageDiff works on two image objects. An image object is
-# anything that provides the following attributes:
-#
-# blocksize: the size in bytes of a block, currently must be 4096.
-#
-# total_blocks: the total size of the partition/image, in blocks.
-#
-# care_map: a RangeSet containing which blocks (in the range [0,
-# total_blocks) we actually care about; i.e. which blocks contain
-# data.
-#
-# file_map: a dict that partitions the blocks contained in care_map
-# into smaller domains that are useful for doing diffs on.
-# (Typically a domain is a file, and the key in file_map is the
-# pathname.)
-#
-# clobbered_blocks: a RangeSet containing which blocks contain data
-# but may be altered by the FS. They need to be excluded when
-# verifying the partition integrity.
-#
-# ReadRangeSet(): a function that takes a RangeSet and returns the
-# data contained in the image blocks of that RangeSet. The data
-# is returned as a list or tuple of strings; concatenating the
-# elements together should produce the requested data.
-# Implementations are free to break up the data into list/tuple
-# elements in any way that is convenient.
-#
-# RangeSha1(): a function that returns (as a hex string) the SHA-1
-# hash of all the data in the specified range.
-#
-# TotalSha1(): a function that returns (as a hex string) the SHA-1
-# hash of all the data in the image (ie, all the blocks in the
-# care_map minus clobbered_blocks, or including the clobbered
-# blocks if include_clobbered_blocks is True).
-#
-# When creating a BlockImageDiff, the src image may be None, in which
-# case the list of transfers produced will never read from the
-# original image.
-
class BlockImageDiff(object):
+ """Generates the diff of two block image objects.
+
+ BlockImageDiff works on two image objects. An image object is anything that
+ provides the following attributes:
+
+ blocksize: the size in bytes of a block, currently must be 4096.
+
+ total_blocks: the total size of the partition/image, in blocks.
+
+ care_map: a RangeSet containing which blocks (in the range [0,
+ total_blocks) we actually care about; i.e. which blocks contain data.
+
+ file_map: a dict that partitions the blocks contained in care_map into
+ smaller domains that are useful for doing diffs on. (Typically a domain
+ is a file, and the key in file_map is the pathname.)
+
+ clobbered_blocks: a RangeSet containing which blocks contain data but may
+ be altered by the FS. They need to be excluded when verifying the
+ partition integrity.
+
+ ReadRangeSet(): a function that takes a RangeSet and returns the data
+ contained in the image blocks of that RangeSet. The data is returned as
+ a list or tuple of strings; concatenating the elements together should
+ produce the requested data. Implementations are free to break up the
+ data into list/tuple elements in any way that is convenient.
+
+ RangeSha1(): a function that returns (as a hex string) the SHA-1 hash of
+ all the data in the specified range.
+
+ TotalSha1(): a function that returns (as a hex string) the SHA-1 hash of
+ all the data in the image (ie, all the blocks in the care_map minus
+ clobbered_blocks, or including the clobbered blocks if
+ include_clobbered_blocks is True).
+
+ When creating a BlockImageDiff, the src image may be None, in which case the
+ list of transfers produced will never read from the original image.
+ """
+
def __init__(self, tgt, src=None, threads=None, version=4,
disable_imgdiff=False):
if threads is None:
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 6336e68..fc3eb2c 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -483,7 +483,7 @@
True iff the image is built successfully.
"""
# system_root_image=true: build a system.img that combines the contents of
- # /system and the ramdisk, and can be mounted at the root of the file system.
+ # /system and root, which should be mounted at the root of the file system.
origin_in = in_dir
fs_config = prop_dict.get("fs_config")
if (prop_dict.get("system_root_image") == "true" and
@@ -492,12 +492,12 @@
# Change the mount point to "/".
prop_dict["mount_point"] = "/"
if fs_config:
- # We need to merge the fs_config files of system and ramdisk.
- merged_fs_config = common.MakeTempFile(prefix="root_fs_config",
+ # We need to merge the fs_config files of system and root.
+ merged_fs_config = common.MakeTempFile(prefix="merged_fs_config",
suffix=".txt")
with open(merged_fs_config, "w") as fw:
- if "ramdisk_fs_config" in prop_dict:
- with open(prop_dict["ramdisk_fs_config"]) as fr:
+ if "root_fs_config" in prop_dict:
+ with open(prop_dict["root_fs_config"]) as fr:
fw.writelines(fr.readlines())
with open(fs_config) as fr:
fw.writelines(fr.readlines())
@@ -645,10 +645,10 @@
if in_dir != origin_in:
# Construct a staging directory of the root file system.
- ramdisk_dir = prop_dict.get("ramdisk_dir")
- if ramdisk_dir:
+ root_dir = prop_dict.get("root_dir")
+ if root_dir:
shutil.rmtree(in_dir)
- shutil.copytree(ramdisk_dir, in_dir, symlinks=True)
+ shutil.copytree(root_dir, in_dir, symlinks=True)
staging_system = os.path.join(in_dir, "system")
shutil.rmtree(staging_system, ignore_errors=True)
shutil.copytree(origin_in, staging_system, symlinks=True)
@@ -790,8 +790,8 @@
d["journal_size"] = "0"
copy_prop("system_verity_block_device", "verity_block_device")
copy_prop("system_root_image", "system_root_image")
- copy_prop("ramdisk_dir", "ramdisk_dir")
- copy_prop("ramdisk_fs_config", "ramdisk_fs_config")
+ copy_prop("root_dir", "root_dir")
+ copy_prop("root_fs_config", "root_fs_config")
copy_prop("ext4_share_dup_blocks", "ext4_share_dup_blocks")
copy_prop("system_squashfs_compressor", "squashfs_compressor")
copy_prop("system_squashfs_compressor_opt", "squashfs_compressor_opt")
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 3dbffc7..5b5e6ed 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -44,7 +44,7 @@
"darwin": "out/host/darwin-x86",
}
- self.search_path = platform_search_path.get(sys.platform, None)
+ self.search_path = platform_search_path.get(sys.platform)
self.signapk_path = "framework/signapk.jar" # Relative to search_path
self.signapk_shared_library_path = "lib64" # Relative to search_path
self.extra_signapk_args = []
@@ -196,10 +196,10 @@
if fc_config:
d["selinux_fc"] = fc_config
- # Similarly we need to redirect "ramdisk_dir" and "ramdisk_fs_config".
+ # Similarly we need to redirect "root_dir" and "root_fs_config".
if d.get("system_root_image") == "true":
- d["ramdisk_dir"] = os.path.join(input_dir, "ROOT")
- d["ramdisk_fs_config"] = os.path.join(
+ d["root_dir"] = os.path.join(input_dir, "ROOT")
+ d["root_fs_config"] = os.path.join(
input_dir, "META", "root_filesystem_config.txt")
# Redirect {system,vendor}_base_fs_file.
@@ -237,15 +237,15 @@
makeint("boot_size")
makeint("fstab_version")
- system_root_image = d.get("system_root_image", None) == "true"
- if d.get("no_recovery", None) != "true":
+ system_root_image = d.get("system_root_image") == "true"
+ if d.get("no_recovery") != "true":
recovery_fstab_path = "RECOVERY/RAMDISK/etc/recovery.fstab"
- d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"],
- recovery_fstab_path, system_root_image)
- elif d.get("recovery_as_boot", None) == "true":
+ d["fstab"] = LoadRecoveryFSTab(
+ read_helper, d["fstab_version"], recovery_fstab_path, system_root_image)
+ elif d.get("recovery_as_boot") == "true":
recovery_fstab_path = "BOOT/RAMDISK/etc/recovery.fstab"
- d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"],
- recovery_fstab_path, system_root_image)
+ d["fstab"] = LoadRecoveryFSTab(
+ read_helper, d["fstab_version"], recovery_fstab_path, system_root_image)
else:
d["fstab"] = None
@@ -441,11 +441,11 @@
cmd.append("--pagesize")
cmd.append(open(fn).read().rstrip("\n"))
- args = info_dict.get("mkbootimg_args", None)
+ args = info_dict.get("mkbootimg_args")
if args and args.strip():
cmd.extend(shlex.split(args))
- args = info_dict.get("mkbootimg_version_args", None)
+ args = info_dict.get("mkbootimg_version_args")
if args and args.strip():
cmd.extend(shlex.split(args))
@@ -453,7 +453,7 @@
cmd.extend(["--ramdisk", ramdisk_img.name])
img_unsigned = None
- if info_dict.get("vboot", None):
+ if info_dict.get("vboot"):
img_unsigned = tempfile.NamedTemporaryFile()
cmd.extend(["--output", img_unsigned.name])
else:
@@ -471,8 +471,8 @@
p.communicate()
assert p.returncode == 0, "mkbootimg of %s image failed" % (partition_name,)
- if (info_dict.get("boot_signer", None) == "true" and
- info_dict.get("verity_key", None)):
+ if (info_dict.get("boot_signer") == "true" and
+ info_dict.get("verity_key")):
# Hard-code the path as "/boot" for two-step special recovery image (which
# will be loaded into /boot during the two-step OTA).
if two_step_image:
@@ -489,7 +489,7 @@
assert p.returncode == 0, "boot_signer of %s image failed" % path
# Sign the image if vboot is non-empty.
- elif info_dict.get("vboot", None):
+ elif info_dict.get("vboot"):
path = "/" + partition_name
img_keyblock = tempfile.NamedTemporaryFile()
# We have switched from the prebuilt futility binary to using the tool
@@ -578,9 +578,9 @@
def Gunzip(in_filename, out_filename):
- """Gunzip the given gzip compressed file to a given output file.
- """
- with gzip.open(in_filename, "rb") as in_file, open(out_filename, "wb") as out_file:
+ """Gunzips the given gzip compressed file to a given output file."""
+ with gzip.open(in_filename, "rb") as in_file, \
+ open(out_filename, "wb") as out_file:
shutil.copyfileobj(in_file, out_file)
@@ -734,7 +734,7 @@
devnull.close()
key_passwords.update(PasswordManager().GetPasswords(need_passwords))
- key_passwords.update(dict.fromkeys(no_passwords, None))
+ key_passwords.update(dict.fromkeys(no_passwords))
return key_passwords
@@ -799,8 +799,7 @@
def SignFile(input_name, output_name, key, password, min_api_level=None,
- codename_to_api_level_map=dict(),
- whole_file=False):
+ codename_to_api_level_map=None, whole_file=False):
"""Sign the input_name zip/jar/apk, producing output_name. Use the
given key and password (the latter may be None if the key does not
have a password.
@@ -816,6 +815,8 @@
codename_to_api_level_map is needed to translate the codename which may be
encountered as the APK's minSdkVersion.
"""
+ if codename_to_api_level_map is None:
+ codename_to_api_level_map = {}
java_library_path = os.path.join(
OPTIONS.search_path, OPTIONS.signapk_shared_library_path)
@@ -877,7 +878,7 @@
device = p.device
if "/" in device:
device = device[device.rfind("/")+1:]
- limit = info_dict.get(device + "_size", None)
+ limit = info_dict.get(device + "_size")
if not fs_type or not limit:
return
@@ -1107,8 +1108,8 @@
class PasswordManager(object):
def __init__(self):
- self.editor = os.getenv("EDITOR", None)
- self.pwfile = os.getenv("ANDROID_PW_FILE", None)
+ self.editor = os.getenv("EDITOR")
+ self.pwfile = os.getenv("ANDROID_PW_FILE")
def GetPasswords(self, items):
"""Get passwords corresponding to each string in 'items',
@@ -1358,7 +1359,7 @@
module does not define the function, return the value of the
'default' kwarg (which itself defaults to None)."""
if self.module is None or not hasattr(self.module, function_name):
- return kwargs.get("default", None)
+ return kwargs.get("default")
return getattr(self.module, function_name)(*((self,) + args), **kwargs)
def FullOTA_Assertions(self):
@@ -1408,8 +1409,9 @@
def VerifyOTA_Assertions(self):
return self._DoCall("VerifyOTA_Assertions")
+
class File(object):
- def __init__(self, name, data, compress_size = None):
+ def __init__(self, name, data, compress_size=None):
self.name = name
self.data = data
self.size = len(data)
@@ -1436,6 +1438,7 @@
def AddToZip(self, z, compression=None):
ZipWriteStr(z, self.name, self.data, compress_type=compression)
+
DIFF_PROGRAM_BY_EXT = {
".gz" : "imgdiff",
".zip" : ["imgdiff", "-z"],
@@ -1444,6 +1447,7 @@
".img" : "imgdiff",
}
+
class Difference(object):
def __init__(self, tf, sf, diff_program=None):
self.tf = tf
@@ -1511,9 +1515,11 @@
def GetPatch(self):
- """Return a tuple (target_file, source_file, patch_data).
+ """Returns a tuple of (target_file, source_file, patch_data).
+
patch_data may be None if ComputePatch hasn't been called, or if
- computing the patch failed."""
+ computing the patch failed.
+ """
return self.tf, self.sf, self.patch
@@ -1545,7 +1551,8 @@
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))
@@ -1598,7 +1605,8 @@
def required_cache(self):
return self._required_cache
- def WriteScript(self, script, output_zip, progress=None):
+ def WriteScript(self, script, output_zip, progress=None,
+ write_verify_script=False):
if not self.src:
# write the output unconditionally
script.Print("Patching %s image unconditionally..." % (self.partition,))
@@ -1608,7 +1616,8 @@
if progress:
script.ShowProgress(progress, 0)
self._WriteUpdate(script, output_zip)
- if OPTIONS.verify:
+
+ if write_verify_script:
self._WritePostInstallVerifyScript(script)
def WriteStrictVerifyScript(self, script):
@@ -1622,12 +1631,12 @@
script.Print("Verifying %s..." % (partition,))
ranges = self.tgt.care_map
ranges_str = ranges.to_string_raw()
- script.AppendExtra('range_sha1("%s", "%s") == "%s" && '
- 'ui_print(" Verified.") || '
- 'ui_print("\\"%s\\" has unexpected contents.");' % (
- self.device, ranges_str,
- self.tgt.TotalSha1(include_clobbered_blocks=True),
- self.device))
+ script.AppendExtra(
+ 'range_sha1("%s", "%s") == "%s" && ui_print(" Verified.") || '
+ 'ui_print("\\"%s\\" has unexpected contents.");' % (
+ self.device, ranges_str,
+ self.tgt.TotalSha1(include_clobbered_blocks=True),
+ self.device))
script.AppendExtra("")
def WriteVerifyScript(self, script, touched_blocks_only=False):
@@ -1651,12 +1660,12 @@
return
ranges_str = ranges.to_string_raw()
- script.AppendExtra(('if (range_sha1("%s", "%s") == "%s" || '
- 'block_image_verify("%s", '
- 'package_extract_file("%s.transfer.list"), '
- '"%s.new.dat", "%s.patch.dat")) then') % (
- self.device, ranges_str, expected_sha1,
- self.device, partition, partition, partition))
+ script.AppendExtra(
+ 'if (range_sha1("%s", "%s") == "%s" || block_image_verify("%s", '
+ 'package_extract_file("%s.transfer.list"), "%s.new.dat", '
+ '"%s.patch.dat")) then' % (
+ self.device, ranges_str, expected_sha1,
+ self.device, partition, partition, partition))
script.Print('Verified %s image...' % (partition,))
script.AppendExtra('else')
@@ -1706,17 +1715,19 @@
# Unlike pre-install verification, clobbered_blocks should not be ignored.
ranges = self.tgt.care_map
ranges_str = ranges.to_string_raw()
- script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % (
- self.device, ranges_str,
- self.tgt.TotalSha1(include_clobbered_blocks=True)))
+ script.AppendExtra(
+ 'if range_sha1("%s", "%s") == "%s" then' % (
+ self.device, ranges_str,
+ self.tgt.TotalSha1(include_clobbered_blocks=True)))
# Bug: 20881595
# Verify that extended blocks are really zeroed out.
if self.tgt.extended:
ranges_str = self.tgt.extended.to_string_raw()
- script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % (
- self.device, ranges_str,
- self._HashZeroBlocks(self.tgt.extended.size())))
+ script.AppendExtra(
+ 'if range_sha1("%s", "%s") == "%s" then' % (
+ self.device, ranges_str,
+ self._HashZeroBlocks(self.tgt.extended.size())))
script.Print('Verified the updated %s image.' % (partition,))
if partition == "system":
code = ErrorCode.SYSTEM_NONZERO_CONTENTS
@@ -1746,9 +1757,9 @@
'{}.transfer.list'.format(self.path),
'{}.transfer.list'.format(self.partition))
- # For full OTA, compress the new.dat with brotli with quality 6 to reduce its size. Quailty 9
- # almost triples the compression time but doesn't further reduce the size too much.
- # For a typical 1.8G system.new.dat
+ # For full OTA, compress the new.dat with brotli with quality 6 to reduce
+ # its size. Quailty 9 almost triples the compression time but doesn't
+ # further reduce the size too much. For a typical 1.8G system.new.dat
# zip | brotli(quality 6) | brotli(quality 9)
# compressed_size: 942M | 869M (~8% reduced) | 854M
# compression_time: 75s | 265s | 719s
@@ -1813,6 +1824,7 @@
DataImage = blockimgdiff.DataImage
+
# map recovery.fstab's fs_types to mount/format "partition types"
PARTITION_TYPES = {
"ext4": "EMMC",
@@ -1821,6 +1833,7 @@
"squashfs": "EMMC"
}
+
def GetTypeAndDevice(mount_point, info):
fstab = info["fstab"]
if fstab:
@@ -1915,7 +1928,7 @@
if os.path.exists(path):
diff_program.append("-b")
diff_program.append(path)
- bonus_args = "-b /system/etc/recovery-resource.dat"
+ bonus_args = "--bonus /system/etc/recovery-resource.dat"
else:
bonus_args = ""
@@ -1933,8 +1946,12 @@
if full_recovery_image:
sh = """#!/system/bin/sh
-if ! applypatch -c %(type)s:%(device)s:%(size)d:%(sha1)s; then
- applypatch /system/etc/recovery.img %(type)s:%(device)s %(sha1)s %(size)d && log -t recovery "Installing new recovery image: succeeded" || log -t recovery "Installing new recovery image: failed"
+if ! applypatch --check %(type)s:%(device)s:%(size)d:%(sha1)s; then
+ applypatch \\
+ --flash /system/etc/recovery.img \\
+ --target %(type)s:%(device)s:%(size)d:%(sha1)s && \\
+ log -t recovery "Installing new recovery image: succeeded" || \\
+ log -t recovery "Installing new recovery image: failed"
else
log -t recovery "Recovery image already installed"
fi
@@ -1944,8 +1961,13 @@
'size': recovery_img.size}
else:
sh = """#!/system/bin/sh
-if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then
- applypatch %(bonus_args)s %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s %(recovery_type)s:%(recovery_device)s %(recovery_sha1)s %(recovery_size)d %(boot_sha1)s:/system/recovery-from-boot.p && log -t recovery "Installing new recovery image: succeeded" || log -t recovery "Installing new recovery image: failed"
+if ! applypatch --check %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then
+ applypatch %(bonus_args)s \\
+ --patch /system/recovery-from-boot.p \\
+ --source %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s \\
+ --target %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s && \\
+ log -t recovery "Installing new recovery image: succeeded" || \\
+ log -t recovery "Installing new recovery image: failed"
else
log -t recovery "Recovery image already installed"
fi
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 5c3533e..3595a9e 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -132,8 +132,8 @@
self.script.append(
('(!less_than_int(%s, getprop("ro.build.date.utc"))) || '
'abort("E%d: Can\'t install this package (%s) over newer '
- 'build (" + getprop("ro.build.date") + ").");') % (timestamp,
- common.ErrorCode.OLDER_BUILD, timestamp_text))
+ 'build (" + getprop("ro.build.date") + ").");') % (
+ timestamp, common.ErrorCode.OLDER_BUILD, timestamp_text))
def AssertDevice(self, device):
"""Assert that the device identifier is the given string."""
@@ -260,8 +260,8 @@
cmd.append(',\0%s,\0package_extract_file("%s")' % patchpairs[i:i+2])
cmd.append(') ||\n abort("E%d: Failed to apply patch to %s");' % (
common.ErrorCode.APPLY_PATCH_FAILURE, srcfile))
- cmd = "".join(cmd)
- self.script.append(self.WordWrap(cmd))
+ cmd_str = "".join(cmd)
+ self.script.append(self.WordWrap(cmd_str))
def WriteRawImage(self, mount_point, fn, mapfn=None):
"""Write the given package file into the partition for the given
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index e6e8c9f..01ff149 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -28,17 +28,17 @@
from __future__ import print_function
+import os
+import shutil
import sys
+import zipfile
+
+import common
if sys.hexversion < 0x02070000:
print("Python 2.7 or newer is required.", file=sys.stderr)
sys.exit(1)
-import os
-import shutil
-import zipfile
-
-import common
OPTIONS = common.OPTIONS
@@ -51,11 +51,12 @@
def main(argv):
- bootable_only = [False]
+ # This allows modifying the value from inner function.
+ bootable_only_array = [False]
def option_handler(o, _):
if o in ("-z", "--bootable_zip"):
- bootable_only[0] = True
+ bootable_only_array[0] = True
else:
return False
return True
@@ -65,7 +66,7 @@
extra_long_opts=["bootable_zip"],
extra_option_handler=option_handler)
- bootable_only = bootable_only[0]
+ bootable_only = bootable_only_array[0]
if len(args) != 2:
common.Usage(__doc__)
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index b9c410f..8cfe4c3 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -827,7 +827,8 @@
allow_shared_blocks)
system_tgt.ResetFileMap()
system_diff = common.BlockDifference("system", system_tgt, src=None)
- system_diff.WriteScript(script, output_zip)
+ system_diff.WriteScript(script, output_zip,
+ write_verify_script=OPTIONS.verify)
boot_img = common.GetBootableImage(
"boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
@@ -839,7 +840,8 @@
allow_shared_blocks)
vendor_tgt.ResetFileMap()
vendor_diff = common.BlockDifference("vendor", vendor_tgt)
- vendor_diff.WriteScript(script, output_zip)
+ vendor_diff.WriteScript(script, output_zip,
+ write_verify_script=OPTIONS.verify)
AddCompatibilityArchiveIfTrebleEnabled(input_zip, output_zip, target_info)
@@ -1559,10 +1561,12 @@
device_specific.IncrementalOTA_InstallBegin()
system_diff.WriteScript(script, output_zip,
- progress=0.8 if vendor_diff else 0.9)
+ progress=0.8 if vendor_diff else 0.9,
+ write_verify_script=OPTIONS.verify)
if vendor_diff:
- vendor_diff.WriteScript(script, output_zip, progress=0.1)
+ vendor_diff.WriteScript(script, output_zip, progress=0.1,
+ write_verify_script=OPTIONS.verify)
if OPTIONS.two_step:
common.ZipWriteStr(output_zip, "boot.img", target_boot.data)
diff --git a/tools/releasetools/pylintrc b/tools/releasetools/pylintrc
index 7b3405c..2a30742 100644
--- a/tools/releasetools/pylintrc
+++ b/tools/releasetools/pylintrc
@@ -62,7 +62,7 @@
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
-disable=invalid-name,missing-docstring,too-many-branches,too-many-locals,too-many-arguments,too-many-statements,duplicate-code,too-few-public-methods,too-many-instance-attributes,too-many-lines,too-many-public-methods,locally-disabled,fixme
+disable=invalid-name,missing-docstring,too-many-branches,too-many-locals,too-many-arguments,too-many-statements,duplicate-code,too-few-public-methods,too-many-instance-attributes,too-many-lines,too-many-public-methods,locally-disabled,fixme,not-callable
[REPORTS]
diff --git a/tools/releasetools/validate_target_files.py b/tools/releasetools/validate_target_files.py
index 886de26..4e40b86 100755
--- a/tools/releasetools/validate_target_files.py
+++ b/tools/releasetools/validate_target_files.py
@@ -131,14 +131,18 @@
1. full recovery:
...
- if ! applypatch -c type:device:size:SHA-1; then
- applypatch /system/etc/recovery.img type:device sha1 size && ...
+ if ! applypatch --check type:device:size:sha1; then
+ applypatch --flash /system/etc/recovery.img \\
+ type:device:size:sha1 && \\
...
2. recovery from boot:
...
- applypatch [-b bonus_args] boot_info recovery_info recovery_sha1 \
- recovery_size patch_info && ...
+ if ! applypatch --check type:recovery_device:recovery_size:recovery_sha1; then
+ applypatch [--bonus bonus_args] \\
+ --patch /system/recovery-from-boot.p \\
+ --source type:boot_device:boot_size:boot_sha1 \\
+ --target type:recovery_device:recovery_size:recovery_sha1 && \\
...
For full recovery, we want to calculate the SHA-1 of /system/etc/recovery.img
@@ -155,44 +159,63 @@
logging.info('Checking %s', script_path)
with open(os.path.join(input_tmp, script_path), 'r') as script:
lines = script.read().strip().split('\n')
- assert len(lines) >= 6
- check_cmd = re.search(r'if ! applypatch -c \w+:.+:\w+:(\w+);',
+ assert len(lines) >= 10
+ check_cmd = re.search(r'if ! applypatch --check (\w+:.+:\w+:\w+);',
lines[1].strip())
- expected_recovery_check_sha1 = check_cmd.group(1)
- patch_cmd = re.search(r'(applypatch.+)&&', lines[2].strip())
- applypatch_argv = patch_cmd.group(1).strip().split()
+ check_partition = check_cmd.group(1)
+ assert len(check_partition.split(':')) == 4
full_recovery_image = info_dict.get("full_recovery_image") == "true"
if full_recovery_image:
- assert len(applypatch_argv) == 5
- # Check we have the same expected SHA-1 of recovery.img in both check mode
- # and patch mode.
- expected_recovery_sha1 = applypatch_argv[3].strip()
- assert expected_recovery_check_sha1 == expected_recovery_sha1
- ValidateFileAgainstSha1(input_tmp, 'recovery.img',
- 'SYSTEM/etc/recovery.img', expected_recovery_sha1)
- else:
- # We're patching boot.img to get recovery.img where bonus_args is optional
- if applypatch_argv[1] == "-b":
- assert len(applypatch_argv) == 8
- boot_info_index = 3
- else:
- assert len(applypatch_argv) == 6
- boot_info_index = 1
+ assert len(lines) == 10, "Invalid line count: {}".format(lines)
- # boot_info: boot_type:boot_device:boot_size:boot_sha1
- boot_info = applypatch_argv[boot_info_index].strip().split(':')
- assert len(boot_info) == 4
+ # Expect something like "EMMC:/dev/block/recovery:28:5f9c..62e3".
+ target = re.search(r'--target (.+) &&', lines[4].strip())
+ assert target is not None, \
+ "Failed to parse target line \"{}\"".format(lines[4])
+ flash_partition = target.group(1)
+
+ # Check we have the same recovery target in the check and flash commands.
+ assert check_partition == flash_partition, \
+ "Mismatching targets: {} vs {}".format(check_partition, flash_partition)
+
+ # Validate the SHA-1 of the recovery image.
+ recovery_sha1 = flash_partition.split(':')[3]
+ ValidateFileAgainstSha1(
+ input_tmp, 'recovery.img', 'SYSTEM/etc/recovery.img', recovery_sha1)
+ else:
+ assert len(lines) == 11, "Invalid line count: {}".format(lines)
+
+ # --source boot_type:boot_device:boot_size:boot_sha1
+ source = re.search(r'--source (\w+:.+:\w+:\w+) \\', lines[4].strip())
+ assert source is not None, \
+ "Failed to parse source line \"{}\"".format(lines[4])
+
+ source_partition = source.group(1)
+ source_info = source_partition.split(':')
+ assert len(source_info) == 4, \
+ "Invalid source partition: {}".format(source_partition)
ValidateFileAgainstSha1(input_tmp, file_name='boot.img',
file_path='IMAGES/boot.img',
- expected_sha1=boot_info[3])
+ expected_sha1=source_info[3])
- recovery_sha1_index = boot_info_index + 2
- expected_recovery_sha1 = applypatch_argv[recovery_sha1_index]
- assert expected_recovery_check_sha1 == expected_recovery_sha1
+ # --target recovery_type:recovery_device:recovery_size:recovery_sha1
+ target = re.search(r'--target (\w+:.+:\w+:\w+) && \\', lines[5].strip())
+ assert target is not None, \
+ "Failed to parse target line \"{}\"".format(lines[5])
+ target_partition = target.group(1)
+
+ # Check we have the same recovery target in the check and patch commands.
+ assert check_partition == target_partition, \
+ "Mismatching targets: {} vs {}".format(
+ check_partition, target_partition)
+
+ recovery_info = target_partition.split(':')
+ assert len(recovery_info) == 4, \
+ "Invalid target partition: {}".format(target_partition)
ValidateFileAgainstSha1(input_tmp, file_name='recovery.img',
file_path='IMAGES/recovery.img',
- expected_sha1=expected_recovery_sha1)
+ expected_sha1=recovery_info[3])
logging.info('Done checking %s', script_path)
diff --git a/tools/warn.py b/tools/warn.py
index 89f4778..4596307 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -75,6 +75,7 @@
# emit_js_data():
import argparse
+import cgi
import csv
import multiprocessing
import os
@@ -3149,6 +3150,14 @@
print '];'
+# Emit a JavaScript const string array for HTML.
+def emit_const_html_string_array(name, array):
+ print 'const ' + name + ' = ['
+ for s in array:
+ print '"' + cgi.escape(strip_escape_string(s)) + '",'
+ print '];'
+
+
# Emit a JavaScript const object array.
def emit_const_object_array(name, array):
print 'const ' + name + ' = ['
@@ -3167,11 +3176,11 @@
emit_const_string_array('ProjectNames', project_names)
emit_const_int_array('WarnPatternsSeverity',
[w['severity'] for w in warn_patterns])
- emit_const_string_array('WarnPatternsDescription',
- [w['description'] for w in warn_patterns])
- emit_const_string_array('WarnPatternsOption',
- [w['option'] for w in warn_patterns])
- emit_const_string_array('WarningMessages', warning_messages)
+ emit_const_html_string_array('WarnPatternsDescription',
+ [w['description'] for w in warn_patterns])
+ emit_const_html_string_array('WarnPatternsOption',
+ [w['option'] for w in warn_patterns])
+ emit_const_html_string_array('WarningMessages', warning_messages)
emit_const_object_array('Warnings', warning_records)
draw_table_javascript = """