Introduce EROFS compress hints to the Android build system

Make it possible to provide a prebuilt hints file to specify different compression strategies on a file basis for all partitions using:

BOARD_EROFS_COMPRESS_HINTS := <path>/erofs-hints.txt

or separately for every partition using:

BOARD_SYSTEMIMAGE_EROFS_COMPRESS_HINTS := <path>/system-partition-erofs-hints.txt
BOARD_VENDORIMAGE_EROFS_COMPRESS_HINTS := <path>/vendor-partition-erofs-hints.txt

Hints format: Each line is defined by tokens separated by spaces in the following form:

<pcluster-in-bytes> <match-pattern>

pcluster-in-bytes can be specified as 0 which mean file will not be compressed

Bug: 231934752
Test: used dump.erofs -S system.img to verify the system image isn't compressed after specifying BOARD_SYSTEMIMAGE_EROFS_COMPRESS_HINTS := no-compress.txt, where no-compress.txt contains 0 .*
Test: used dump.erofs --nid=<inode-for-all-apk-files> vendor.img to verify apk files are not compressed (the rest of the partition content is compressed)
Test: used dump.erofs -S <all-images> to verify all images are not compressed after specifying BOARD_EROFS_COMPRESS_HINTS := <path>/no-compress.txt
Change-Id: I64054e26af5ea5781c45d2183b7796a9ad2b7927
This commit is contained in:
Dmitrii Merkurev
2022-05-17 23:10:37 +00:00
parent d528b3c553
commit 8ab6603a43
2 changed files with 12 additions and 0 deletions

View File

@@ -331,6 +331,14 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config):
if compressor:
build_command.extend(["-z", compressor])
compress_hints = None
if "erofs_default_compress_hints" in prop_dict:
compress_hints = prop_dict["erofs_default_compress_hints"]
if "erofs_compress_hints" in prop_dict:
compress_hints = prop_dict["erofs_compress_hints"]
if compress_hints:
build_command.extend(["--compress-hints", compress_hints])
build_command.extend(["--mount-point", prop_dict["mount_point"]])
if target_out:
build_command.extend(["--product-out", target_out])
@@ -652,6 +660,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
common_props = (
"extfs_sparse_flag",
"erofs_default_compressor",
"erofs_default_compress_hints",
"erofs_pcluster_size",
"erofs_share_dup_blocks",
"erofs_sparse_flag",
@@ -706,6 +715,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
(True, "{}_base_fs_file", "base_fs_file"),
(True, "{}_disable_sparse", "disable_sparse"),
(True, "{}_erofs_compressor", "erofs_compressor"),
(True, "{}_erofs_compress_hints", "erofs_compress_hints"),
(True, "{}_erofs_pcluster_size", "erofs_pcluster_size"),
(True, "{}_erofs_share_dup_blocks", "erofs_share_dup_blocks"),
(True, "{}_extfs_inode_count", "extfs_inode_count"),