summaryrefslogtreecommitdiff
path: root/ext4_utils
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2020-11-20 03:18:57 +0900
committerJiyong Park <jiyong@google.com>2020-11-20 10:40:55 +0900
commita8dd3b4776cb423bd8365b2328c7c07ed0d8072f (patch)
treec894195073cdb65c4a428271354905cc33d952e0 /ext4_utils
parentbe9534d22b6efcd1a6965986aeaae2cef33e85b1 (diff)
downloadextras-a8dd3b4776cb423bd8365b2328c7c07ed0d8072f.tar.gz
mkuserimg_mke2fs finds its sub tools in the same directory
So far, mkuserimg_mke2fs ran only in the Make world. Now, it will be run in the Soong world via the new android_filesystem module. But the problem is that, when running in Soong, the PATH environment variable doesn't point to the host binary directory (e.g. out/soong/host/linux-x86/bin). This is a problem for this script because sub tools like mke2fs and e2fsdroid have been invoked just by their names expecting that they will be under PATH. To fix this problem, the tool now tries to find the sub tools in the same directory as this script is located at, which would be the host binary directory. Bug: 172414391 Test: m Change-Id: Ia42d0b2533357f20c4dcf1cb7d2587c35165b799
Diffstat (limited to 'ext4_utils')
-rw-r--r--ext4_utils/mkuserimg_mke2fs.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/ext4_utils/mkuserimg_mke2fs.py b/ext4_utils/mkuserimg_mke2fs.py
index 4633426b..d4a14f87 100644
--- a/ext4_utils/mkuserimg_mke2fs.py
+++ b/ext4_utils/mkuserimg_mke2fs.py
@@ -35,6 +35,8 @@ def RunCommand(cmd, env):
env_copy = os.environ.copy()
env_copy.update(env)
+ cmd[0] = FindProgram(cmd[0])
+
logging.info("Env: %s", env)
logging.info("Running: " + " ".join(cmd))
@@ -44,6 +46,21 @@ def RunCommand(cmd, env):
return output, p.returncode
+def FindProgram(prog_name):
+ """Finds the path to prog_name.
+
+ Args:
+ prog_name: the program name to find.
+ Returns:
+ path to the progName if found. The program is searched in the same directory
+ where this script is located at. If not found, progName is returned.
+ """
+ exec_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
+ prog_path = os.path.join(exec_dir, prog_name)
+ if os.path.exists(prog_path):
+ return prog_path
+ else:
+ return prog_name
def ParseArguments(argv):
"""Parses the input arguments to the program."""