diff options
author | Dennis Shen <dzshen@google.com> | 2022-11-04 13:54:08 +0000 |
---|---|---|
committer | Dennis Shen <dzshen@google.com> | 2022-11-14 19:23:38 +0000 |
commit | f02f38419fcd6cf62299f015c18e85626bfabdc5 (patch) | |
tree | 2a9442f072d3e0bae2686e7e1d3162d8578509f2 | |
parent | 3085deffebaab25fd9337c92a8c01cc32640ec54 (diff) | |
download | apex-f02f38419fcd6cf62299f015c18e85626bfabdc5.tar.gz |
ensure blkid and fsck.erofs in deapexer call
BUG: b/255963179, b/240288941
Merged-In: Ibbc119ad6b33dab88bafddcc57abd5972d46cfbc
Change-Id: Ibbc119ad6b33dab88bafddcc57abd5972d46cfbc
(cherry picked from commit f9dad181d5b106900ed518536427fb4143379235)
-rw-r--r-- | apexer/Android.bp | 4 | ||||
-rw-r--r-- | apexer/apexer_test.py | 5 | ||||
-rw-r--r-- | tools/deapexer.py | 22 |
3 files changed, 27 insertions, 4 deletions
diff --git a/apexer/Android.bp b/apexer/Android.bp index 20d6f277..5b72039d 100644 --- a/apexer/Android.bp +++ b/apexer/Android.bp @@ -133,6 +133,8 @@ python_test_host { apexer_deps_minus_go_tools = apexer_tools + [ "deapexer", "debugfs_static", + "blkid", + "fsck.erofs", ] apexer_deps_tools = apexer_deps_minus_go_tools + apexer_go_tools @@ -178,6 +180,8 @@ genrule { "cp $(location fec) $$BIN && " + "cp $(location zipalign) $$BIN && " + "cp $(location debugfs_static) $$BIN && " + + "cp $(location blkid) $$BIN && " + + "cp $(location fsck.erofs) $$BIN && " + "cp $$SIGNAPK_JAR $$BIN && " + "cp $$LIBCPLUSPLUS $$LIB && " + "cp $$LIBCONSCRYPT_OPENJDK_JNI $$LIB && " + diff --git a/apexer/apexer_test.py b/apexer/apexer_test.py index 25a27c8d..e1ade87f 100644 --- a/apexer/apexer_test.py +++ b/apexer/apexer_test.py @@ -184,7 +184,7 @@ class ApexerRebuildTest(unittest.TestCase): files = {} for i in ["apexer", "deapexer", "avbtool", "mke2fs", "sefcontext_compile", "e2fsdroid", "resize2fs", "soong_zip", "aapt2", "merge_zips", "zipalign", "debugfs_static", - "signapk.jar", "android.jar"]: + "signapk.jar", "android.jar", "blkid", "fsck.erofs"]: file_path = os.path.join(dir_name, "bin", i) if os.path.exists(file_path): os.chmod(file_path, stat.S_IRUSR | stat.S_IXUSR); @@ -249,7 +249,8 @@ class ApexerRebuildTest(unittest.TestCase): dir_name = tempfile.mkdtemp(prefix=self._testMethodName+"_extracted_payload_") self._to_cleanup.append(dir_name) cmd = ["deapexer", "--debugfs_path", self.host_tools["debugfs_static"], - "extract", apex_file_path, dir_name] + "--blkid_path",self.host_tools["blkid"], "--fsckerofs_path", + self.host_tools["fsck.erofs"], "extract", apex_file_path, dir_name] run_host_command(cmd) # Remove payload files added by apexer and e2fs tools. diff --git a/tools/deapexer.py b/tools/deapexer.py index e9d23614..f49ca696 100644 --- a/tools/deapexer.py +++ b/tools/deapexer.py @@ -390,8 +390,26 @@ def main(argv): file=sys.stderr) sys.exit(1) - if args.cmd == 'extract' and not args.blkid_path: - args.blkid_path = shutil.which('blkid') + if args.cmd == 'extract': + if not args.blkid_path: + print('ANDROID_HOST_OUT environment variable is not defined, --blkid_path must be set', + file=sys.stderr) + sys.exit(1) + + if not os.path.isfile(args.blkid_path): + print(f'Cannot find blkid specified at {args.blkid_path}', + file=sys.stderr) + sys.exit(1) + + if not args.fsckerofs_path: + print('ANDROID_HOST_OUT environment variable is not defined, --fsckerofs_path must be set', + file=sys.stderr) + sys.exit(1) + + if not os.path.isfile(args.fsckerofs_path): + print(f'Cannot find fsck.erofs specified at {args.fsckerofs_path}', + file=sys.stderr) + sys.exit(1) args.func(args) |