blob: 40db67854bf97ddb4967ab77237db18267c1c04a [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2010 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
adlr@google.com3defe6a2009-12-04 20:57:17 +000016
17// Update file format: A delta update file contains all the deltas needed
18// to update a system from one specific version to another specific
19// version. The update format is represented by this struct pseudocode:
20// struct delta_update_file {
21// char magic[4] = "CrAU";
Alex Deymoc1d7f122015-09-10 15:15:42 -070022// uint64 file_format_version;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080023// uint64 manifest_size; // Size of protobuf DeltaArchiveManifest
Alex Deymoc1d7f122015-09-10 15:15:42 -070024//
25// // Only present if format_version > 1:
26// uint32 metadata_signature_size;
27//
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080028// // The Bzip2 compressed DeltaArchiveManifest
29// char manifest[];
adlr@google.com3defe6a2009-12-04 20:57:17 +000030//
Alex Deymoc1d7f122015-09-10 15:15:42 -070031// // The signature of the metadata (from the beginning of the payload up to
32// // this location, not including the signature itself). This is a serialized
33// // Signatures message.
34// char medatada_signature_message[metadata_signature_size];
35//
adlr@google.com3defe6a2009-12-04 20:57:17 +000036// // Data blobs for files, no specific format. The specific offset
37// // and length of each data blob is recorded in the DeltaArchiveManifest.
38// struct {
39// char data[];
40// } blobs[];
41//
Andrew de los Reyes94f025d2010-08-16 17:17:27 -070042// // These two are not signed:
Alex Deymoc1d7f122015-09-10 15:15:42 -070043// uint64 payload_signatures_message_size;
44// char payload_signatures_message[];
Andrew de los Reyes94f025d2010-08-16 17:17:27 -070045//
adlr@google.com3defe6a2009-12-04 20:57:17 +000046// };
47
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080048// The DeltaArchiveManifest protobuf is an ordered list of InstallOperation
49// objects. These objects are stored in a linear array in the
50// DeltaArchiveManifest. Each operation is applied in order by the client.
adlr@google.com3defe6a2009-12-04 20:57:17 +000051
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080052// The DeltaArchiveManifest also contains the initial and final
53// checksums for the device.
adlr@google.com3defe6a2009-12-04 20:57:17 +000054
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080055// The client will perform each InstallOperation in order, beginning even
56// before the entire delta file is downloaded (but after at least the
57// protobuf is downloaded). The types of operations are explained:
58// - REPLACE: Replace the dst_extents on the drive with the attached data,
59// zero padding out to block size.
60// - REPLACE_BZ: bzip2-uncompress the attached data and write it into
61// dst_extents on the drive, zero padding to block size.
62// - MOVE: Copy the data in src_extents to dst_extents. Extents may overlap,
63// so it may be desirable to read all src_extents data into memory before
64// writing it out.
Alex Deymoc1d7f122015-09-10 15:15:42 -070065// - SOURCE_COPY: Copy the data in src_extents in the old partition to
66// dst_extents in the new partition. There's no overlapping of data because
67// the extents are in different partitions.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080068// - BSDIFF: Read src_length bytes from src_extents into memory, perform
69// bspatch with attached data, write new data to dst_extents, zero padding
70// to block size.
Alex Deymoc1d7f122015-09-10 15:15:42 -070071// - SOURCE_BSDIFF: Read the data in src_extents in the old partition, perform
72// bspatch with the attached data and write the new data to dst_extents in the
73// new partition.
74// - ZERO: Write zeros to the destination dst_extents.
75// - DISCARD: Discard the destination dst_extents blocks on the physical medium.
76// the data read from those block is undefined.
77// - REPLACE_XZ: Replace the dst_extents with the contents of the attached
78// xz file after decompression. The xz file should only use crc32 or no crc at
79// all to be compatible with xz-embedded.
Amin Hassanicdeb6e62017-10-11 10:15:11 -070080// - PUFFDIFF: Read the data in src_extents in the old partition, perform
81// puffpatch with the attached data and write the new data to dst_extents in
82// the new partition.
Alex Deymoc1d7f122015-09-10 15:15:42 -070083//
84// The operations allowed in the payload (supported by the client) depend on the
Sen Jiang771f6482018-04-04 17:59:10 -070085// major and minor version. See InstallOperation.Type below for details.
adlr@google.com3defe6a2009-12-04 20:57:17 +000086
Amin Hassani489875a2017-08-04 13:20:52 -070087syntax = "proto2";
88
adlr@google.com3defe6a2009-12-04 20:57:17 +000089package chromeos_update_engine;
Alex Deymob8f16a12014-06-10 18:59:22 -070090option optimize_for = LITE_RUNTIME;
adlr@google.com3defe6a2009-12-04 20:57:17 +000091
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080092// Data is packed into blocks on disk, always starting from the beginning
93// of the block. If a file's data is too large for one block, it overflows
94// into another block, which may or may not be the following block on the
95// physical partition. An ordered list of extents is another
96// representation of an ordered list of blocks. For example, a file stored
97// in blocks 9, 10, 11, 2, 18, 12 (in that order) would be stored in
98// extents { {9, 3}, {2, 1}, {18, 1}, {12, 1} } (in that order).
99// In general, files are stored sequentially on disk, so it's more efficient
100// to use extents to encode the block lists (this is effectively
101// run-length encoding).
102// A sentinel value (kuint64max) as the start block denotes a sparse-hole
103// in a file whose block-length is specified by num_blocks.
adlr@google.com3defe6a2009-12-04 20:57:17 +0000104
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700105// Signatures: Updates may be signed by the OS vendor. The client verifies
106// an update's signature by hashing the entire download. The section of the
Jay Srinivasan74475bf2012-09-13 19:26:26 -0700107// download that contains the signature is at the end of the file, so when
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700108// signing a file, only the part up to the signature part is signed.
109// Then, the client looks inside the download's Signatures message for a
110// Signature message that it knows how to handle. Generally, a client will
111// only know how to handle one type of signature, but an update may contain
112// many signatures to support many different types of client. Then client
113// selects a Signature message and uses that, along with a known public key,
114// to verify the download. The public key is expected to be part of the
115// client.
116
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800117message Extent {
118 optional uint64 start_block = 1;
119 optional uint64 num_blocks = 2;
adlr@google.com3defe6a2009-12-04 20:57:17 +0000120}
121
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700122message Signatures {
123 message Signature {
124 optional uint32 version = 1;
Andrew de los Reyes0c440052010-08-20 11:25:54 -0700125 optional bytes data = 2;
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700126 }
127 repeated Signature signatures = 1;
128}
129
Darin Petkov36a58222010-10-07 22:00:09 -0700130message PartitionInfo {
131 optional uint64 size = 1;
132 optional bytes hash = 2;
133}
134
Don Garrett0dd39852013-04-03 16:55:42 -0700135// Describe an image we are based on in a human friendly way.
136// Examples:
137// dev-channel, x86-alex, 1.2.3, mp-v3
138// nplusone-channel, x86-alex, 1.2.4, mp-v3, dev-channel, 1.2.3
139//
140// All fields will be set, if this message is present.
141message ImageInfo {
142 optional string board = 1;
143 optional string key = 2;
144 optional string channel = 3;
145 optional string version = 4;
146
147 // If these values aren't present, they should be assumed to match
148 // the equivalent value above. They are normally only different for
149 // special image types such as nplusone images.
150 optional string build_channel = 5;
151 optional string build_version = 6;
152}
153
Alex Deymoa12ee112015-08-12 22:19:32 -0700154message InstallOperation {
155 enum Type {
Amin Hassani0f59a9a2019-09-27 10:24:31 -0700156 REPLACE = 0; // Replace destination extents w/ attached data.
157 REPLACE_BZ = 1; // Replace destination extents w/ attached bzipped data.
158 MOVE = 2 [deprecated = true]; // Move source extents to target extents.
159 BSDIFF = 3 [deprecated = true]; // The data is a bsdiff binary diff.
Alex Deymoac6246a2015-08-13 14:00:22 -0700160
Alex Deymoc1d7f122015-09-10 15:15:42 -0700161 // On minor version 2 or newer, these operations are supported:
Alex Deymoa12ee112015-08-12 22:19:32 -0700162 SOURCE_COPY = 4; // Copy from source to target partition
163 SOURCE_BSDIFF = 5; // Like BSDIFF, but read from source partition
Alex Deymoac6246a2015-08-13 14:00:22 -0700164
Alex Deymoc1d7f122015-09-10 15:15:42 -0700165 // On minor version 3 or newer and on major version 2 or newer, these
166 // operations are supported:
Alex Deymoc1d7f122015-09-10 15:15:42 -0700167 REPLACE_XZ = 8; // Replace destination extents w/ attached xz data.
Sen Jiang3317b882016-01-08 17:48:57 +0800168
169 // On minor version 4 or newer, these operations are supported:
Amin Hassanidf3a8662017-12-07 12:17:45 -0800170 ZERO = 6; // Write zeros in the destination.
171 DISCARD = 7; // Discard the destination blocks, reading as undefined.
Amin Hassaniefa62d92017-11-09 13:46:56 -0800172 BROTLI_BSDIFF = 10; // Like SOURCE_BSDIFF, but compressed with brotli.
Amin Hassani77d7cbc2018-02-07 16:21:33 -0800173
174 // On minor version 5 or newer, these operations are supported:
175 PUFFDIFF = 9; // The data is in puffdiff format.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800176 }
Alex Deymoa12ee112015-08-12 22:19:32 -0700177 required Type type = 1;
Sen Jiang9edcd042018-11-12 16:46:06 -0800178
179 // Only minor version 6 or newer support 64 bits |data_offset| and
180 // |data_length|, older client will read them as uint32.
Alex Deymoa12ee112015-08-12 22:19:32 -0700181 // The offset into the delta file (after the protobuf)
182 // where the data (if any) is stored
Sen Jiang9edcd042018-11-12 16:46:06 -0800183 optional uint64 data_offset = 2;
Alex Deymoa12ee112015-08-12 22:19:32 -0700184 // The length of the data in the delta file
Sen Jiang9edcd042018-11-12 16:46:06 -0800185 optional uint64 data_length = 3;
Alex Deymoa12ee112015-08-12 22:19:32 -0700186
187 // Ordered list of extents that are read from (if any) and written to.
188 repeated Extent src_extents = 4;
189 // Byte length of src, equal to the number of blocks in src_extents *
Amin Hassanif5a06d82017-10-19 15:06:38 -0700190 // block_size. It is used for BSDIFF and SOURCE_BSDIFF, because we need to
191 // pass that external program the number of bytes to read from the blocks we
192 // pass it. This is not used in any other operation.
Alex Deymoa12ee112015-08-12 22:19:32 -0700193 optional uint64 src_length = 5;
194
195 repeated Extent dst_extents = 6;
196 // Byte length of dst, equal to the number of blocks in dst_extents *
Amin Hassanif5a06d82017-10-19 15:06:38 -0700197 // block_size. Used for BSDIFF and SOURCE_BSDIFF, but not in any other
198 // operation.
Alex Deymoa12ee112015-08-12 22:19:32 -0700199 optional uint64 dst_length = 7;
200
201 // Optional SHA 256 hash of the blob associated with this operation.
202 // This is used as a primary validation for http-based downloads and
203 // as a defense-in-depth validation for https-based downloads. If
204 // the operation doesn't refer to any blob, this field will have
205 // zero bytes.
206 optional bytes data_sha256_hash = 8;
Alex Deymoac6246a2015-08-13 14:00:22 -0700207
208 // Indicates the SHA 256 hash of the source data referenced in src_extents at
209 // the time of applying the operation. If present, the update_engine daemon
210 // MUST read and verify the source data before applying the operation.
211 optional bytes src_sha256_hash = 9;
212}
213
214// Describes the update to apply to a single partition.
215message PartitionUpdate {
216 // A platform-specific name to identify the partition set being updated. For
217 // example, in Chrome OS this could be "ROOT" or "KERNEL".
218 required string partition_name = 1;
219
Alex Deymoeb86e552015-09-21 16:00:38 -0700220 // Whether this partition carries a filesystem with post-install program that
221 // must be run to finalize the update process. See also |postinstall_path| and
222 // |filesystem_type|.
Alex Deymoac6246a2015-08-13 14:00:22 -0700223 optional bool run_postinstall = 2;
224
Alex Deymoeb86e552015-09-21 16:00:38 -0700225 // The path of the executable program to run during the post-install step,
226 // relative to the root of this filesystem. If not set, the default "postinst"
227 // will be used. This setting is only used when |run_postinstall| is set and
228 // true.
229 optional string postinstall_path = 3;
230
231 // The filesystem type as passed to the mount(2) syscall when mounting the new
232 // filesystem to run the post-install program. If not set, a fixed list of
233 // filesystems will be attempted. This setting is only used if
234 // |run_postinstall| is set and true.
235 optional string filesystem_type = 4;
236
Alex Deymoac6246a2015-08-13 14:00:22 -0700237 // If present, a list of signatures of the new_partition_info.hash signed with
238 // different keys. If the update_engine daemon requires vendor-signed images
239 // and has its public key installed, one of the signatures should be valid
240 // for /postinstall to run.
Alex Deymoeb86e552015-09-21 16:00:38 -0700241 repeated Signatures.Signature new_partition_signature = 5;
Alex Deymoac6246a2015-08-13 14:00:22 -0700242
Alex Deymoeb86e552015-09-21 16:00:38 -0700243 optional PartitionInfo old_partition_info = 6;
244 optional PartitionInfo new_partition_info = 7;
Alex Deymoac6246a2015-08-13 14:00:22 -0700245
246 // The list of operations to be performed to apply this PartitionUpdate. The
247 // associated operation blobs (in operations[i].data_offset, data_length)
248 // should be stored contiguously and in the same order.
Alex Deymoeb86e552015-09-21 16:00:38 -0700249 repeated InstallOperation operations = 8;
Alex Deymo5b91c6b2016-08-04 20:33:36 -0700250
251 // Whether a failure in the postinstall step for this partition should be
252 // ignored.
253 optional bool postinstall_optional = 9;
Sen Jiang57f91802017-11-14 17:42:13 -0800254
255 // On minor version 6 or newer, these fields are supported:
256
257 // The extent for data covered by verity hash tree.
258 optional Extent hash_tree_data_extent = 10;
259
260 // The extent to store verity hash tree.
261 optional Extent hash_tree_extent = 11;
262
263 // The hash algorithm used in verity hash tree.
264 optional string hash_tree_algorithm = 12;
265
266 // The salt used for verity hash tree.
267 optional bytes hash_tree_salt = 13;
268
269 // The extent for data covered by FEC.
270 optional Extent fec_data_extent = 14;
271
272 // The extent to store FEC.
273 optional Extent fec_extent = 15;
274
275 // The number of FEC roots.
276 optional uint32 fec_roots = 16 [default = 2];
Alex Deymoa12ee112015-08-12 22:19:32 -0700277}
278
Yifan Hong398cb542018-10-18 11:29:40 -0700279message DynamicPartitionGroup {
280 // Name of the group.
281 required string name = 1;
282
283 // Maximum size of the group. The sum of sizes of all partitions in the group
284 // must not exceed the maximum size of the group.
285 optional uint64 size = 2;
286
287 // A list of partitions that belong to the group.
288 repeated string partition_names = 3;
289}
290
291// Metadata related to all dynamic partitions.
292message DynamicPartitionMetadata {
293 // All updateable groups present in |partitions| of this DeltaArchiveManifest.
294 // - If an updatable group is on the device but not in the manifest, it is
295 // not updated. Hence, the group will not be resized, and partitions cannot
296 // be added to or removed from the group.
297 // - If an updatable group is in the manifest but not on the device, the group
298 // is added to the device.
299 repeated DynamicPartitionGroup groups = 1;
300}
301
Alex Deymoa12ee112015-08-12 22:19:32 -0700302message DeltaArchiveManifest {
Alex Deymoc1d7f122015-09-10 15:15:42 -0700303 // Only present in major version = 1. List of install operations for the
304 // kernel and rootfs partitions. For major version = 2 see the |partitions|
305 // field.
Amin Hassani55c75412019-10-07 11:20:39 -0700306 repeated InstallOperation install_operations = 1 [deprecated = true];
307 repeated InstallOperation kernel_install_operations = 2 [deprecated = true];
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800308
309 // (At time of writing) usually 4096
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700310 optional uint32 block_size = 3 [default = 4096];
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700311
312 // If signatures are present, the offset into the blobs, generally
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700313 // tacked onto the end of the file, and the length. We use an offset
314 // rather than a bool to allow for more flexibility in future file formats.
315 // If either is absent, it means signatures aren't supported in this
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700316 // file.
317 optional uint64 signatures_offset = 4;
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700318 optional uint64 signatures_size = 5;
Darin Petkov36a58222010-10-07 22:00:09 -0700319
Alex Deymoc1d7f122015-09-10 15:15:42 -0700320 // Only present in major version = 1. Partition metadata used to validate the
321 // update. For major version = 2 see the |partitions| field.
Amin Hassani55c75412019-10-07 11:20:39 -0700322 optional PartitionInfo old_kernel_info = 6 [deprecated = true];
323 optional PartitionInfo new_kernel_info = 7 [deprecated = true];
324 optional PartitionInfo old_rootfs_info = 8 [deprecated = true];
325 optional PartitionInfo new_rootfs_info = 9 [deprecated = true];
Don Garrett0dd39852013-04-03 16:55:42 -0700326
327 // old_image_info will only be present for delta images.
328 optional ImageInfo old_image_info = 10;
329
330 optional ImageInfo new_image_info = 11;
Don Garrettb8dd1d92013-11-22 17:40:02 -0800331
Alex Deymoc1d7f122015-09-10 15:15:42 -0700332 // The minor version, also referred as "delta version", of the payload.
Don Garrettb8dd1d92013-11-22 17:40:02 -0800333 optional uint32 minor_version = 12 [default = 0];
Alex Deymoac6246a2015-08-13 14:00:22 -0700334
Alex Deymoc1d7f122015-09-10 15:15:42 -0700335 // Only present in major version >= 2. List of partitions that will be
336 // updated, in the order they will be updated. This field replaces the
337 // |install_operations|, |kernel_install_operations| and the
338 // |{old,new}_{kernel,rootfs}_info| fields used in major version = 1. This
339 // array can have more than two partitions if needed, and they are identified
340 // by the partition name.
Alex Deymoac6246a2015-08-13 14:00:22 -0700341 repeated PartitionUpdate partitions = 13;
Sen Jiang5011df62017-06-28 17:13:19 -0700342
343 // The maximum timestamp of the OS allowed to apply this payload.
344 // Can be used to prevent downgrading the OS.
345 optional int64 max_timestamp = 14;
Yifan Hong398cb542018-10-18 11:29:40 -0700346
347 // Metadata related to all dynamic partitions.
348 optional DynamicPartitionMetadata dynamic_partition_metadata = 15;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800349}