Enabled incrementals to patch + rename moved files
Change-Id: I551fc5291847e3ace15361c203d86f566c26da97
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 2c3b9e7..426b713 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -184,6 +184,20 @@
cmd = "delete(" + ",\0".join(['"%s"' % (i,) for i in file_list]) + ");"
self.script.append(self._WordWrap(cmd))
+ def RenameFile(self, srcfile, tgtfile):
+ """Moves a file from one location to another."""
+ if self.info.get("update_rename_support", False):
+ self.script.append('rename("%s", "%s");' % (srcfile, tgtfile))
+ else:
+ raise ValueError("Rename not supported by update binary")
+
+ def SkipNextActionIfTargetExists(self, tgtfile, tgtsha1):
+ """Prepend an action with an apply_patch_check in order to
+ skip the action if the file exists. Used when a patch
+ is later renamed."""
+ cmd = ('sha1_check(read_file("%s"), %s) || ' % (tgtfile, tgtsha1))
+ self.script.append(self._WordWrap(cmd))
+
def ApplyPatch(self, srcfile, tgtfile, tgtsize, tgtsha1, *patchpairs):
"""Apply binary patches (in *patchpairs) to the given srcfile to
produce tgtfile (which may be "-" to indicate overwriting the