summaryrefslogtreecommitdiff
path: root/scripts/update_payload/common.py
diff options
context:
space:
mode:
authorAllie Wood <alliewood@chromium.org>2015-04-06 11:05:12 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-04-15 04:50:56 +0000
commit12f59aa1cffec0ee531daccc6de7469870f86302 (patch)
tree556511e734922e8b9c1568375a1188b479d41797 /scripts/update_payload/common.py
parentfb04d30e433eed1d7e7b78114c1a747c89091362 (diff)
update_payload: Add SOURCE operations to applier.
Add support for SOURCE_COPY and SOURCE_BSDIFF to paycheck by adding functions to apply these operations in applier. Also remove the source to destination partition copy in the applier when minor version is 2. Adds constants for source and inplace minor versions to common.py. BUG=chromium:461635 TEST=unit tests and ./test_paycheck.sh with sample payloads. CQ-DEPEND=CL:263747 Change-Id: I72d354d0609d205aab374dbdca6f30eb4de6a819 Reviewed-on: https://chromium-review.googlesource.com/264931 Tested-by: Allie Wood <alliewood@chromium.org> Reviewed-by: Alex Deymo <deymo@chromium.org> Commit-Queue: Allie Wood <alliewood@chromium.org> Trybot-Ready: Allie Wood <alliewood@chromium.org>
Diffstat (limited to 'scripts/update_payload/common.py')
-rw-r--r--scripts/update_payload/common.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py
index 2beabeac..573fda40 100644
--- a/scripts/update_payload/common.py
+++ b/scripts/update_payload/common.py
@@ -4,6 +4,8 @@
"""Utilities for update payload processing."""
+from __future__ import print_function
+
import ctypes
from error import PayloadError
@@ -21,6 +23,8 @@ SIG_ASN1_HEADER = (
'\x00\x04\x20'
)
+INPLACE_MINOR_PAYLOAD_VERSION = 1
+SOURCE_MINOR_PAYLOAD_VERSION = 2
#
# Payload operation types.
@@ -58,9 +62,11 @@ def IntPackingFmtStr(size, is_unsigned):
Args:
size: the integer size in bytes (2, 4 or 8)
is_unsigned: whether it is signed or not
+
Returns:
A format string for packing/unpacking integer values; assumes network byte
order (big-endian).
+
Raises:
PayloadError if something is wrong with the arguments.
@@ -95,8 +101,10 @@ def Read(file_obj, length, offset=None, hasher=None):
from either the beginning (non-negative) or end (negative) of the
file. (optional)
hasher: a hashing object to pass the read data through (optional)
+
Returns:
A string containing the read data.
+
Raises:
PayloadError if a read error occurred or not enough data was read.
@@ -150,6 +158,7 @@ def _ObjNameIter(items, base_name, reverse=False, name_format_func=None):
base_name: the base name for all objects
reverse: whether iteration should be in reverse order
name_format_func: a function to apply to the name string
+
Yields:
An iterator whose i-th invocation returns (items[i], name), where name ==
base_name + '[i]' (with a formatting function optionally applied to it).