summaryrefslogtreecommitdiff
path: root/apexer/apexer.py
diff options
context:
space:
mode:
authorHuang Jianan <huangjianan@oppo.com>2021-08-02 15:00:02 +0800
committeralk3pInjection <webmaster@raspii.tech>2021-09-27 21:17:05 +0800
commit190df0bdb26adbc7f654e8945e54180ed0e901e3 (patch)
tree885a3499f06bdcfeb6299c2a21f2712ef3b82fff /apexer/apexer.py
parent81b8907194b55146d7e1a10b824d0202dddaa62f (diff)
Add EROFS support for APEXHEADlineage-18.1
Bug: 195274797 Test: ./apxer/runtests.sh Change-Id: I19019d2809496bfc37eca1964e58a4e04d8bbbe7 Signed-off-by: Huang Jianan <huangjianan@oppo.com>
Diffstat (limited to 'apexer/apexer.py')
-rw-r--r--apexer/apexer.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/apexer/apexer.py b/apexer/apexer.py
index 5d4d5c2..5a5183b 100644
--- a/apexer/apexer.py
+++ b/apexer/apexer.py
@@ -31,6 +31,7 @@ import sys
import tempfile
import uuid
import xml.etree.ElementTree as ET
+import glob
from apex_manifest import ValidateApexManifest
from apex_manifest import ApexManifestError
from manifest import android_ns
@@ -105,8 +106,8 @@ def ParseArgs(argv):
metavar='FS_TYPE',
required=False,
default='ext4',
- choices=['ext4', 'f2fs'],
- help='type of filesystem being used for payload image "ext4" or "f2fs"')
+ choices=['ext4', 'f2fs', 'erofs'],
+ help='type of filesystem being used for payload image "ext4", "f2fs" or "erofs"')
parser.add_argument(
'--override_apk_package_name',
required=False,
@@ -588,6 +589,36 @@ def CreateApex(args, work_dir):
# TODO(b/158453869): resize the image file to save space
+ elif args.payload_fs_type == 'erofs':
+ # mkfs.erofs doesn't support multiple input
+ tmp_input_dir = os.path.join(work_dir, 'tmp_input_dir')
+ os.mkdir(tmp_input_dir)
+ cmd = ['/bin/cp', '-ra']
+ cmd.extend(glob.glob(manifests_dir + '/*'))
+ cmd.extend(glob.glob(args.input_dir + '/*'))
+ cmd.append(tmp_input_dir)
+ RunCommand(cmd, args.verbose)
+
+ cmd = ['make_erofs']
+ cmd.extend(['-z', 'lz4hc'])
+ cmd.extend(['--fs-config-file', args.canned_fs_config])
+ cmd.extend(['--file-contexts', args.file_contexts])
+ uu = str(uuid.uuid5(uuid.NAMESPACE_URL, 'www.android.com'))
+ cmd.extend(['-U', uu])
+ cmd.extend(['-T', '0'])
+ cmd.extend([img_file, tmp_input_dir])
+ RunCommand(cmd, args.verbose)
+ shutil.rmtree(tmp_input_dir)
+
+ # The minimum image size of erofs is 4k, which will cause an error
+ # when execute generate_hash_tree in avbtool
+ cmd = ["/bin/ls", "-lgG", img_file]
+ output, _ = RunCommand(cmd, verbose=False)
+ image_size = int(output.split()[2])
+ if image_size == 4096:
+ cmd = ["/usr/bin/fallocate", "-l", "8k", img_file]
+ RunCommand(cmd, verbose=False)
+
if args.unsigned_payload_only:
shutil.copyfile(img_file, args.output)
if (args.verbose):