From fffe1d5e9c65dcb2321643e25d77d465f7763ba6 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 3 May 2012 16:15:29 -0700 Subject: [PATCH] use the file uid/gid/mode saved in the target_files When building a bootable image with mkbootfs, use the set of file metadata that's stored in the target_files zip (when available), rather than whatever is built into the mkbootfs binary at the time the image is built. Bug: 6435132 Change-Id: If6c59149bdbcc9a67e5ab9161398f355bd1f511d --- tools/releasetools/common.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 8196b3c364..5e4055a219 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -196,7 +196,7 @@ def DumpInfoDict(d): for k, v in sorted(d.items()): print "%-25s = (%s) %s" % (k, type(v).__name__, v) -def BuildBootableImage(sourcedir): +def BuildBootableImage(sourcedir, fs_config_file): """Take a kernel, cmdline, and ramdisk directory from the input (in 'sourcedir'), and turn them into a boot image. Return the image data, or None if sourcedir does not appear to contains files for @@ -209,8 +209,11 @@ def BuildBootableImage(sourcedir): ramdisk_img = tempfile.NamedTemporaryFile() img = tempfile.NamedTemporaryFile() - p1 = Run(["mkbootfs", os.path.join(sourcedir, "RAMDISK")], - stdout=subprocess.PIPE) + if os.access(fs_config_file, os.F_OK): + cmd = ["mkbootfs", "-f", fs_config_file, os.path.join(sourcedir, "RAMDISK")] + else: + cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")] + p1 = Run(cmd, stdout=subprocess.PIPE) p2 = Run(["minigzip"], stdin=p1.stdout, stdout=ramdisk_img.file.fileno()) @@ -265,7 +268,9 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir): return File.FromLocalFile(name, prebuilt_path) else: print "building image from target_files %s..." % (tree_subdir,) - return File(name, BuildBootableImage(os.path.join(unpack_dir, tree_subdir))) + fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt" + return File(name, BuildBootableImage(os.path.join(unpack_dir, tree_subdir), + os.path.join(unpack_dir, fs_config))) def UnzipTemp(filename, pattern=None):