Searches for debugfs_static in search path

When signing APks on build server, there might not be an android repo.
Usually deapexer.py will be run from otatools.zip after exctration. So
we should look for debugfs_static in search path

Bug: 165347497
Test: Use sign_apk_from_target_files without android repo
Change-Id: Ifaf91764ca0dc08d010f43a24bfe975a07a71e7f
diff --git a/tools/releasetools/apex_utils.py b/tools/releasetools/apex_utils.py
index 3d24310..8783f25 100644
--- a/tools/releasetools/apex_utils.py
+++ b/tools/releasetools/apex_utils.py
@@ -51,6 +51,8 @@
     self.apex_path = apex_path
     self.key_passwords = key_passwords
     self.codename_to_api_level_map = codename_to_api_level_map
+    self.debugfs_path = os.path.join(
+        OPTIONS.search_path, "bin", "debugfs_static")
 
   def ProcessApexFile(self, apk_keys, payload_key, signing_args=None):
     """Scans and signs the apk files and repack the apex
@@ -61,14 +63,13 @@
     Returns:
       The repacked apex file containing the signed apk files.
     """
-    debugfs_path = os.path.join(OPTIONS.search_path, "bin", "debugfs_static")
-    if not os.path.exists(debugfs_path):
+    if not os.path.exists(self.debugfs_path):
       raise ApexSigningError(
           "Couldn't find location of debugfs_static: " +
           "Path {} does not exist. ".format(debugfs_path) +
           "Make sure bin/debugfs_static can be found in -p <path>")
     list_cmd = ['deapexer', '--debugfs_path',
-                debugfs_path, 'list', self.apex_path]
+                self.debugfs_path, 'list', self.apex_path]
     entries_names = common.RunAndCheckOutput(list_cmd).split()
     apk_entries = [name for name in entries_names if name.endswith('.apk')]
 
@@ -98,8 +99,14 @@
 
   def ExtractApexPayloadAndSignApks(self, apk_entries, apk_keys):
     """Extracts the payload image and signs the containing apk files."""
+    if not os.path.exists(self.debugfs_path):
+      raise ApexSigningError(
+          "Couldn't find location of debugfs_static: " +
+          "Path {} does not exist. ".format(debugfs_path) +
+          "Make sure bin/debugfs_static can be found in -p <path>")
     payload_dir = common.MakeTempDir()
-    extract_cmd = ['deapexer', 'extract', self.apex_path, payload_dir]
+    extract_cmd = ['deapexer', '--debugfs_path',
+                   self.debugfs_path, 'extract', self.apex_path, payload_dir]
     common.RunAndCheckOutput(extract_cmd)
 
     has_signed_apk = False