relocate applypatch; check patch integrity
- Delete the applypatch code (it's being moved to bootable/recovery).
- Change the OTA script generator to verify the sha1sum of all the
patch files after they are unpacked into /tmp.
b/2361316 - VZW Issue PP628: Continuous reset to Droid logo:
framework-res.apk update failed (CR LIBtt59130)
Change-Id: I5858d48f10127f72e708d50d3de844569d1aff27
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 64bd547..900bad1 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -113,7 +113,7 @@
def PatchCheck(self, filename, *sha1):
"""Check that the given file (or MTD reference) has one of the
given *sha1 hashes."""
- self.script.append('assert(apply_patch_check("%s"' % (filename,) +
+ self.script.append('assert(sha1_check(read_file("%s")' % (filename,) +
"".join([', "%s"' % (i,) for i in sha1]) +
'));')
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 920ce8f..1e3f9a3 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -627,7 +627,7 @@
verbatim_targets.append((tf.name, tf.size))
else:
common.ZipWriteStr(output_zip, "patch/" + tf.name + ".p", d)
- patch_list.append((tf.name, tf, sf, tf.size))
+ patch_list.append((tf.name, tf, sf, tf.size, sha.sha(d).hexdigest()))
largest_source_size = max(largest_source_size, sf.size)
source_fp = GetBuildProp("ro.build.fingerprint", source_zip)
@@ -669,7 +669,7 @@
total_verify_size += source_boot.size
so_far = 0
- for fn, tf, sf, size in patch_list:
+ for fn, tf, sf, size, patch_sha in patch_list:
script.PatchCheck("/"+fn, tf.sha1, sf.sha1)
so_far += sf.size
script.SetProgress(so_far / total_verify_size)
@@ -693,6 +693,9 @@
script.Print("Unpacking patches...")
script.UnpackPackageDir("patch", "/tmp/patchtmp")
+ for fn, tf, sf, size, patch_sha in patch_list:
+ script.PatchCheck("/tmp/patchtmp/" + tf.name + ".p", patch_sha)
+
device_specific.IncrementalOTA_VerifyEnd()
script.Comment("---- start making changes here ----")
@@ -714,7 +717,7 @@
so_far = 0
script.Print("Patching system files...")
- for fn, tf, sf, size in patch_list:
+ for fn, tf, sf, size, _ in patch_list:
script.ApplyPatch("/"+fn, "-", tf.size, tf.sha1,
sf.sha1, "/tmp/patchtmp/"+fn+".p")
so_far += tf.size