diff options
author | Tao Bao <tbao@google.com> | 2015-09-03 21:17:37 -0700 |
---|---|---|
committer | Tao Bao <tbao@google.com> | 2015-09-03 21:21:55 -0700 |
commit | a77d41e2f7021d11e8bcb863f3e331d5d92ba6a1 (patch) | |
tree | 90cbb35d16a873d87c374216214d910123c4cfa8 | |
parent | c6c9c61d05ffcc41239baaa1f3011b17e8518b65 (diff) | |
download | build-a77d41e2f7021d11e8bcb863f3e331d5d92ba6a1.tar.gz |
releasetools: Fix the bug when deleting files.
For file-based OTAs, we used to remove unneeded files in ascending
order, which failed to delete non-empty directories. Reverse the order
to fix the issue.
For example, now we have the following in our generated script:
delete("/system/app/Calculator/arm/Calculator.odex",
"/system/app/Calculator/arm/",
"/system/app/Calculator/Calculator.apk",
"/system/app/Calculator/");
Bug: 22960996
Change-Id: I0d36d29b7862fb53bf55bf5685a990180f9c0b3b
-rwxr-xr-x | tools/releasetools/ota_from_target_files.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index 7a11ba664b..d686004a96 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -1072,11 +1072,13 @@ class FileDifference(object): script.FileCheck(tf.name, tf.sha1) def RemoveUnneededFiles(self, script, extras=()): - script.DeleteFiles( - ["/" + i[0] for i in self.verbatim_targets] + - ["/" + i for i in sorted(self.source_data) - if i not in self.target_data and i not in self.renames] + - list(extras)) + file_list = ["/" + i[0] for i in self.verbatim_targets] + file_list += ["/" + i for i in self.source_data + if i not in self.target_data and i not in self.renames] + file_list += list(extras) + # Sort the list in descending order, which removes all the files first + # before attempting to remove the folder. (Bug: 22960996) + script.DeleteFiles(sorted(file_list, reverse=True)) def TotalPatchSize(self): return sum(i[1].size for i in self.patch_list) |