applypatch changes for patching recovery image
Make some changes needed to applypatch in order to store the recovery
image in the system partition as a binary patch relative to the boot
image:
- make applypatch use shared libraries, so it's smaller. It will
need to be on the main system so it can install the recovery
image. Make an applypatch_static binary for use in recovery
packages (still needed for updating cupcake devices to donut).
- output the results of patching to an in-memory buffer and write
that to the partition; there's no convenient /tmp for us to us.
(This should be basically a no-op in recovery, since /tmp is a
ramdisk anyway.)
diff --git a/tools/releasetools/amend_generator.py b/tools/releasetools/amend_generator.py
index 8341599..3e8af13 100644
--- a/tools/releasetools/amend_generator.py
+++ b/tools/releasetools/amend_generator.py
@@ -94,13 +94,13 @@
for i in sha1:
out.append(" " + i)
self.script.append("".join(out))
- self.included_files.add("applypatch")
+ self.included_files.add(("applypatch_static", "applypatch"))
def CacheFreeSpaceCheck(self, amount):
"""Check that there's at least 'amount' space that can be made
available on /cache."""
self.script.append("run_program PACKAGE:applypatch -s %d" % (amount,))
- self.included_files.add("applypatch")
+ self.included_files.add(("applypatch_static", "applypatch"))
def Mount(self, kind, what, path):
# no-op; amend uses it's 'roots' system to automatically mount
@@ -155,7 +155,7 @@
(srcfile, tgtfile, tgtsha1, tgtsize)) +
" ".join(["%s:%s" % patchpairs[i:i+2]
for i in range(0, len(patchpairs), 2)]))
- self.included_files.add("applypatch")
+ self.included_files.add(("applypatch_static", "applypatch"))
def WriteFirmwareImage(self, kind, fn):
"""Arrange to update the given firmware image (kind must be
@@ -195,11 +195,16 @@
common.ZipWriteStr(output_zip, "META-INF/com/google/android/update-script",
"\n".join(self.script) + "\n")
for i in self.included_files:
+ if isinstance(i, tuple):
+ sourcefn, targetfn = i
+ else:
+ sourcefn = i
+ targetfn = i
try:
if input_path is None:
- data = input_zip.read(os.path.join("OTA/bin", i))
+ data = input_zip.read(os.path.join("OTA/bin", sourcefn))
else:
- data = open(os.path.join(input_path, i)).read()
- common.ZipWriteStr(output_zip, i, data, perms=0755)
+ data = open(os.path.join(input_path, sourcefn)).read()
+ common.ZipWriteStr(output_zip, targetfn, data, perms=0755)
except (IOError, KeyError), e:
raise ExternalError("unable to include binary %s: %s" % (i, e))