blob: be97c264cd381610a9ffedb82e7b51b0cc67c2cd [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.
80//
81// The operations allowed in the payload (supported by the client) depend on the
82// major and minor version. See InstallOperation.Type bellow for details.
adlr@google.com3defe6a2009-12-04 20:57:17 +000083
84package chromeos_update_engine;
Alex Deymob8f16a12014-06-10 18:59:22 -070085option optimize_for = LITE_RUNTIME;
adlr@google.com3defe6a2009-12-04 20:57:17 +000086
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080087// Data is packed into blocks on disk, always starting from the beginning
88// of the block. If a file's data is too large for one block, it overflows
89// into another block, which may or may not be the following block on the
90// physical partition. An ordered list of extents is another
91// representation of an ordered list of blocks. For example, a file stored
92// in blocks 9, 10, 11, 2, 18, 12 (in that order) would be stored in
93// extents { {9, 3}, {2, 1}, {18, 1}, {12, 1} } (in that order).
94// In general, files are stored sequentially on disk, so it's more efficient
95// to use extents to encode the block lists (this is effectively
96// run-length encoding).
97// A sentinel value (kuint64max) as the start block denotes a sparse-hole
98// in a file whose block-length is specified by num_blocks.
adlr@google.com3defe6a2009-12-04 20:57:17 +000099
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700100// Signatures: Updates may be signed by the OS vendor. The client verifies
101// an update's signature by hashing the entire download. The section of the
Jay Srinivasan74475bf2012-09-13 19:26:26 -0700102// download that contains the signature is at the end of the file, so when
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700103// signing a file, only the part up to the signature part is signed.
104// Then, the client looks inside the download's Signatures message for a
105// Signature message that it knows how to handle. Generally, a client will
106// only know how to handle one type of signature, but an update may contain
107// many signatures to support many different types of client. Then client
108// selects a Signature message and uses that, along with a known public key,
109// to verify the download. The public key is expected to be part of the
110// client.
111
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800112message Extent {
113 optional uint64 start_block = 1;
114 optional uint64 num_blocks = 2;
adlr@google.com3defe6a2009-12-04 20:57:17 +0000115}
116
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700117message Signatures {
118 message Signature {
119 optional uint32 version = 1;
Andrew de los Reyes0c440052010-08-20 11:25:54 -0700120 optional bytes data = 2;
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700121 }
122 repeated Signature signatures = 1;
123}
124
Darin Petkov36a58222010-10-07 22:00:09 -0700125message PartitionInfo {
126 optional uint64 size = 1;
127 optional bytes hash = 2;
128}
129
Don Garrett0dd39852013-04-03 16:55:42 -0700130// Describe an image we are based on in a human friendly way.
131// Examples:
132// dev-channel, x86-alex, 1.2.3, mp-v3
133// nplusone-channel, x86-alex, 1.2.4, mp-v3, dev-channel, 1.2.3
134//
135// All fields will be set, if this message is present.
136message ImageInfo {
137 optional string board = 1;
138 optional string key = 2;
139 optional string channel = 3;
140 optional string version = 4;
141
142 // If these values aren't present, they should be assumed to match
143 // the equivalent value above. They are normally only different for
144 // special image types such as nplusone images.
145 optional string build_channel = 5;
146 optional string build_version = 6;
147}
148
Alex Deymoa12ee112015-08-12 22:19:32 -0700149message InstallOperation {
150 enum Type {
151 REPLACE = 0; // Replace destination extents w/ attached data
152 REPLACE_BZ = 1; // Replace destination extents w/ attached bzipped data
153 MOVE = 2; // Move source extents to destination extents
154 BSDIFF = 3; // The data is a bsdiff binary diff
Alex Deymoac6246a2015-08-13 14:00:22 -0700155
Alex Deymoc1d7f122015-09-10 15:15:42 -0700156 // On minor version 2 or newer, these operations are supported:
Alex Deymoa12ee112015-08-12 22:19:32 -0700157 SOURCE_COPY = 4; // Copy from source to target partition
158 SOURCE_BSDIFF = 5; // Like BSDIFF, but read from source partition
Alex Deymoac6246a2015-08-13 14:00:22 -0700159
Alex Deymoc1d7f122015-09-10 15:15:42 -0700160 // On minor version 3 or newer and on major version 2 or newer, these
161 // operations are supported:
Alex Deymoac6246a2015-08-13 14:00:22 -0700162 ZERO = 6; // Write zeros in the destination.
163 DISCARD = 7; // Discard the destination blocks, reading as undefined.
Alex Deymoc1d7f122015-09-10 15:15:42 -0700164 REPLACE_XZ = 8; // Replace destination extents w/ attached xz data.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800165 }
Alex Deymoa12ee112015-08-12 22:19:32 -0700166 required Type type = 1;
167 // The offset into the delta file (after the protobuf)
168 // where the data (if any) is stored
169 optional uint32 data_offset = 2;
170 // The length of the data in the delta file
171 optional uint32 data_length = 3;
172
173 // Ordered list of extents that are read from (if any) and written to.
174 repeated Extent src_extents = 4;
175 // Byte length of src, equal to the number of blocks in src_extents *
176 // block_size. It is used for BSDIFF, because we need to pass that
177 // external program the number of bytes to read from the blocks we pass it.
178 // This is not used in any other operation.
179 optional uint64 src_length = 5;
180
181 repeated Extent dst_extents = 6;
182 // Byte length of dst, equal to the number of blocks in dst_extents *
183 // block_size. Used for BSDIFF, but not in any other operation.
184 optional uint64 dst_length = 7;
185
186 // Optional SHA 256 hash of the blob associated with this operation.
187 // This is used as a primary validation for http-based downloads and
188 // as a defense-in-depth validation for https-based downloads. If
189 // the operation doesn't refer to any blob, this field will have
190 // zero bytes.
191 optional bytes data_sha256_hash = 8;
Alex Deymoac6246a2015-08-13 14:00:22 -0700192
193 // Indicates the SHA 256 hash of the source data referenced in src_extents at
194 // the time of applying the operation. If present, the update_engine daemon
195 // MUST read and verify the source data before applying the operation.
196 optional bytes src_sha256_hash = 9;
197}
198
199// Describes the update to apply to a single partition.
200message PartitionUpdate {
201 // A platform-specific name to identify the partition set being updated. For
202 // example, in Chrome OS this could be "ROOT" or "KERNEL".
203 required string partition_name = 1;
204
205 // Whether this partition carries a filesystem with a "/postinstall" script
206 // that must be run to finalize the update process.
207 optional bool run_postinstall = 2;
208
209 // If present, a list of signatures of the new_partition_info.hash signed with
210 // different keys. If the update_engine daemon requires vendor-signed images
211 // and has its public key installed, one of the signatures should be valid
212 // for /postinstall to run.
213 repeated Signatures.Signature new_partition_signature = 3;
214
215 optional PartitionInfo old_partition_info = 4;
216 optional PartitionInfo new_partition_info = 5;
217
218 // The list of operations to be performed to apply this PartitionUpdate. The
219 // associated operation blobs (in operations[i].data_offset, data_length)
220 // should be stored contiguously and in the same order.
221 repeated InstallOperation operations = 6;
Alex Deymoa12ee112015-08-12 22:19:32 -0700222}
223
224message DeltaArchiveManifest {
Alex Deymoc1d7f122015-09-10 15:15:42 -0700225 // Only present in major version = 1. List of install operations for the
226 // kernel and rootfs partitions. For major version = 2 see the |partitions|
227 // field.
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800228 repeated InstallOperation install_operations = 1;
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700229 repeated InstallOperation kernel_install_operations = 2;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800230
231 // (At time of writing) usually 4096
Andrew de los Reyesf4c7ef12010-04-30 10:37:00 -0700232 optional uint32 block_size = 3 [default = 4096];
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700233
234 // If signatures are present, the offset into the blobs, generally
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700235 // tacked onto the end of the file, and the length. We use an offset
236 // rather than a bool to allow for more flexibility in future file formats.
237 // If either is absent, it means signatures aren't supported in this
Andrew de los Reyes94f025d2010-08-16 17:17:27 -0700238 // file.
239 optional uint64 signatures_offset = 4;
Andrew de los Reyes932bc4c2010-08-23 18:14:09 -0700240 optional uint64 signatures_size = 5;
Darin Petkov36a58222010-10-07 22:00:09 -0700241
Alex Deymoc1d7f122015-09-10 15:15:42 -0700242 // Only present in major version = 1. Partition metadata used to validate the
243 // update. For major version = 2 see the |partitions| field.
Darin Petkov36a58222010-10-07 22:00:09 -0700244 optional PartitionInfo old_kernel_info = 6;
245 optional PartitionInfo new_kernel_info = 7;
246 optional PartitionInfo old_rootfs_info = 8;
247 optional PartitionInfo new_rootfs_info = 9;
Don Garrett0dd39852013-04-03 16:55:42 -0700248
249 // old_image_info will only be present for delta images.
250 optional ImageInfo old_image_info = 10;
251
252 optional ImageInfo new_image_info = 11;
Don Garrettb8dd1d92013-11-22 17:40:02 -0800253
Alex Deymoc1d7f122015-09-10 15:15:42 -0700254 // The minor version, also referred as "delta version", of the payload.
Don Garrettb8dd1d92013-11-22 17:40:02 -0800255 optional uint32 minor_version = 12 [default = 0];
Alex Deymoac6246a2015-08-13 14:00:22 -0700256
Alex Deymoc1d7f122015-09-10 15:15:42 -0700257 // Only present in major version >= 2. List of partitions that will be
258 // updated, in the order they will be updated. This field replaces the
259 // |install_operations|, |kernel_install_operations| and the
260 // |{old,new}_{kernel,rootfs}_info| fields used in major version = 1. This
261 // array can have more than two partitions if needed, and they are identified
262 // by the partition name.
Alex Deymoac6246a2015-08-13 14:00:22 -0700263 repeated PartitionUpdate partitions = 13;
Andrew de los Reyes1e338b82010-01-22 14:57:27 -0800264}