ensure blkid and fsck.erofs in deapexer call

BUG: b/255963179, b/240288941
Change-Id: Ibbc119ad6b33dab88bafddcc57abd5972d46cfbc
diff --git a/apexer/Android.bp b/apexer/Android.bp
index fb0ce52..ecf3acd 100644
--- a/apexer/Android.bp
+++ b/apexer/Android.bp
@@ -142,6 +142,8 @@
 apexer_deps_minus_go_tools = apexer_tools + [
     "deapexer",
     "debugfs_static",
+    "blkid",
+    "fsck.erofs",
 ]
 
 apexer_deps_tools = apexer_deps_minus_go_tools + apexer_go_tools
@@ -188,6 +190,8 @@
         "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 25a27c8..e1ade87 100644
--- a/apexer/apexer_test.py
+++ b/apexer/apexer_test.py
@@ -184,7 +184,7 @@
         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 @@
         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 e9d2361..f49ca69 100644
--- a/tools/deapexer.py
+++ b/tools/deapexer.py
@@ -390,8 +390,26 @@
           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)