diff options
Diffstat (limited to 'tools/releasetools/edify_generator.py')
-rw-r--r-- | tools/releasetools/edify_generator.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index 566e687..a52e328 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -243,6 +243,15 @@ class EdifyGenerator(object): cmd = "delete(" + ",\0".join(['"%s"' % (i,) for i in file_list]) + ");" self.script.append(self.WordWrap(cmd)) + def DeleteFilesIfNotMatching(self, file_list): + """Delete the file in file_list if not matching the checksum.""" + if not file_list: + return + for name, sha1 in file_list: + cmd = ('sha1_check(read_file("{name}"), "{sha1}") || ' + 'delete("{name}");'.format(name=name, sha1=sha1)) + 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): @@ -254,7 +263,7 @@ class EdifyGenerator(object): """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)) + cmd = ('sha1_check(read_file("%s"), %s) ||' % (tgtfile, tgtsha1)) self.script.append(self.WordWrap(cmd)) def ApplyPatch(self, srcfile, tgtfile, tgtsize, tgtsha1, *patchpairs): |