pass blobs to applypatch in incremental OTAs

applypatch now takes patches as blob-valued arguments instead of just
filenames, eliminating the need to unpack all patches to /tmp before
starting to apply them.

Revert the last change I made where sha1_check(read_file(...)) was
substituted for apply_patch_check(...).  apply_patch_check() knows to
check /cache/saved.file if the original source file is missing or has
a bad checksum, which is important if the device loses power or
otherwise restarts during patching.

Change-Id: Ia5b761474b0f809a5a5eed29455b1b145145699e
This commit is contained in:
Doug Zongker
2010-02-22 15:41:53 -08:00
parent 1af09dea7c
commit c8d446bcde
4 changed files with 16 additions and 9 deletions

View File

@@ -111,6 +111,14 @@ class EdifyGenerator(object):
self.script.append("set_progress(%f);" % (frac,))
def PatchCheck(self, filename, *sha1):
"""Check that the given file (or MTD reference) has one of the
given *sha1 hashes, checking the version saved in cache if the
file does not match."""
self.script.append('assert(apply_patch_check("%s"' % (filename,) +
"".join([', "%s"' % (i,) for i in sha1]) +
'));')
def FileCheck(self, filename, *sha1):
"""Check that the given file (or MTD reference) has one of the
given *sha1 hashes."""
self.script.append('assert(sha1_check(read_file("%s")' % (filename,) +
@@ -164,7 +172,7 @@ class EdifyGenerator(object):
cmd = ['apply_patch("%s",\0"%s",\0%s,\0%d'
% (srcfile, tgtfile, tgtsha1, tgtsize)]
for i in range(0, len(patchpairs), 2):
cmd.append(',\0"%s:%s"' % patchpairs[i:i+2])
cmd.append(',\0%s, package_extract_file("%s")' % patchpairs[i:i+2])
cmd.append(');')
cmd = "".join(cmd)
self.script.append(self._WordWrap(cmd))