From 553b0ec49bc64fc4b7df4358cd31396a87276d2b Mon Sep 17 00:00:00 2001 From: Gilad Arnold Date: Sat, 26 Jan 2013 01:00:39 -0800 Subject: Update payload library + command-line tool An initial implementation of a Python module for parsing, checking and applying a Chrome OS update payload. Comes with a command-line tool (paycheck.py) for applying such operations on payload files, and a test script (test_paycheck.sh) for ensuring that the library and tool are working correctly. Since update_payload is introduced as a package, we're moving some previously merged utilities into the package's directory. (Unit testing for this code will be uploaded on a separate CL; see chromium-os:39663) BUG=chromium-os:34911,chromium-os:33607,chromium-os:7597 TEST=test_paycheck.sh successful on MP-signed payloads CQ-DEPEND=I5746a1d80e822a575f0d96f94d0b4e765fc64507 Change-Id: I77123a1fffbb2059c239b7145c6922968fdffb6a Reviewed-on: https://gerrit.chromium.org/gerrit/43041 Reviewed-by: Gilad Arnold Tested-by: Gilad Arnold Reviewed-by: Chris Sosa Reviewed-by: Jay Srinivasan Reviewed-by: Don Garrett Commit-Queue: Gilad Arnold --- scripts/update_payload/common.py | 141 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 scripts/update_payload/common.py (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py new file mode 100644 index 00000000..16509911 --- /dev/null +++ b/scripts/update_payload/common.py @@ -0,0 +1,141 @@ +# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Utilities for update payload processing.""" + +import ctypes +import textwrap + +from error import PayloadError +import update_metadata_pb2 + + +# +# Constants. +# +PSEUDO_EXTENT_MARKER = ctypes.c_uint64(-1).value + + +# +# Payload operation types. +# +class OpType(object): + """Container for operation type constants.""" + _CLASS = update_metadata_pb2.DeltaArchiveManifest.InstallOperation + # pylint: disable=E1101 + REPLACE = _CLASS.REPLACE + REPLACE_BZ = _CLASS.REPLACE_BZ + MOVE = _CLASS.MOVE + BSDIFF = _CLASS.BSDIFF + NAMES = { + REPLACE: 'REPLACE', + REPLACE_BZ: 'REPLACE_BZ', + MOVE: 'MOVE', + BSDIFF: 'BSDIFF', + } + + def __init__(self): + pass + + +# +# Checker and hashed reading of data. +# +def Read(file_obj, length, offset=None, hasher=None): + """Reads binary data from a file. + + Args: + file_obj: an open file object + length: the length of the data to read + offset: an offset to seek to prior to reading; this is an absolute offset + 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. + + """ + if offset is not None: + if offset >= 0: + file_obj.seek(offset) + else: + file_obj.seek(offset, 2) + + try: + data = file_obj.read(length) + except IOError, e: + raise PayloadError('error reading from file (%s): %s' % (file_obj.name, e)) + + if len(data) != length: + raise PayloadError( + 'reading from file (%s) too short (%d instead of %d bytes)' % + (file_obj.name, len(data), length)) + + if hasher: + hasher.update(data) + + return data + + +# +# Formatting functions. +# +def FormatExtent(ex, block_size=0): + end_block = ex.start_block + ex.num_blocks + if block_size: + return '%d->%d * %d' % (ex.start_block, end_block, block_size) + else: + return '%d->%d' % (ex.start_block, end_block) + + +def FormatSha256(digest): + """Returns a canonical string representation of a SHA256 digest.""" + return '\n'.join(textwrap.wrap(digest.encode('hex'), 32)) + + +# +# Useful iterators. +# +def _ObjNameIter(items, base_name, reverse=False, name_format_func=None): + """A generic (item, name) tuple iterators. + + Args: + items: the sequence of objects to iterate on + 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). + + """ + idx, inc = (len(items), -1) if reverse else (1, 1) + for item in items: + item_name = '%s[%d]' % (base_name, idx) + if name_format_func: + item_name = name_format_func(item, item_name) + yield (item, item_name) + idx += inc + + +def _OperationNameFormatter(op, op_name): + return '%s(%s)' % (op_name, OpType.NAMES.get(op.type, '?')) + + +def OperationIter(operations, base_name, reverse=False): + """An (item, name) iterator for update operations.""" + return _ObjNameIter(operations, base_name, reverse=reverse, + name_format_func=_OperationNameFormatter) + + +def ExtentIter(extents, base_name, reverse=False): + """An (item, name) iterator for operation extents.""" + return _ObjNameIter(extents, base_name, reverse=reverse) + + +def SignatureIter(sigs, base_name, reverse=False): + """An (item, name) iterator for signatures.""" + return _ObjNameIter(sigs, base_name, reverse=reverse) -- cgit v1.2.3 From 857223b4118d7b4d9bd988d996db00d7ea313029 Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Fri, 29 Mar 2013 14:31:43 -0700 Subject: Modify paycheck to print out hashes in base64. Both the update engine and sha256_partitions.sh print out hashes in base64 encoding. Let's stay consistent with ourselves so we can diagnose hash mismatches correctly. BUG=None TEST=Ran it with a delta payload and compared hashes with sha256_partitions.sh and logs from applying it in the update_engine. Change-Id: I90c511b936792a073fbe069065ff53c24f47041c Reviewed-on: https://gerrit.chromium.org/gerrit/46910 Commit-Queue: Chris Sosa Reviewed-by: Chris Sosa Tested-by: Chris Sosa --- scripts/update_payload/common.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 16509911..5e0087ba 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -5,7 +5,6 @@ """Utilities for update payload processing.""" import ctypes -import textwrap from error import PayloadError import update_metadata_pb2 @@ -93,7 +92,7 @@ def FormatExtent(ex, block_size=0): def FormatSha256(digest): """Returns a canonical string representation of a SHA256 digest.""" - return '\n'.join(textwrap.wrap(digest.encode('hex'), 32)) + return digest.encode('base64') # -- cgit v1.2.3 From 5502b56f34f9703cf053be46e4ea5685c0c9ac26 Mon Sep 17 00:00:00 2001 From: Gilad Arnold Date: Fri, 8 Mar 2013 13:22:31 -0800 Subject: paycheck: unit tests + fixes to checker module This adds missing unit tests for the checker module, bundled with fixes to some bugs that surfaced due to unit tests. This includes: * A fake extent (signified by start_block == UINT64_MAX) that accompanies a signature data blob bears different requirements than previously implemented. Specifically, the extent sequence must have exactly one extent; and the number of blocks is not necessarily one, rather it is the correct number that corresponds to the actual length of the signature blob. * REPLACE/REPLACE_BZ operations must contain data. * MOVE operation validation must ensure that all of the actual message extents are being used. * BSDIFF operation must contain data (the diff). * Signature pseudo-operation should be a REPLACE. BUG=chromium-os:34911,chromium-os:33607,chromium-os:7597 TEST=Passes unittests (upcoming); works with actual payloads. Change-Id: I4d839d1d4da1fbb4a493b208958a139368e2c8ca Reviewed-on: https://gerrit.chromium.org/gerrit/45429 Tested-by: Gilad Arnold Reviewed-by: Chris Sosa Commit-Queue: Gilad Arnold --- scripts/update_payload/common.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 5e0087ba..6b5dbada 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -15,6 +15,12 @@ import update_metadata_pb2 # PSEUDO_EXTENT_MARKER = ctypes.c_uint64(-1).value +SIG_ASN1_HEADER = ( + '\x30\x31\x30\x0d\x06\x09\x60\x86' + '\x48\x01\x65\x03\x04\x02\x01\x05' + '\x00\x04\x20' +) + # # Payload operation types. @@ -27,6 +33,7 @@ class OpType(object): REPLACE_BZ = _CLASS.REPLACE_BZ MOVE = _CLASS.MOVE BSDIFF = _CLASS.BSDIFF + ALL = (REPLACE, REPLACE_BZ, MOVE, BSDIFF) NAMES = { REPLACE: 'REPLACE', REPLACE_BZ: 'REPLACE_BZ', @@ -41,6 +48,39 @@ class OpType(object): # # Checker and hashed reading of data. # +def IntPackingFmtStr(size, is_unsigned): + """Returns an integer format string for use by the struct module. + + 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. + + """ + # Determine the base conversion format. + if size == 2: + fmt = 'h' + elif size == 4: + fmt = 'i' + elif size == 8: + fmt = 'q' + else: + raise PayloadError('unsupport numeric field size (%s)' % size) + + # Signed or unsigned? + if is_unsigned: + fmt = fmt.upper() + + # Make it network byte order (big-endian). + fmt = '!' + fmt + + return fmt + + def Read(file_obj, length, offset=None, hasher=None): """Reads binary data from a file. -- cgit v1.2.3 From 382df5ce2f4b67bf0998b01c6fedcdb5c35ebef9 Mon Sep 17 00:00:00 2001 From: Gilad Arnold Date: Fri, 3 May 2013 12:49:28 -0700 Subject: paycheck: enforce physical partition size correctly During payload checking, payload has wrongly interpreted the size reported in the update payload to be the physical partition size, whereas this is in fact the size of the filesystem portion only (a misnomer). This sometimes caused it to emit errors on out-of-bounds operations, which are otherwise harmless in real-world scenarios. This CL makes a clear distinction between the two, with the following semantics: - The payload's embedded filesystem size must by <= the physical partition sizes. - Reading/writing from/to the new partition must be within the physical partition size boundaries, and not the filesystem ones. - Reading from the old partition is only allowed from filesystem boundaries; this is unchanged from current behavior and appears to be consistent with how we perform delta updates. - Old/new SHA256 verification during payload application is now limited to the allotted filesystem portion only (and not the full partition size). This is consistent with the update engine's semantics. - Other than that, this change currently has no further effect on payload application, which remains more permissive wrt to partition sizes. This also means that the sizes of partitions resulting from a payload application will not necessarily abide by the predetermined physical partition sizes. This is in line with the prevailing division of responsibilities between payload checking (strict) and application (relaxed). BUG=chromium:221847 TEST=Payload checking respects partition size override TEST=Unit tests pass TEST=Integration tests pass Change-Id: I0dbc88d538c0cc53b7551f4dfa8f543bcf480cd5 Reviewed-on: https://gerrit.chromium.org/gerrit/50103 Reviewed-by: Gilad Arnold Tested-by: Gilad Arnold Commit-Queue: David James --- scripts/update_payload/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 6b5dbada..a8697306 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -46,7 +46,7 @@ class OpType(object): # -# Checker and hashed reading of data. +# Checked and hashed reading of data. # def IntPackingFmtStr(size, is_unsigned): """Returns an integer format string for use by the struct module. -- cgit v1.2.3 From a7aa0bcfa25b0d303447482980eca0973d4e939a Mon Sep 17 00:00:00 2001 From: Gilad Arnold Date: Tue, 12 Nov 2013 08:18:08 -0800 Subject: paycheck: strip newlines off of hash digest strings This is an annoyance I'd like to get rid of. BUG=None TEST=None Change-Id: I6119163ffc4944dd2f857bad055822b37229a692 Reviewed-on: https://chromium-review.googlesource.com/176478 Tested-by: Gilad Arnold Reviewed-by: Don Garrett Commit-Queue: Gilad Arnold --- scripts/update_payload/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index a8697306..584eb35c 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -132,7 +132,7 @@ def FormatExtent(ex, block_size=0): def FormatSha256(digest): """Returns a canonical string representation of a SHA256 digest.""" - return digest.encode('base64') + return digest.encode('base64').strip() # -- cgit v1.2.3 From c11dc7338639296ab99f89964a94bcc486500ba3 Mon Sep 17 00:00:00 2001 From: Allie Wood Date: Wed, 18 Feb 2015 15:53:05 -0800 Subject: update_payload: Regenerate proto file with new operation codes. Regenerate update_metadata_pb2.py to include SOURCE_COPY and SOURCE_BSDIFF, the new a to b operations for delta minor version 2. BUG=chromium:459363 TEST=unit tests and `cbuildbot --remote link-release --hwtest` Change-Id: I3631c7af97f57d48f86a34c37f97ec8c3cef088d Reviewed-on: https://chromium-review.googlesource.com/250954 Reviewed-by: Alex Deymo Commit-Queue: Allie Wood Tested-by: Allie Wood Reviewed-by: Don Garrett --- scripts/update_payload/common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 584eb35c..2beabeac 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -33,12 +33,16 @@ class OpType(object): REPLACE_BZ = _CLASS.REPLACE_BZ MOVE = _CLASS.MOVE BSDIFF = _CLASS.BSDIFF - ALL = (REPLACE, REPLACE_BZ, MOVE, BSDIFF) + SOURCE_COPY = _CLASS.SOURCE_COPY + SOURCE_BSDIFF = _CLASS.SOURCE_BSDIFF + ALL = (REPLACE, REPLACE_BZ, MOVE, BSDIFF, SOURCE_COPY, SOURCE_BSDIFF) NAMES = { REPLACE: 'REPLACE', REPLACE_BZ: 'REPLACE_BZ', MOVE: 'MOVE', BSDIFF: 'BSDIFF', + SOURCE_COPY: 'SOURCE_COPY', + SOURCE_BSDIFF: 'SOURCE_BSDIFF' } def __init__(self): -- cgit v1.2.3 From 12f59aa1cffec0ee531daccc6de7469870f86302 Mon Sep 17 00:00:00 2001 From: Allie Wood Date: Mon, 6 Apr 2015 11:05:12 -0700 Subject: 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 Reviewed-by: Alex Deymo Commit-Queue: Allie Wood Trybot-Ready: Allie Wood --- scripts/update_payload/common.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'scripts/update_payload/common.py') 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). -- cgit v1.2.3 From cf6f30dd7ef1db9955f2e318c0e47ee00271f358 Mon Sep 17 00:00:00 2001 From: Alex Deymo Date: Thu, 11 Jun 2015 13:51:46 -0700 Subject: update_payload: Remove ctypes dependency. ctypes requires libffi.so to be installed in the system, but old test_images don't have it, preventing "cros flash" to work there. This patch removes the need for ctypes from common.py so cros flash can work. BUG=None TEST=cros flash from R29 on link. Change-Id: Idd0732660780081c26375a5214167b53f625e3ed Reviewed-on: https://chromium-review.googlesource.com/277070 Trybot-Ready: Alex Deymo Tested-by: Alex Deymo Reviewed-by: Don Garrett Commit-Queue: Alex Deymo --- scripts/update_payload/common.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 573fda40..e8c7c766 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -6,8 +6,6 @@ from __future__ import print_function -import ctypes - from error import PayloadError import update_metadata_pb2 @@ -15,7 +13,7 @@ import update_metadata_pb2 # # Constants. # -PSEUDO_EXTENT_MARKER = ctypes.c_uint64(-1).value +PSEUDO_EXTENT_MARKER = (1L << 64) - 1 # UINT64_MAX SIG_ASN1_HEADER = ( '\x30\x31\x30\x0d\x06\x09\x60\x86' -- cgit v1.2.3 From e4beff7dacb170298f86bb5bde1946b9b827b174 Mon Sep 17 00:00:00 2001 From: Gilad Arnold Date: Thu, 16 Jul 2015 14:14:03 -0700 Subject: paycheck: Fix printing of operation index while tracing. The block tracer is meant to scan operations in reverse order, to discover the latest operation that writes to a block. Strangely, it only reversed the operation indexes but scanned the actual operations in the original order, which is both incorrect in the general case, but even when it works the printed results are confusing (operations shown with the wrong index). This fixes it. Also some cosmetic changes to pacify the linter. BUG=chromium:510909 TEST=paycheck -B now prints the correct operation indexes. Change-Id: I65c44eeb450c229a2d5251737a0953716e124687 Reviewed-on: https://chromium-review.googlesource.com/286220 Commit-Queue: Gilad Arnold Tested-by: Gilad Arnold Reviewed-by: Don Garrett --- scripts/update_payload/common.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index e8c7c766..1a9b010d 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -67,7 +67,6 @@ def IntPackingFmtStr(size, is_unsigned): Raises: PayloadError if something is wrong with the arguments. - """ # Determine the base conversion format. if size == 2: @@ -105,7 +104,6 @@ def Read(file_obj, length, offset=None, hasher=None): Raises: PayloadError if a read error occurred or not enough data was read. - """ if offset is not None: if offset >= 0: @@ -160,9 +158,10 @@ def _ObjNameIter(items, base_name, reverse=False, name_format_func=None): Yields: An iterator whose i-th invocation returns (items[i], name), where name == base_name + '[i]' (with a formatting function optionally applied to it). - """ idx, inc = (len(items), -1) if reverse else (1, 1) + if reverse: + items = reversed(items) for item in items: item_name = '%s[%d]' % (base_name, idx) if name_format_func: -- cgit v1.2.3 From 2846677f9ec7725d9cf9513768477c873c19ba78 Mon Sep 17 00:00:00 2001 From: Alex Deymo Date: Fri, 11 Sep 2015 17:16:44 -0700 Subject: paycheck: Update generated protobuf code. This patch updates the generated update_metadata_pb2.py file with the latest changes in the udpate_metadata.proto file. Some other changes in the update_payload library were required to match the changes in the .proto file. BUG=b:23179128 TEST=paycheck unittests Change-Id: I482d67d4a35f69438a26395eea77286994108b7a Reviewed-on: https://chromium-review.googlesource.com/299498 Commit-Ready: Alex Deymo Tested-by: Alex Deymo Reviewed-by: Gilad Arnold --- scripts/update_payload/common.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 1a9b010d..9d008a95 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -29,7 +29,7 @@ SOURCE_MINOR_PAYLOAD_VERSION = 2 # class OpType(object): """Container for operation type constants.""" - _CLASS = update_metadata_pb2.DeltaArchiveManifest.InstallOperation + _CLASS = update_metadata_pb2.InstallOperation # pylint: disable=E1101 REPLACE = _CLASS.REPLACE REPLACE_BZ = _CLASS.REPLACE_BZ @@ -37,14 +37,21 @@ class OpType(object): BSDIFF = _CLASS.BSDIFF SOURCE_COPY = _CLASS.SOURCE_COPY SOURCE_BSDIFF = _CLASS.SOURCE_BSDIFF - ALL = (REPLACE, REPLACE_BZ, MOVE, BSDIFF, SOURCE_COPY, SOURCE_BSDIFF) + ZERO = _CLASS.ZERO + DISCARD = _CLASS.DISCARD + REPLACE_XZ = _CLASS.REPLACE_XZ + ALL = (REPLACE, REPLACE_BZ, MOVE, BSDIFF, SOURCE_COPY, SOURCE_BSDIFF, ZERO, + DISCARD, REPLACE_XZ) NAMES = { REPLACE: 'REPLACE', REPLACE_BZ: 'REPLACE_BZ', MOVE: 'MOVE', BSDIFF: 'BSDIFF', SOURCE_COPY: 'SOURCE_COPY', - SOURCE_BSDIFF: 'SOURCE_BSDIFF' + SOURCE_BSDIFF: 'SOURCE_BSDIFF', + ZERO: 'ZERO', + DISCARD: 'DISCARD', + REPLACE_XZ: 'REPLACE_XZ' } def __init__(self): -- cgit v1.2.3 From ef49735f40d0319151fd1e50abdbe377ab49ce72 Mon Sep 17 00:00:00 2001 From: Alex Deymo Date: Thu, 15 Oct 2015 09:14:58 -0700 Subject: Parse Payload v2 header. The update payload v2 contains an extra field in the header with the size of the metadata signatures and the metadata signatures stored right after the metadata. This patch parses the new payload format. BUG=b:22024447 TEST=cros payload show payload-v2.bin; served a payload v2 with devserver.py Change-Id: I8ce85af1df505f82f62a9d1cd57910cee6921f84 Reviewed-on: https://chromium-review.googlesource.com/306090 Commit-Ready: Alex Deymo Tested-by: Alex Deymo Reviewed-by: Gilad Arnold --- scripts/update_payload/common.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 9d008a95..38d949b4 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -21,6 +21,9 @@ SIG_ASN1_HEADER = ( '\x00\x04\x20' ) +CHROMEOS_MAJOR_PAYLOAD_VERSION = 1 +BRILLO_MAJOR_PAYLOAD_VERSION = 2 + INPLACE_MINOR_PAYLOAD_VERSION = 1 SOURCE_MINOR_PAYLOAD_VERSION = 2 -- cgit v1.2.3 From d6122bb9df5b593a3ab1fc35fab7f1a0caa53928 Mon Sep 17 00:00:00 2001 From: Sen Jiang Date: Fri, 11 Dec 2015 10:27:04 -0800 Subject: paycheck: Allow minor version 3 in applier. Also fixed nits in checker. BUG=chromium:568473 TEST=./checker_unittest.py Change-Id: Ia791f4dc636e9c3a2921aeaa5f9dd01c247bf5bb Reviewed-on: https://chromium-review.googlesource.com/317780 Trybot-Ready: Sen Jiang Tested-by: Sen Jiang Reviewed-by: Alex Deymo Reviewed-by: Gilad Arnold Commit-Queue: Sen Jiang --- scripts/update_payload/common.py | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 38d949b4..80e25014 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -26,6 +26,7 @@ BRILLO_MAJOR_PAYLOAD_VERSION = 2 INPLACE_MINOR_PAYLOAD_VERSION = 1 SOURCE_MINOR_PAYLOAD_VERSION = 2 +OPSRCHASH_MINOR_PAYLOAD_VERSION = 3 # # Payload operation types. -- cgit v1.2.3 From c2538fab9a7fc01c0216520874d711c8a9fbd9d3 Mon Sep 17 00:00:00 2001 From: Sen Jiang Date: Wed, 24 Feb 2016 14:15:02 -0800 Subject: update_payload: Regenerate protobuf to include IMGDIFF. Generated from update_metadata.proto using protoc 2.5.0 BUG=b:26456666 TEST=./checker_unittest.py Change-Id: I9dc7db00be8afb2f78e80bec910f9ca83a55a9a1 Reviewed-on: https://chromium-review.googlesource.com/329237 Commit-Ready: Sen Jiang Tested-by: Sen Jiang Reviewed-by: Alex Deymo --- scripts/update_payload/common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts/update_payload/common.py') diff --git a/scripts/update_payload/common.py b/scripts/update_payload/common.py index 80e25014..88cd6edc 100644 --- a/scripts/update_payload/common.py +++ b/scripts/update_payload/common.py @@ -44,8 +44,9 @@ class OpType(object): ZERO = _CLASS.ZERO DISCARD = _CLASS.DISCARD REPLACE_XZ = _CLASS.REPLACE_XZ + IMGDIFF = _CLASS.IMGDIFF ALL = (REPLACE, REPLACE_BZ, MOVE, BSDIFF, SOURCE_COPY, SOURCE_BSDIFF, ZERO, - DISCARD, REPLACE_XZ) + DISCARD, REPLACE_XZ, IMGDIFF) NAMES = { REPLACE: 'REPLACE', REPLACE_BZ: 'REPLACE_BZ', @@ -55,7 +56,8 @@ class OpType(object): SOURCE_BSDIFF: 'SOURCE_BSDIFF', ZERO: 'ZERO', DISCARD: 'DISCARD', - REPLACE_XZ: 'REPLACE_XZ' + REPLACE_XZ: 'REPLACE_XZ', + IMGDIFF: 'IMGDIFF', } def __init__(self): -- cgit v1.2.3