blob: cf0d745ae7e88752f2c94c00ee0d3635abb7adf9 [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";
Andrew de los Reyes0c440052010-08-20 11:25:54 -070022// uint64 file_format_version = 1;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080023// uint64 manifest_size; // Size of protobuf DeltaArchiveManifest
24// // The Bzip2 compressed DeltaArchiveManifest
25// char manifest[];
adlr@google.com3defe6a2009-12-04 20:57:17 +000026//
27// // Data blobs for files, no specific format. The specific offset
28// // and length of each data blob is recorded in the DeltaArchiveManifest.
29// struct {
30// char data[];
31// } blobs[];
32//
Andrew de los Reyes94f025d2010-08-16 17:17:27 -070033// // These two are not signed:
34// uint64 signatures_message_size;
35// char signatures_message[];
36//
adlr@google.com3defe6a2009-12-04 20:57:17 +000037// };
38
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080039// The DeltaArchiveManifest protobuf is an ordered list of InstallOperation
40// objects. These objects are stored in a linear array in the
41// DeltaArchiveManifest. Each operation is applied in order by the client.
adlr@google.com3defe6a2009-12-04 20:57:17 +000042
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080043// The DeltaArchiveManifest also contains the initial and final
44// checksums for the device.
adlr@google.com3defe6a2009-12-04 20:57:17 +000045
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080046// The client will perform each InstallOperation in order, beginning even
47// before the entire delta file is downloaded (but after at least the
48// protobuf is downloaded). The types of operations are explained:
49// - REPLACE: Replace the dst_extents on the drive with the attached data,
50// zero padding out to block size.
51// - REPLACE_BZ: bzip2-uncompress the attached data and write it into
52// dst_extents on the drive, zero padding to block size.
53// - MOVE: Copy the data in src_extents to dst_extents. Extents may overlap,
54// so it may be desirable to read all src_extents data into memory before
55// writing it out.
56// - BSDIFF: Read src_length bytes from src_extents into memory, perform
57// bspatch with attached data, write new data to dst_extents, zero padding
58// to block size.
adlr@google.com3defe6a2009-12-04 20:57:17 +000059
60package chromeos_update_engine;
Alex Deymob8f16a12014-06-10 18:59:22 -070061option optimize_for = LITE_RUNTIME;
adlr@google.com3defe6a2009-12-04 20:57:17 +000062
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080063// Data is packed into blocks on disk, always starting from the beginning
64// of the block. If a file's data is too large for one block, it overflows
65// into another block, which may or may not be the following block on the
66// physical partition. An ordered list of extents is another
67// representation of an ordered list of blocks. For example, a file stored
68// in blocks 9, 10, 11, 2, 18, 12 (in that order) would be stored in
69// extents { {9, 3}, {2, 1}, {18, 1}, {12, 1} } (in that order).
70// In general, files are stored sequentially on disk, so it's more efficient
71// to use extents to encode the block lists (this is effectively
72// run-length encoding).
73// A sentinel value (kuint64max) as the start block denotes a sparse-hole
74// in a file whose block-length is specified by num_blocks.
adlr@google.com3defe6a2009-12-04 20:57:17 +000075
Andrew de los Reyes94f025d2010-08-16 17:17:27 -070076// Signatures: Updates may be signed by the OS vendor. The client verifies
77// an update's signature by hashing the entire download. The section of the
Jay Srinivasan74475bf2012-09-13 19:26:26 -070078// download that contains the signature is at the end of the file, so when
Andrew de los Reyes94f025d2010-08-16 17:17:27 -070079// signing a file, only the part up to the signature part is signed.
80// Then, the client looks inside the download's Signatures message for a
81// Signature message that it knows how to handle. Generally, a client will
82// only know how to handle one type of signature, but an update may contain
83// many signatures to support many different types of client. Then client
84// selects a Signature message and uses that, along with a known public key,
85// to verify the download. The public key is expected to be part of the
86// client.
87
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080088message Extent {
89 optional uint64 start_block = 1;
90 optional uint64 num_blocks = 2;
adlr@google.com3defe6a2009-12-04 20:57:17 +000091}
92
Andrew de los Reyes94f025d2010-08-16 17:17:27 -070093message Signatures {
94 message Signature {
95 optional uint32 version = 1;
Andrew de los Reyes0c440052010-08-20 11:25:54 -070096 optional bytes data = 2;
Andrew de los Reyes94f025d2010-08-16 17:17:27 -070097 }
98 repeated Signature signatures = 1;
99}
100
Darin Petkov36a58222010-10-07 22:00:09 -0700101message PartitionInfo {
102 optional uint64 size = 1;
103 optional bytes hash = 2;
104}
105
Don Garrett0dd39852013-04-03 16:55:42 -0700106// Describe an image we are based on in a human friendly way.
107// Examples:
108// dev-channel, x86-alex, 1.2.3, mp-v3
109// nplusone-channel, x86-alex, 1.2.4, mp-v3, dev-channel, 1.2.3
110//
111// All fields will be set, if this message is present.
112message ImageInfo {
113 optional string board = 1;
114 optional string key = 2;
115 optional string channel = 3;
116 optional string version = 4;
117
118 // If these values aren't present, they should be assumed to match
119 // the equivalent value above. They are normally only different for
120 // special image types such as nplusone images.
121 optional string build_channel = 5;
122 optional string build_version = 6;
123}
124
Alex Deymoa12ee112015-08-12 22:19:32 -0700125message InstallOperation {
126 enum Type {
127 REPLACE = 0; // Replace destination extents w/ attached data
128 REPLACE_BZ = 1; // Replace destination extents w/ attached bzipped data
129 MOVE = 2; // Move source extents to destination extents
130 BSDIFF = 3; // The data is a bsdiff binary diff
Alex Deymoac6246a2015-08-13 14:00:22 -0700131
132 // SOURCE_COPY and SOURCE_BSDIFF are only supported on minor version 2 or
133 // higher.
Alex Deymoa12ee112015-08-12 22:19:32 -0700134 SOURCE_COPY = 4; // Copy from source to target partition
135 SOURCE_BSDIFF = 5; // Like BSDIFF, but read from source partition
Alex Deymoac6246a2015-08-13 14:00:22 -0700136
137 // ZERO and DISCARD are only supported on minor version 3.
138 ZERO = 6; // Write zeros in the destination.
139 DISCARD = 7; // Discard the destination blocks, reading as undefined.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800140 }
Alex Deymoa12ee112015-08-12 22:19:32 -0700141 required Type type = 1;
142 // The offset into the delta file (after the protobuf)
143 // where the data (if any) is stored
144 optional uint32 data_offset = 2;
145 // The length of the data in the delta file
146 optional uint32 data_length = 3;
147
148 // Ordered list of extents that are read from (if any) and written to.
149 repeated Extent src_extents = 4;
150 // Byte length of src, equal to the number of blocks in src_extents *
151 // block_size. It is used for BSDIFF, because we need to pass that
152 // external program the number of bytes to read from the blocks we pass it.
153 // This is not used in any other operation.
154 optional uint64 src_length = 5;
155
156 repeated Extent dst_extents = 6;
157 // Byte length of dst, equal to the number of blocks in dst_extents *
158 // block_size. Used for BSDIFF, but not in any other operation.
159 optional uint64 dst_length = 7;
160
161 // Optional SHA 256 hash of the blob associated with this operation.
162 // This is used as a primary validation for http-based downloads and
163 // as a defense-in-depth validation for https-based downloads. If
164 // the operation doesn't refer to any blob, this field will have
165 // zero bytes.
166 optional bytes data_sha256_hash = 8;
Alex Deymoac6246a2015-08-13 14:00:22 -0700167
168 // Indicates the SHA 256 hash of the source data referenced in src_extents at
169 // the time of applying the operation. If present, the update_engine daemon
170 // MUST read and verify the source data before applying the operation.
171 optional bytes src_sha256_hash = 9;
172}
173
174// Describes the update to apply to a single partition.
175message PartitionUpdate {
176 // A platform-specific name to identify the partition set being updated. For
177 // example, in Chrome OS this could be "ROOT" or "KERNEL".
178 required string partition_name = 1;
179
180 // Whether this partition carries a filesystem with a "/postinstall" script
181 // that must be run to finalize the update process.
182 optional bool run_postinstall = 2;
183
184 // If present, a list of signatures of the new_partition_info.hash signed with
185 // different keys. If the update_engine daemon requires vendor-signed images
186 // and has its public key installed, one of the signatures should be valid
187 // for /postinstall to run.
188 repeated Signatures.Signature new_partition_signature = 3;
189
190 optional PartitionInfo old_partition_info = 4;
191 optional PartitionInfo new_partition_info = 5;
192
193 // The list of operations to be performed to apply this PartitionUpdate. The
194 // associated operation blobs (in operations[i].data_offset, data_length)
195 // should be stored contiguously and in the same order.
196 repeated InstallOperation operations = 6;
Alex Deymoa12ee112015-08-12 22:19:32 -0700197}
198
199message DeltaArchiveManifest {
Alex Deymoac6246a2015-08-13 14:00:22 -0700200 // DEPRECATED. List of install operations for the kernel and rootfs
201 // partitions. This information is now present in the |partitions| field. If
202 // you set these fields instead of the ones in the PartitionUpdate, they will
203 // be migrated to the corresponding entries in the PartitionUpdate to support
204 // full payloads on legacy daemons. Delta payloads starting with minor_version
205 // 3 MAY NOT include these fields.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800206 repeated InstallOperation install_operations = 1;
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700207 repeated InstallOperation kernel_install_operations = 2;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800208
209 // (At time of writing) usually 4096
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700210 optional uint32 block_size = 3 [default = 4096];
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700211
212 // If signatures are present, the offset into the blobs, generally
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700213 // tacked onto the end of the file, and the length. We use an offset
214 // rather than a bool to allow for more flexibility in future file formats.
215 // If either is absent, it means signatures aren't supported in this
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700216 // file.
217 optional uint64 signatures_offset = 4;
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700218 optional uint64 signatures_size = 5;
Darin Petkov36a58222010-10-07 22:00:09 -0700219
Alex Deymoac6246a2015-08-13 14:00:22 -0700220 // DEPRECATED. Partition metadata used to validate the update.
221 // This information is now present in the |partitions| field. If you set
222 // these fields instead of the ones in the PartitionUpdate, they will be
223 // migrated to the corresponding entries in the PartitionUpdate to support
224 // full payloads on legacy daemons. Delta payloads starting with minor_version
225 // 3 MAY NOT include these fields.
Darin Petkov36a58222010-10-07 22:00:09 -0700226 optional PartitionInfo old_kernel_info = 6;
227 optional PartitionInfo new_kernel_info = 7;
228 optional PartitionInfo old_rootfs_info = 8;
229 optional PartitionInfo new_rootfs_info = 9;
Don Garrett0dd39852013-04-03 16:55:42 -0700230
231 // old_image_info will only be present for delta images.
232 optional ImageInfo old_image_info = 10;
233
234 optional ImageInfo new_image_info = 11;
Don Garrettb8dd1d92013-11-22 17:40:02 -0800235
236 optional uint32 minor_version = 12 [default = 0];
Alex Deymoac6246a2015-08-13 14:00:22 -0700237
238 // List of partitions that will be updated, in the order they will be updated.
239 repeated PartitionUpdate partitions = 13;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800240}