Skip to content
Browse files

add -w option to ota_from_target_files

Add option to make OTA packages that wipe user data.
  • Loading branch information...
1 parent 8dda455 commit 660a88168feab1d75cd89b038b7d49eb65c76e23 Doug Zongker committed with cyanogen
Showing with 17 additions and 5 deletions.
  1. +17 −5 tools/releasetools/ota_from_target_files
View
22 tools/releasetools/ota_from_target_files
@@ -33,6 +33,10 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package
Generate an incremental OTA using the given target-files zip as
the starting build.
+ -w (--wipe_user_data)
+ Generate an OTA package that will wipe the user data partition
+ when installed.
+
"""
import sys
@@ -58,6 +62,7 @@ OPTIONS.incremental_source = None
OPTIONS.require_verbatim = set()
OPTIONS.prohibit_verbatim = set(("system/build.prop",))
OPTIONS.patch_threshold = 0.95
+OPTIONS.wipe_user_data = False
def MostPopularKey(d, default):
"""Given a dict, return the key corresponding to the largest
@@ -334,6 +339,9 @@ def WriteFullOTAPackage(input_zip, output_zip):
script.append("write_radio_image PACKAGE:radio.img")
script.append("show_progress 0.5 0")
+ if OPTIONS.wipe_user_data:
+ script.append("format DATA:")
+
script.append("format SYSTEM:")
script.append("copy_dir PACKAGE:system SYSTEM:")
@@ -542,6 +550,9 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
script.append("\n# ---- start making changes here\n")
+ if OPTIONS.wipe_user_data:
+ script.append("format DATA:")
+
DeleteFiles(script, [SubstituteRoot(i[0]) for i in verbatim_targets])
if updating_boot:
@@ -641,21 +652,22 @@ def main(argv):
def option_handler(o, a):
if o in ("-b", "--board_config"):
common.LoadBoardConfig(a)
- return True
elif o in ("-k", "--package_key"):
OPTIONS.package_key = a
- return True
elif o in ("-i", "--incremental_from"):
OPTIONS.incremental_source = a
- return True
+ elif o in ("-w", "--wipe_user_data"):
+ OPTIONS.wipe_user_data = True
else:
return False
+ return True
args = common.ParseOptions(argv, __doc__,
- extra_opts="b:k:i:d:",
+ extra_opts="b:k:i:d:w",
extra_long_opts=["board_config=",
"package_key=",
- "incremental_from="],
+ "incremental_from=",
+ "wipe_user_data"],
extra_option_handler=option_handler)
if len(args) != 2:

0 comments on commit 660a881

Please sign in to comment.
Something went wrong with that request. Please try again.