Loading core/Makefile +2 −1 Original line number Diff line number Diff line Loading @@ -1135,7 +1135,8 @@ DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \ $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \ $(HOST_OUT_EXECUTABLES)/make_ext4fs \ $(HOST_OUT_EXECUTABLES)/simg2img \ $(HOST_OUT_EXECUTABLES)/e2fsck $(HOST_OUT_EXECUTABLES)/e2fsck \ $(HOST_OUT_EXECUTABLES)/xdelta3 OTATOOLS := $(DISTTOOLS) \ $(HOST_OUT_EXECUTABLES)/aapt Loading tools/releasetools/build_image.py +9 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import sys import commands import shutil import simg_map def RunCommand(cmd): """ Echo and run the given command Loading Loading @@ -146,6 +148,13 @@ def UnsparseImage(sparse_image_path, replace=True): return False, None return True, unsparse_image_path def MappedUnsparseImage(sparse_image_path, unsparse_image_path, map_path, mapped_unsparse_image_path): if simg_map.ComputeMap(sparse_image_path, unsparse_image_path, map_path, mapped_unsparse_image_path): return False return True def MakeVerityEnabledImage(out_file, prop_dict): """Creates an image that is verifiable using dm-verity. Loading tools/releasetools/common.py +1 −1 Original line number Diff line number Diff line Loading @@ -1015,7 +1015,7 @@ def MakeSystemPatch(source_file, target_file): with open(output_file.name + ".xz") as patch_file: patch_data = patch_file.read() os.unlink(patch_file.name) return File("system.img.p", patch_data) return File("system.muimg.p", patch_data) def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img, info_dict=None): Loading tools/releasetools/edify_generator.py +23 −6 Original line number Diff line number Diff line Loading @@ -190,6 +190,16 @@ class EdifyGenerator(object): (p.fs_type, common.PARTITION_TYPES[p.fs_type], p.device, p.length, p.mount_point)) def WipeBlockDevice(self, partition): if partition != "/system": raise ValueError(("WipeBlockDevice currently only works " "on /system, not %s\n") % (partition,)) fstab = self.info.get("fstab", None) size = self.info.get("system_size", None) device = fstab[partition].device self.script.append('wipe_block_device("%s", %s);' % (device, size)) def DeleteFiles(self, file_list): """Delete all files in file_list.""" if not file_list: return Loading Loading @@ -224,7 +234,7 @@ class EdifyGenerator(object): cmd = "".join(cmd) self.script.append(self._WordWrap(cmd)) def WriteRawImage(self, mount_point, fn): def WriteRawImage(self, mount_point, fn, mapfn=None): """Write the given package file into the partition for the given mount point.""" Loading @@ -238,6 +248,11 @@ class EdifyGenerator(object): 'write_raw_image(package_extract_file("%(fn)s"), "%(device)s");' % args) elif partition_type == "EMMC": if mapfn: args["map"] = mapfn self.script.append( 'package_extract_file("%(fn)s", "%(device)s", "%(map)s");' % args) else: self.script.append( 'package_extract_file("%(fn)s", "%(device)s");' % args) else: Loading Loading @@ -309,7 +324,9 @@ class EdifyGenerator(object): common.ZipWriteStr(output_zip, "META-INF/com/google/android/update-binary", data, perms=0755) def Syspatch(self, filename, size, target_sha, source_sha, patchfile): def Syspatch(self, filename, target_mapfile, target_sha, source_mapfile, source_sha, patchfile): """Applies a compressed binary patch to a block device.""" call = 'syspatch("%s", "%s", "%s", "%s", "%s");' self.script.append(call % (filename, size, target_sha, source_sha, patchfile)) call = 'syspatch("%s", "%s", "%s", "%s", "%s", "%s");' self.script.append(call % (filename, target_mapfile, target_sha, source_mapfile, source_sha, patchfile)) tools/releasetools/img_from_target_files.py +21 −2 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ def AddSystem(output_zip, sparse=True): common.ZipWriteStr(output_zip, "system.img", data) def BuildSystem(input_dir, info_dict, sparse=True): def BuildSystem(input_dir, info_dict, sparse=True, map_file=None): print "creating system.img..." img = tempfile.NamedTemporaryFile() Loading @@ -87,6 +87,8 @@ def BuildSystem(input_dir, info_dict, sparse=True): image_props, img.name) assert succ, "build system.img image failed" mapdata = None if sparse: img.seek(os.SEEK_SET, 0) data = img.read() Loading @@ -95,13 +97,30 @@ def BuildSystem(input_dir, info_dict, sparse=True): success, name = build_image.UnsparseImage(img.name, replace=False) if not success: assert False, "unsparsing system.img failed" if map_file: mmap = tempfile.NamedTemporaryFile() mimg = tempfile.NamedTemporaryFile(delete=False) success = build_image.MappedUnsparseImage( img.name, name, mmap.name, mimg.name) if not success: assert False, "creating sparse map failed" os.unlink(name) name = mimg.name with open(mmap.name) as f: mapdata = f.read() try: with open(name) as f: data = f.read() finally: os.unlink(name) if mapdata is None: return data else: return mapdata, data def AddVendor(output_zip): Loading Loading
core/Makefile +2 −1 Original line number Diff line number Diff line Loading @@ -1135,7 +1135,8 @@ DISTTOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \ $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \ $(HOST_OUT_EXECUTABLES)/make_ext4fs \ $(HOST_OUT_EXECUTABLES)/simg2img \ $(HOST_OUT_EXECUTABLES)/e2fsck $(HOST_OUT_EXECUTABLES)/e2fsck \ $(HOST_OUT_EXECUTABLES)/xdelta3 OTATOOLS := $(DISTTOOLS) \ $(HOST_OUT_EXECUTABLES)/aapt Loading
tools/releasetools/build_image.py +9 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import sys import commands import shutil import simg_map def RunCommand(cmd): """ Echo and run the given command Loading Loading @@ -146,6 +148,13 @@ def UnsparseImage(sparse_image_path, replace=True): return False, None return True, unsparse_image_path def MappedUnsparseImage(sparse_image_path, unsparse_image_path, map_path, mapped_unsparse_image_path): if simg_map.ComputeMap(sparse_image_path, unsparse_image_path, map_path, mapped_unsparse_image_path): return False return True def MakeVerityEnabledImage(out_file, prop_dict): """Creates an image that is verifiable using dm-verity. Loading
tools/releasetools/common.py +1 −1 Original line number Diff line number Diff line Loading @@ -1015,7 +1015,7 @@ def MakeSystemPatch(source_file, target_file): with open(output_file.name + ".xz") as patch_file: patch_data = patch_file.read() os.unlink(patch_file.name) return File("system.img.p", patch_data) return File("system.muimg.p", patch_data) def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img, info_dict=None): Loading
tools/releasetools/edify_generator.py +23 −6 Original line number Diff line number Diff line Loading @@ -190,6 +190,16 @@ class EdifyGenerator(object): (p.fs_type, common.PARTITION_TYPES[p.fs_type], p.device, p.length, p.mount_point)) def WipeBlockDevice(self, partition): if partition != "/system": raise ValueError(("WipeBlockDevice currently only works " "on /system, not %s\n") % (partition,)) fstab = self.info.get("fstab", None) size = self.info.get("system_size", None) device = fstab[partition].device self.script.append('wipe_block_device("%s", %s);' % (device, size)) def DeleteFiles(self, file_list): """Delete all files in file_list.""" if not file_list: return Loading Loading @@ -224,7 +234,7 @@ class EdifyGenerator(object): cmd = "".join(cmd) self.script.append(self._WordWrap(cmd)) def WriteRawImage(self, mount_point, fn): def WriteRawImage(self, mount_point, fn, mapfn=None): """Write the given package file into the partition for the given mount point.""" Loading @@ -238,6 +248,11 @@ class EdifyGenerator(object): 'write_raw_image(package_extract_file("%(fn)s"), "%(device)s");' % args) elif partition_type == "EMMC": if mapfn: args["map"] = mapfn self.script.append( 'package_extract_file("%(fn)s", "%(device)s", "%(map)s");' % args) else: self.script.append( 'package_extract_file("%(fn)s", "%(device)s");' % args) else: Loading Loading @@ -309,7 +324,9 @@ class EdifyGenerator(object): common.ZipWriteStr(output_zip, "META-INF/com/google/android/update-binary", data, perms=0755) def Syspatch(self, filename, size, target_sha, source_sha, patchfile): def Syspatch(self, filename, target_mapfile, target_sha, source_mapfile, source_sha, patchfile): """Applies a compressed binary patch to a block device.""" call = 'syspatch("%s", "%s", "%s", "%s", "%s");' self.script.append(call % (filename, size, target_sha, source_sha, patchfile)) call = 'syspatch("%s", "%s", "%s", "%s", "%s", "%s");' self.script.append(call % (filename, target_mapfile, target_sha, source_mapfile, source_sha, patchfile))
tools/releasetools/img_from_target_files.py +21 −2 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ def AddSystem(output_zip, sparse=True): common.ZipWriteStr(output_zip, "system.img", data) def BuildSystem(input_dir, info_dict, sparse=True): def BuildSystem(input_dir, info_dict, sparse=True, map_file=None): print "creating system.img..." img = tempfile.NamedTemporaryFile() Loading @@ -87,6 +87,8 @@ def BuildSystem(input_dir, info_dict, sparse=True): image_props, img.name) assert succ, "build system.img image failed" mapdata = None if sparse: img.seek(os.SEEK_SET, 0) data = img.read() Loading @@ -95,13 +97,30 @@ def BuildSystem(input_dir, info_dict, sparse=True): success, name = build_image.UnsparseImage(img.name, replace=False) if not success: assert False, "unsparsing system.img failed" if map_file: mmap = tempfile.NamedTemporaryFile() mimg = tempfile.NamedTemporaryFile(delete=False) success = build_image.MappedUnsparseImage( img.name, name, mmap.name, mimg.name) if not success: assert False, "creating sparse map failed" os.unlink(name) name = mimg.name with open(mmap.name) as f: mapdata = f.read() try: with open(name) as f: data = f.read() finally: os.unlink(name) if mapdata is None: return data else: return mapdata, data def AddVendor(output_zip): Loading