From e92f15a85885de8db24b6f2ab536d25cf20a5ca5 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Fri, 26 Aug 2011 13:46:40 -0700 Subject: [PATCH] patch the /system/build.prop file last Works around a problem observed on a retail device: incremental update from build 1 to build 2 partially completed, leaving a mix of files from the two builds. (Why it booted into the regular system instead of recovery to restart update installation is still a mystery.) build.prop was one of the files updated, so the device reported itself as having build 2. The device hobbled along for months in this state, until build 3 was released and the 2-to-3 incremental package repeatedly failed (because some of the files it was trying to patch were build 1). This change makes updating build.prop the very last thing does by an incremental update script, so if installation is aborted and the regular system starts (and works at all), it will continue reporting itself as build 1 and be sent the 1-to-2 OTA package again. Change-Id: I1edc1dcef2bd2495b6fd96517c2f4c574b994f27 --- tools/releasetools/ota_from_target_files | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index aead38f4ec..4264efa4b2 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -613,7 +613,12 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip): so_far = 0 script.Print("Patching system files...") - for fn, tf, sf, size, _ in patch_list: + deferred_patch_list = [] + for item in patch_list: + fn, tf, sf, size, _ = item + if tf.name == "system/build.prop": + deferred_patch_list.append(item) + continue script.ApplyPatch("/"+fn, "-", tf.size, tf.sha1, sf.sha1, "patch/"+fn+".p") so_far += tf.size script.SetProgress(so_far / total_patch_size) @@ -715,6 +720,15 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip): if OPTIONS.extra_script is not None: script.AppendExtra(OPTIONS.extra_script) + # Patch the build.prop file last, so if something fails but the + # device can still come up, it appears to be the old build and will + # get set the OTA package again to retry. + script.Print("Patching remaining system files...") + for item in deferred_patch_list: + fn, tf, sf, size, _ = item + script.ApplyPatch("/"+fn, "-", tf.size, tf.sha1, sf.sha1, "patch/"+fn+".p") + script.SetPermissions("/system/build.prop", 0, 0, 0644) + script.AddToZip(target_zip, output_zip) WriteMetadata(metadata, output_zip)