summaryrefslogtreecommitdiff
path: root/ext4_utils
diff options
context:
space:
mode:
authorDaniel Mentz <danielmentz@google.com>2019-09-10 16:31:53 -0700
committerDaniel Mentz <danielmentz@google.com>2019-09-18 18:14:53 -0700
commit62556d41c784ae86e5ef415f4b9760ab97d90097 (patch)
treeb32ab76df091ff991910c793dcd655de36632691 /ext4_utils
parentf0988974b003b7dee4be811412dfbf1f08fc0b4f (diff)
downloadextras-62556d41c784ae86e5ef415f4b9760ab97d90097.tar.gz
mkuserimg_mke2fs.py: Package mke2fs.conf
Depending on the environment where mkuserimg_mke2fs.py is used, it's difficult to locate the configuration file mke2fs.conf. To avoid potential issues, let's just package mke2fs.conf with mkuserimg_mke2fs.py. Bug: 112937752 Change-Id: I9eb911fc9357e65a666bafd3089461cac8289008
Diffstat (limited to 'ext4_utils')
-rw-r--r--ext4_utils/Android.bp4
-rw-r--r--ext4_utils/mkuserimg_mke2fs.py25
2 files changed, 20 insertions, 9 deletions
diff --git a/ext4_utils/Android.bp b/ext4_utils/Android.bp
index 967af010..4efecf7d 100644
--- a/ext4_utils/Android.bp
+++ b/ext4_utils/Android.bp
@@ -48,6 +48,10 @@ python_binary_host {
"mkuserimg_mke2fs.py",
],
+ data: [
+ "mke2fs.conf",
+ ],
+
version: {
py2: {
enabled: true,
diff --git a/ext4_utils/mkuserimg_mke2fs.py b/ext4_utils/mkuserimg_mke2fs.py
index 538ffaac..4633426b 100644
--- a/ext4_utils/mkuserimg_mke2fs.py
+++ b/ext4_utils/mkuserimg_mke2fs.py
@@ -17,8 +17,10 @@
import argparse
import logging
import os
+import pkgutil
import subprocess
import sys
+import tempfile
def RunCommand(cmd, env):
@@ -212,15 +214,20 @@ def main(argv):
output.truncate()
# run mke2fs
- mke2fs_env = {"MKE2FS_CONFIG" : "./system/extras/ext4_utils/mke2fs.conf"}
- if args.timestamp:
- mke2fs_env["E2FSPROGS_FAKE_TIME"] = args.timestamp
-
- output, ret = RunCommand(mke2fs_cmd, mke2fs_env)
- print(output)
- if ret != 0:
- logging.error("Failed to run mke2fs: " + output)
- sys.exit(4)
+ with tempfile.NamedTemporaryFile() as conf_file:
+ conf_data = pkgutil.get_data('mkuserimg_mke2fs', 'mke2fs.conf')
+ conf_file.write(conf_data)
+ conf_file.flush()
+ mke2fs_env = {"MKE2FS_CONFIG" : conf_file.name}
+
+ if args.timestamp:
+ mke2fs_env["E2FSPROGS_FAKE_TIME"] = args.timestamp
+
+ output, ret = RunCommand(mke2fs_cmd, mke2fs_env)
+ print(output)
+ if ret != 0:
+ logging.error("Failed to run mke2fs: " + output)
+ sys.exit(4)
# run e2fsdroid
e2fsdroid_env = {}