summaryrefslogtreecommitdiffstats
path: root/tools/releasetools
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2010-04-21 14:08:44 -0700
committerDoug Zongker <dougz@android.com>2010-09-03 11:58:31 -0700
commitc637db16d83b2c248b1cf0122e2ba558ed95762c (patch)
treefa7e6711ffe037d975b8e510a121d5ddc2346b29 /tools/releasetools
parentc5b8d4ceb63909e5f0811fa80dca205996fd8644 (diff)
downloadbuild-c637db16d83b2c248b1cf0122e2ba558ed95762c.zip
build-c637db16d83b2c248b1cf0122e2ba558ed95762c.tar.gz
build-c637db16d83b2c248b1cf0122e2ba558ed95762c.tar.bz2
remove remaining amend support
Remove the remaining (unused and untested) support for generating amend scripts. This means that you won't be able to OTA directly from cupcake to gingerbread. Change-Id: Iaf5295db92a42b336960d05295f48b67cb729337
Diffstat (limited to 'tools/releasetools')
-rw-r--r--tools/releasetools/amend_generator.py222
-rw-r--r--tools/releasetools/both_generator.py62
-rwxr-xr-xtools/releasetools/ota_from_target_files46
3 files changed, 9 insertions, 321 deletions
diff --git a/tools/releasetools/amend_generator.py b/tools/releasetools/amend_generator.py
deleted file mode 100644
index b543bf7..0000000
--- a/tools/releasetools/amend_generator.py
+++ /dev/null
@@ -1,222 +0,0 @@
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-
-import common
-
-class AmendGenerator(object):
- """Class to generate scripts in the 'amend' recovery script language
- used up through cupcake."""
-
- def __init__(self):
- self.script = ['assert compatible_with("0.2") == "true"']
- self.included_files = set()
-
- def MakeTemporary(self):
- """Make a temporary script object whose commands can latter be
- appended to the parent script with AppendScript(). Used when the
- caller wants to generate script commands out-of-order."""
- x = AmendGenerator()
- x.script = []
- x.included_files = self.included_files
- return x
-
- @staticmethod
- def _FileRoot(fn):
- """Convert a file path to the 'root' notation used by amend."""
- if fn.startswith("/system/"):
- return "SYSTEM:" + fn[8:]
- elif fn == "/system":
- return "SYSTEM:"
- elif fn.startswith("/tmp/"):
- return "CACHE:.." + fn
- else:
- raise ValueError("don't know root for \"%s\"" % (fn,))
-
- @staticmethod
- def _PartitionRoot(partition):
- """Convert a partition name to the 'root' notation used by amend."""
- if partition == "userdata":
- return "DATA:"
- else:
- return partition.upper() + ":"
-
- def AppendScript(self, other):
- """Append the contents of another script (which should be created
- with temporary=True) to this one."""
- self.script.extend(other.script)
- self.included_files.update(other.included_files)
-
- def AssertSomeFingerprint(self, *fp):
- """Assert that the current fingerprint is one of *fp."""
- x = [('file_contains("SYSTEM:build.prop", '
- '"ro.build.fingerprint=%s") == "true"') % i for i in fp]
- self.script.append("assert %s" % (" || ".join(x),))
-
- def AssertOlderBuild(self, timestamp):
- """Assert that the build on the device is older (or the same as)
- the given timestamp."""
- self.script.append("run_program PACKAGE:check_prereq %s" % (timestamp,))
- self.included_files.add("check_prereq")
-
- def AssertDevice(self, device):
- """Assert that the device identifier is the given string."""
- self.script.append('assert getprop("ro.product.device") == "%s" || '
- 'getprop("ro.build.product") == "%s"' % (device, device))
-
- def AssertSomeBootloader(self, *bootloaders):
- """Asert that the bootloader version is one of *bootloaders."""
- self.script.append("assert " +
- " || ".join(['getprop("ro.bootloader") == "%s"' % (b,)
- for b in bootloaders]))
-
- def ShowProgress(self, frac, dur):
- """Update the progress bar, advancing it over 'frac' over the next
- 'dur' seconds."""
- self.script.append("show_progress %f %d" % (frac, int(dur)))
-
- def SetProgress(self, frac):
- """Not implemented in amend."""
- pass
-
- def PatchCheck(self, filename, *sha1):
- """Check that the given file (or MTD reference) has one of the
- given *sha1 hashes."""
- out = ["run_program PACKAGE:applypatch -c %s" % (filename,)]
- for i in sha1:
- out.append(" " + i)
- self.script.append("".join(out))
- self.included_files.add(("applypatch_static", "applypatch"))
-
- # Not quite right since we don't need to check /cache/saved.file on
- # failure, but shouldn't hurt.
- FileCheck = PatchCheck
-
- 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_static", "applypatch"))
-
- def Mount(self, kind, what, path):
- # no-op; amend uses it's 'roots' system to automatically mount
- # things when they're referred to
- pass
-
- def UnpackPackageDir(self, src, dst):
- """Unpack a given directory from the OTA package into the given
- destination directory."""
- dst = self._FileRoot(dst)
- self.script.append("copy_dir PACKAGE:%s %s" % (src, dst))
-
- def Comment(self, comment):
- """Write a comment into the update script."""
- self.script.append("")
- for i in comment.split("\n"):
- self.script.append("# " + i)
- self.script.append("")
-
- def Print(self, message):
- """Log a message to the screen (if the logs are visible)."""
- # no way to do this from amend; substitute a script comment instead
- self.Comment(message)
-
- def FormatPartition(self, partition):
- """Format the given MTD partition."""
- self.script.append("format %s" % (self._PartitionRoot(partition),))
-
- def DeleteFiles(self, file_list):
- """Delete all files in file_list."""
- line = []
- t = 0
- for i in file_list:
- i = self._FileRoot(i)
- line.append(i)
- t += len(i) + 1
- if t > 80:
- self.script.append("delete " + " ".join(line))
- line = []
- t = 0
- if line:
- self.script.append("delete " + " ".join(line))
-
- def ApplyPatch(self, srcfile, tgtfile, tgtsize, tgtsha1, *patchpairs):
- """Apply binary patches (in *patchpairs) to the given srcfile to
- produce tgtfile (which may be "-" to indicate overwriting the
- source file."""
- if len(patchpairs) % 2 != 0:
- raise ValueError("bad patches given to ApplyPatch")
- self.script.append(
- ("run_program PACKAGE:applypatch %s %s %s %d " %
- (srcfile, tgtfile, tgtsha1, tgtsize)) +
- " ".join(["%s:%s" % patchpairs[i:i+2]
- for i in range(0, len(patchpairs), 2)]))
- self.included_files.add(("applypatch_static", "applypatch"))
-
- def WriteFirmwareImage(self, kind, fn):
- """Arrange to update the given firmware image (kind must be
- "hboot" or "radio") when recovery finishes."""
- self.script.append("write_%s_image PACKAGE:%s" % (kind, fn))
-
- def WriteRawImage(self, partition, fn):
- """Write the given file into the given MTD partition."""
- self.script.append("write_raw_image PACKAGE:%s %s" %
- (fn, self._PartitionRoot(partition)))
-
- def SetPermissions(self, fn, uid, gid, mode):
- """Set file ownership and permissions."""
- fn = self._FileRoot(fn)
- self.script.append("set_perm %d %d 0%o %s" % (uid, gid, mode, fn))
-
- def SetPermissionsRecursive(self, fn, uid, gid, dmode, fmode):
- """Recursively set path ownership and permissions."""
- fn = self._FileRoot(fn)
- self.script.append("set_perm_recursive %d %d 0%o 0%o %s" %
- (uid, gid, dmode, fmode, fn))
-
- def MakeSymlinks(self, symlink_list):
- """Create symlinks, given a list of (dest, link) pairs."""
- self.DeleteFiles([i[1] for i in symlink_list])
- self.script.extend(["symlink %s %s" % (i[0], self._FileRoot(i[1]))
- for i in sorted(symlink_list)])
-
- def AppendExtra(self, extra):
- """Append text verbatim to the output script."""
- self.script.append(extra)
-
- def UnmountAll(self):
- pass
-
- def AddToZip(self, input_zip, output_zip, input_path=None):
- """Write the accumulated script to the output_zip file. input_zip
- is used as the source for any ancillary binaries needed by the
- script. If input_path is not None, it will be used as a local
- path for binaries instead of input_zip."""
- 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", sourcefn))
- else:
- 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))
diff --git a/tools/releasetools/both_generator.py b/tools/releasetools/both_generator.py
deleted file mode 100644
index 4ae8d50..0000000
--- a/tools/releasetools/both_generator.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import edify_generator
-import amend_generator
-
-class BothGenerator(object):
- def __init__(self, version):
- self.version = version
- self.edify = edify_generator.EdifyGenerator(version)
- self.amend = amend_generator.AmendGenerator()
-
- def MakeTemporary(self):
- x = BothGenerator(self.version)
- x.edify = self.edify.MakeTemporary()
- x.amend = self.amend.MakeTemporary()
- return x
-
- def AppendScript(self, other):
- self.edify.AppendScript(other.edify)
- self.amend.AppendScript(other.amend)
-
- def _DoBoth(self, name, *args):
- getattr(self.edify, name)(*args)
- getattr(self.amend, name)(*args)
-
- def AssertSomeFingerprint(self, *a): self._DoBoth("AssertSomeFingerprint", *a)
- def AssertOlderBuild(self, *a): self._DoBoth("AssertOlderBuild", *a)
- def AssertDevice(self, *a): self._DoBoth("AssertDevice", *a)
- def AssertSomeBootloader(self, *a): self._DoBoth("AssertSomeBootloader", *a)
- def ShowProgress(self, *a): self._DoBoth("ShowProgress", *a)
- def PatchCheck(self, *a): self._DoBoth("PatchCheck", *a)
- def FileCheck(self, filename, *sha1): self._DoBoth("FileCheck", *a)
- def CacheFreeSpaceCheck(self, *a): self._DoBoth("CacheFreeSpaceCheck", *a)
- def Mount(self, *a): self._DoBoth("Mount", *a)
- def UnpackPackageDir(self, *a): self._DoBoth("UnpackPackageDir", *a)
- def Comment(self, *a): self._DoBoth("Comment", *a)
- def Print(self, *a): self._DoBoth("Print", *a)
- def FormatPartition(self, *a): self._DoBoth("FormatPartition", *a)
- def DeleteFiles(self, *a): self._DoBoth("DeleteFiles", *a)
- def ApplyPatch(self, *a): self._DoBoth("ApplyPatch", *a)
- def WriteFirmwareImage(self, *a): self._DoBoth("WriteFirmwareImage", *a)
- def WriteRawImage(self, *a): self._DoBoth("WriteRawImage", *a)
- def SetPermissions(self, *a): self._DoBoth("SetPermissions", *a)
- def SetPermissionsRecursive(self, *a): self._DoBoth("SetPermissionsRecursive", *a)
- def MakeSymlinks(self, *a): self._DoBoth("MakeSymlinks", *a)
- def AppendExtra(self, *a): self._DoBoth("AppendExtra", *a)
- def UnmountAll(self, *a): self._DoBoth("UnmountAll", *a)
-
- def AddToZip(self, input_zip, output_zip, input_path=None):
- self._DoBoth("AddToZip", input_zip, output_zip, input_path)
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 932d5b0..29911bb 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -44,10 +44,6 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package
-e (--extra_script) <file>
Insert the contents of file at the end of the update script.
- -m (--script_mode) <mode>
- Specify 'amend' or 'edify' scripts, or 'auto' to pick
- automatically (this is the default).
-
"""
import sys
@@ -68,9 +64,7 @@ import time
import zipfile
import common
-import amend_generator
import edify_generator
-import both_generator
OPTIONS = common.OPTIONS
OPTIONS.package_key = "build/target/product/security/testkey"
@@ -81,7 +75,6 @@ OPTIONS.patch_threshold = 0.95
OPTIONS.wipe_user_data = False
OPTIONS.omit_prereq = False
OPTIONS.extra_script = None
-OPTIONS.script_mode = 'auto'
OPTIONS.worker_threads = 3
def MostPopularKey(d, default):
@@ -343,15 +336,10 @@ fi
def WriteFullOTAPackage(input_zip, output_zip):
- if OPTIONS.script_mode == "auto":
- script = both_generator.BothGenerator(2)
- elif OPTIONS.script_mode == "amend":
- script = amend_generator.AmendGenerator()
- else:
- # TODO: how to determine this? We don't know what version it will
- # be installed on top of. For now, we expect the API just won't
- # change very often.
- script = edify_generator.EdifyGenerator(2)
+ # TODO: how to determine this? We don't know what version it will
+ # be installed on top of. For now, we expect the API just won't
+ # change very often.
+ script = edify_generator.EdifyGenerator(3)
metadata = {"post-build": GetBuildProp("ro.build.fingerprint", input_zip),
"pre-device": GetBuildProp("ro.product.device", input_zip),
@@ -587,20 +575,10 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
source_version = GetRecoveryAPIVersion(source_zip)
target_version = GetRecoveryAPIVersion(target_zip)
- if OPTIONS.script_mode == 'amend':
- script = amend_generator.AmendGenerator()
- elif OPTIONS.script_mode == 'edify':
- if source_version == 0:
- print ("WARNING: generating edify script for a source that "
- "can't install it.")
- script = edify_generator.EdifyGenerator(source_version)
- elif OPTIONS.script_mode == 'auto':
- if source_version > 0:
- script = edify_generator.EdifyGenerator(source_version)
- else:
- script = amend_generator.AmendGenerator()
- else:
- raise ValueError('unknown script mode "%s"' % (OPTIONS.script_mode,))
+ if source_version == 0:
+ print ("WARNING: generating edify script for a source that "
+ "can't install it.")
+ script = edify_generator.EdifyGenerator(source_version)
metadata = {"pre-device": GetBuildProp("ro.product.device", source_zip),
"post-timestamp": GetBuildProp("ro.build.date.utc", target_zip),
@@ -856,8 +834,6 @@ def main(argv):
OPTIONS.omit_prereq = True
elif o in ("-e", "--extra_script"):
OPTIONS.extra_script = a
- elif o in ("-m", "--script_mode"):
- OPTIONS.script_mode = a
elif o in ("--worker_threads"):
OPTIONS.worker_threads = int(a)
else:
@@ -865,14 +841,13 @@ def main(argv):
return True
args = common.ParseOptions(argv, __doc__,
- extra_opts="b:k:i:d:wne:m:",
+ extra_opts="b:k:i:d:wne:",
extra_long_opts=["board_config=",
"package_key=",
"incremental_from=",
"wipe_user_data",
"no_prereq",
"extra_script=",
- "script_mode=",
"worker_threads="],
extra_option_handler=option_handler)
@@ -880,9 +855,6 @@ def main(argv):
common.Usage(__doc__)
sys.exit(1)
- if OPTIONS.script_mode not in ("amend", "edify", "auto"):
- raise ValueError('unknown script mode "%s"' % (OPTIONS.script_mode,))
-
if OPTIONS.extra_script is not None:
OPTIONS.extra_script = open(OPTIONS.extra_script).read()