blob: 1657a7e293a638cd310e444d5bb8fb7ee351b9b9 [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
Sen Jiangcb131242019-01-22 17:07:58 -080017// Update file format: An update file contains all the operations needed
18// to update a system to a specific version. It can be a full payload which
19// can update from any version, or a delta payload which can only update
20// from a specific version.
21// The update format is represented by this struct pseudocode:
adlr@google.com3defe6a2009-12-04 20:57:17 +000022// struct delta_update_file {
23// char magic[4] = "CrAU";
Sen Jiangcb131242019-01-22 17:07:58 -080024// uint64 file_format_version; // payload major version
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080025// uint64 manifest_size; // Size of protobuf DeltaArchiveManifest
Alex Deymoc1d7f122015-09-10 15:15:42 -070026//
Sen Jiangcb131242019-01-22 17:07:58 -080027// // Only present if format_version >= 2:
Alex Deymoc1d7f122015-09-10 15:15:42 -070028// uint32 metadata_signature_size;
29//
Sen Jiangcb131242019-01-22 17:07:58 -080030// // The DeltaArchiveManifest protobuf serialized, not compressed.
31// char manifest[manifest_size];
adlr@google.com3defe6a2009-12-04 20:57:17 +000032//
Alex Deymoc1d7f122015-09-10 15:15:42 -070033// // The signature of the metadata (from the beginning of the payload up to
34// // this location, not including the signature itself). This is a serialized
35// // Signatures message.
Sen Jiangcb131242019-01-22 17:07:58 -080036// char metadata_signature_message[metadata_signature_size];
Alex Deymoc1d7f122015-09-10 15:15:42 -070037//
adlr@google.com3defe6a2009-12-04 20:57:17 +000038// // Data blobs for files, no specific format. The specific offset
39// // and length of each data blob is recorded in the DeltaArchiveManifest.
40// struct {
41// char data[];
42// } blobs[];
43//
Sen Jiangcb131242019-01-22 17:07:58 -080044// // The signature of the entire payload, everything up to this location,
45// // except that metadata_signature_message is skipped to simplify signing
46// // process. These two are not signed:
Alex Deymoc1d7f122015-09-10 15:15:42 -070047// uint64 payload_signatures_message_size;
Sen Jiangcb131242019-01-22 17:07:58 -080048// // This is a serialized Signatures message.
49// char payload_signatures_message[payload_signatures_message_size];
Andrew de los Reyes94f025d2010-08-16 17:17:27 -070050//
adlr@google.com3defe6a2009-12-04 20:57:17 +000051// };
52
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080053// The DeltaArchiveManifest protobuf is an ordered list of InstallOperation
54// objects. These objects are stored in a linear array in the
55// DeltaArchiveManifest. Each operation is applied in order by the client.
adlr@google.com3defe6a2009-12-04 20:57:17 +000056
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080057// The DeltaArchiveManifest also contains the initial and final
58// checksums for the device.
adlr@google.com3defe6a2009-12-04 20:57:17 +000059
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080060// The client will perform each InstallOperation in order, beginning even
61// before the entire delta file is downloaded (but after at least the
62// protobuf is downloaded). The types of operations are explained:
63// - REPLACE: Replace the dst_extents on the drive with the attached data,
64// zero padding out to block size.
65// - REPLACE_BZ: bzip2-uncompress the attached data and write it into
66// dst_extents on the drive, zero padding to block size.
67// - MOVE: Copy the data in src_extents to dst_extents. Extents may overlap,
68// so it may be desirable to read all src_extents data into memory before
Sen Jiangcb131242019-01-22 17:07:58 -080069// writing it out. (deprecated)
Alex Deymoc1d7f122015-09-10 15:15:42 -070070// - SOURCE_COPY: Copy the data in src_extents in the old partition to
71// dst_extents in the new partition. There's no overlapping of data because
72// the extents are in different partitions.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080073// - BSDIFF: Read src_length bytes from src_extents into memory, perform
74// bspatch with attached data, write new data to dst_extents, zero padding
Sen Jiangcb131242019-01-22 17:07:58 -080075// to block size. (deprecated)
Alex Deymoc1d7f122015-09-10 15:15:42 -070076// - SOURCE_BSDIFF: Read the data in src_extents in the old partition, perform
77// bspatch with the attached data and write the new data to dst_extents in the
78// new partition.
79// - ZERO: Write zeros to the destination dst_extents.
80// - DISCARD: Discard the destination dst_extents blocks on the physical medium.
81// the data read from those block is undefined.
82// - REPLACE_XZ: Replace the dst_extents with the contents of the attached
83// xz file after decompression. The xz file should only use crc32 or no crc at
84// all to be compatible with xz-embedded.
Amin Hassanicdeb6e62017-10-11 10:15:11 -070085// - PUFFDIFF: Read the data in src_extents in the old partition, perform
86// puffpatch with the attached data and write the new data to dst_extents in
87// the new partition.
Alex Deymoc1d7f122015-09-10 15:15:42 -070088//
89// The operations allowed in the payload (supported by the client) depend on the
Sen Jiang771f6482018-04-04 17:59:10 -070090// major and minor version. See InstallOperation.Type below for details.
adlr@google.com3defe6a2009-12-04 20:57:17 +000091
Amin Hassani489875a2017-08-04 13:20:52 -070092syntax = "proto2";
93
adlr@google.com3defe6a2009-12-04 20:57:17 +000094package chromeos_update_engine;
Alex Deymob8f16a12014-06-10 18:59:22 -070095option optimize_for = LITE_RUNTIME;
adlr@google.com3defe6a2009-12-04 20:57:17 +000096
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080097// Data is packed into blocks on disk, always starting from the beginning
98// of the block. If a file's data is too large for one block, it overflows
99// into another block, which may or may not be the following block on the
100// physical partition. An ordered list of extents is another
101// representation of an ordered list of blocks. For example, a file stored
102// in blocks 9, 10, 11, 2, 18, 12 (in that order) would be stored in
103// extents { {9, 3}, {2, 1}, {18, 1}, {12, 1} } (in that order).
104// In general, files are stored sequentially on disk, so it's more efficient
105// to use extents to encode the block lists (this is effectively
106// run-length encoding).
107// A sentinel value (kuint64max) as the start block denotes a sparse-hole
108// in a file whose block-length is specified by num_blocks.
adlr@google.com3defe6a2009-12-04 20:57:17 +0000109
Sen Jiangcb131242019-01-22 17:07:58 -0800110message Extent {
111 optional uint64 start_block = 1;
112 optional uint64 num_blocks = 2;
113}
114
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700115// Signatures: Updates may be signed by the OS vendor. The client verifies
116// an update's signature by hashing the entire download. The section of the
Jay Srinivasan74475bf2012-09-13 19:26:26 -0700117// download that contains the signature is at the end of the file, so when
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700118// signing a file, only the part up to the signature part is signed.
119// Then, the client looks inside the download's Signatures message for a
120// Signature message that it knows how to handle. Generally, a client will
121// only know how to handle one type of signature, but an update may contain
122// many signatures to support many different types of client. Then client
123// selects a Signature message and uses that, along with a known public key,
124// to verify the download. The public key is expected to be part of the
125// client.
126
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700127message Signatures {
128 message Signature {
129 optional uint32 version = 1;
Andrew de los Reyes0c440052010-08-20 11:25:54 -0700130 optional bytes data = 2;
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700131 }
132 repeated Signature signatures = 1;
133}
134
Darin Petkov36a58222010-10-07 22:00:09 -0700135message PartitionInfo {
136 optional uint64 size = 1;
137 optional bytes hash = 2;
138}
139
Don Garrett0dd39852013-04-03 16:55:42 -0700140// Describe an image we are based on in a human friendly way.
141// Examples:
142// dev-channel, x86-alex, 1.2.3, mp-v3
143// nplusone-channel, x86-alex, 1.2.4, mp-v3, dev-channel, 1.2.3
144//
145// All fields will be set, if this message is present.
146message ImageInfo {
147 optional string board = 1;
148 optional string key = 2;
149 optional string channel = 3;
150 optional string version = 4;
151
152 // If these values aren't present, they should be assumed to match
153 // the equivalent value above. They are normally only different for
154 // special image types such as nplusone images.
155 optional string build_channel = 5;
156 optional string build_version = 6;
157}
158
Alex Deymoa12ee112015-08-12 22:19:32 -0700159message InstallOperation {
160 enum Type {
161 REPLACE = 0; // Replace destination extents w/ attached data
162 REPLACE_BZ = 1; // Replace destination extents w/ attached bzipped data
Sen Jiangcb131242019-01-22 17:07:58 -0800163 MOVE = 2 [deprecated = true]; // Move source extents to destination extents
164 BSDIFF = 3 [deprecated = true]; // The data is a bsdiff binary diff
Alex Deymoac6246a2015-08-13 14:00:22 -0700165
Alex Deymoc1d7f122015-09-10 15:15:42 -0700166 // On minor version 2 or newer, these operations are supported:
Alex Deymoa12ee112015-08-12 22:19:32 -0700167 SOURCE_COPY = 4; // Copy from source to target partition
168 SOURCE_BSDIFF = 5; // Like BSDIFF, but read from source partition
Alex Deymoac6246a2015-08-13 14:00:22 -0700169
Alex Deymoc1d7f122015-09-10 15:15:42 -0700170 // On minor version 3 or newer and on major version 2 or newer, these
171 // operations are supported:
Alex Deymoc1d7f122015-09-10 15:15:42 -0700172 REPLACE_XZ = 8; // Replace destination extents w/ attached xz data.
Sen Jiang3317b882016-01-08 17:48:57 +0800173
174 // On minor version 4 or newer, these operations are supported:
Amin Hassanidf3a8662017-12-07 12:17:45 -0800175 ZERO = 6; // Write zeros in the destination.
176 DISCARD = 7; // Discard the destination blocks, reading as undefined.
Amin Hassaniefa62d92017-11-09 13:46:56 -0800177 BROTLI_BSDIFF = 10; // Like SOURCE_BSDIFF, but compressed with brotli.
Amin Hassani77d7cbc2018-02-07 16:21:33 -0800178
179 // On minor version 5 or newer, these operations are supported:
180 PUFFDIFF = 9; // The data is in puffdiff format.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800181 }
Alex Deymoa12ee112015-08-12 22:19:32 -0700182 required Type type = 1;
Sen Jiang9edcd042018-11-12 16:46:06 -0800183
184 // Only minor version 6 or newer support 64 bits |data_offset| and
185 // |data_length|, older client will read them as uint32.
Alex Deymoa12ee112015-08-12 22:19:32 -0700186 // The offset into the delta file (after the protobuf)
187 // where the data (if any) is stored
Sen Jiang9edcd042018-11-12 16:46:06 -0800188 optional uint64 data_offset = 2;
Alex Deymoa12ee112015-08-12 22:19:32 -0700189 // The length of the data in the delta file
Sen Jiang9edcd042018-11-12 16:46:06 -0800190 optional uint64 data_length = 3;
Alex Deymoa12ee112015-08-12 22:19:32 -0700191
192 // Ordered list of extents that are read from (if any) and written to.
193 repeated Extent src_extents = 4;
194 // Byte length of src, equal to the number of blocks in src_extents *
Amin Hassanif5a06d82017-10-19 15:06:38 -0700195 // block_size. It is used for BSDIFF and SOURCE_BSDIFF, because we need to
196 // pass that external program the number of bytes to read from the blocks we
197 // pass it. This is not used in any other operation.
Alex Deymoa12ee112015-08-12 22:19:32 -0700198 optional uint64 src_length = 5;
199
200 repeated Extent dst_extents = 6;
201 // Byte length of dst, equal to the number of blocks in dst_extents *
Amin Hassanif5a06d82017-10-19 15:06:38 -0700202 // block_size. Used for BSDIFF and SOURCE_BSDIFF, but not in any other
203 // operation.
Alex Deymoa12ee112015-08-12 22:19:32 -0700204 optional uint64 dst_length = 7;
205
206 // Optional SHA 256 hash of the blob associated with this operation.
207 // This is used as a primary validation for http-based downloads and
208 // as a defense-in-depth validation for https-based downloads. If
209 // the operation doesn't refer to any blob, this field will have
210 // zero bytes.
211 optional bytes data_sha256_hash = 8;
Alex Deymoac6246a2015-08-13 14:00:22 -0700212
213 // Indicates the SHA 256 hash of the source data referenced in src_extents at
214 // the time of applying the operation. If present, the update_engine daemon
215 // MUST read and verify the source data before applying the operation.
216 optional bytes src_sha256_hash = 9;
217}
218
219// Describes the update to apply to a single partition.
220message PartitionUpdate {
221 // A platform-specific name to identify the partition set being updated. For
222 // example, in Chrome OS this could be "ROOT" or "KERNEL".
223 required string partition_name = 1;
224
Alex Deymoeb86e552015-09-21 16:00:38 -0700225 // Whether this partition carries a filesystem with post-install program that
226 // must be run to finalize the update process. See also |postinstall_path| and
227 // |filesystem_type|.
Alex Deymoac6246a2015-08-13 14:00:22 -0700228 optional bool run_postinstall = 2;
229
Alex Deymoeb86e552015-09-21 16:00:38 -0700230 // The path of the executable program to run during the post-install step,
231 // relative to the root of this filesystem. If not set, the default "postinst"
232 // will be used. This setting is only used when |run_postinstall| is set and
233 // true.
234 optional string postinstall_path = 3;
235
236 // The filesystem type as passed to the mount(2) syscall when mounting the new
237 // filesystem to run the post-install program. If not set, a fixed list of
238 // filesystems will be attempted. This setting is only used if
239 // |run_postinstall| is set and true.
240 optional string filesystem_type = 4;
241
Alex Deymoac6246a2015-08-13 14:00:22 -0700242 // If present, a list of signatures of the new_partition_info.hash signed with
243 // different keys. If the update_engine daemon requires vendor-signed images
244 // and has its public key installed, one of the signatures should be valid
245 // for /postinstall to run.
Alex Deymoeb86e552015-09-21 16:00:38 -0700246 repeated Signatures.Signature new_partition_signature = 5;
Alex Deymoac6246a2015-08-13 14:00:22 -0700247
Alex Deymoeb86e552015-09-21 16:00:38 -0700248 optional PartitionInfo old_partition_info = 6;
249 optional PartitionInfo new_partition_info = 7;
Alex Deymoac6246a2015-08-13 14:00:22 -0700250
251 // The list of operations to be performed to apply this PartitionUpdate. The
252 // associated operation blobs (in operations[i].data_offset, data_length)
253 // should be stored contiguously and in the same order.
Alex Deymoeb86e552015-09-21 16:00:38 -0700254 repeated InstallOperation operations = 8;
Alex Deymo5b91c6b2016-08-04 20:33:36 -0700255
256 // Whether a failure in the postinstall step for this partition should be
257 // ignored.
258 optional bool postinstall_optional = 9;
Sen Jiang57f91802017-11-14 17:42:13 -0800259
260 // On minor version 6 or newer, these fields are supported:
261
262 // The extent for data covered by verity hash tree.
263 optional Extent hash_tree_data_extent = 10;
264
265 // The extent to store verity hash tree.
266 optional Extent hash_tree_extent = 11;
267
268 // The hash algorithm used in verity hash tree.
269 optional string hash_tree_algorithm = 12;
270
271 // The salt used for verity hash tree.
272 optional bytes hash_tree_salt = 13;
273
274 // The extent for data covered by FEC.
275 optional Extent fec_data_extent = 14;
276
277 // The extent to store FEC.
278 optional Extent fec_extent = 15;
279
280 // The number of FEC roots.
281 optional uint32 fec_roots = 16 [default = 2];
Alex Deymoa12ee112015-08-12 22:19:32 -0700282}
283
Yifan Hong398cb542018-10-18 11:29:40 -0700284message DynamicPartitionGroup {
285 // Name of the group.
286 required string name = 1;
287
288 // Maximum size of the group. The sum of sizes of all partitions in the group
289 // must not exceed the maximum size of the group.
290 optional uint64 size = 2;
291
292 // A list of partitions that belong to the group.
293 repeated string partition_names = 3;
294}
295
296// Metadata related to all dynamic partitions.
297message DynamicPartitionMetadata {
Sen Jiangcb131242019-01-22 17:07:58 -0800298 // All updatable groups present in |partitions| of this DeltaArchiveManifest.
Yifan Hong398cb542018-10-18 11:29:40 -0700299 // - If an updatable group is on the device but not in the manifest, it is
300 // not updated. Hence, the group will not be resized, and partitions cannot
301 // be added to or removed from the group.
302 // - If an updatable group is in the manifest but not on the device, the group
303 // is added to the device.
304 repeated DynamicPartitionGroup groups = 1;
Yifan Hong05b3b962019-09-26 17:19:21 -0700305
306 // Whether dynamic partitions have snapshots during the update. If this is
307 // set to true, the update_engine daemon creates snapshots for all dynamic
308 // partitions if possible. If this is unset, the update_engine daemon MUST
309 // NOT create snapshots for dynamic partitions.
310 optional bool snapshot_enabled = 2;
Yifan Hong398cb542018-10-18 11:29:40 -0700311}
312
Alex Deymoa12ee112015-08-12 22:19:32 -0700313message DeltaArchiveManifest {
Alex Deymoc1d7f122015-09-10 15:15:42 -0700314 // Only present in major version = 1. List of install operations for the
315 // kernel and rootfs partitions. For major version = 2 see the |partitions|
316 // field.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800317 repeated InstallOperation install_operations = 1;
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700318 repeated InstallOperation kernel_install_operations = 2;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800319
320 // (At time of writing) usually 4096
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700321 optional uint32 block_size = 3 [default = 4096];
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700322
323 // If signatures are present, the offset into the blobs, generally
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700324 // tacked onto the end of the file, and the length. We use an offset
325 // rather than a bool to allow for more flexibility in future file formats.
326 // If either is absent, it means signatures aren't supported in this
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700327 // file.
328 optional uint64 signatures_offset = 4;
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700329 optional uint64 signatures_size = 5;
Darin Petkov36a58222010-10-07 22:00:09 -0700330
Alex Deymoc1d7f122015-09-10 15:15:42 -0700331 // Only present in major version = 1. Partition metadata used to validate the
332 // update. For major version = 2 see the |partitions| field.
Darin Petkov36a58222010-10-07 22:00:09 -0700333 optional PartitionInfo old_kernel_info = 6;
334 optional PartitionInfo new_kernel_info = 7;
335 optional PartitionInfo old_rootfs_info = 8;
336 optional PartitionInfo new_rootfs_info = 9;
Don Garrett0dd39852013-04-03 16:55:42 -0700337
338 // old_image_info will only be present for delta images.
339 optional ImageInfo old_image_info = 10;
340
341 optional ImageInfo new_image_info = 11;
Don Garrettb8dd1d92013-11-22 17:40:02 -0800342
Alex Deymoc1d7f122015-09-10 15:15:42 -0700343 // The minor version, also referred as "delta version", of the payload.
Sen Jiangcb131242019-01-22 17:07:58 -0800344 // Minor version 0 is full payload, everything else is delta payload.
Don Garrettb8dd1d92013-11-22 17:40:02 -0800345 optional uint32 minor_version = 12 [default = 0];
Alex Deymoac6246a2015-08-13 14:00:22 -0700346
Alex Deymoc1d7f122015-09-10 15:15:42 -0700347 // Only present in major version >= 2. List of partitions that will be
348 // updated, in the order they will be updated. This field replaces the
349 // |install_operations|, |kernel_install_operations| and the
350 // |{old,new}_{kernel,rootfs}_info| fields used in major version = 1. This
351 // array can have more than two partitions if needed, and they are identified
352 // by the partition name.
Alex Deymoac6246a2015-08-13 14:00:22 -0700353 repeated PartitionUpdate partitions = 13;
Sen Jiang5011df62017-06-28 17:13:19 -0700354
355 // The maximum timestamp of the OS allowed to apply this payload.
356 // Can be used to prevent downgrading the OS.
357 optional int64 max_timestamp = 14;
Yifan Hong398cb542018-10-18 11:29:40 -0700358
359 // Metadata related to all dynamic partitions.
360 optional DynamicPartitionMetadata dynamic_partition_metadata = 15;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800361}