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>
diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py
index 2beabea..573fda4 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 @@
'\x00\x04\x20'
)
+INPLACE_MINOR_PAYLOAD_VERSION = 1
+SOURCE_MINOR_PAYLOAD_VERSION = 2
#
# Payload operation types.
@@ -58,9 +62,11 @@
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 @@
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 @@
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).