blob: 115d513cfc018c5c513dc9d724a2046313820611 [file] [log] [blame]
adlr@google.com3defe6a2009-12-04 20:57:17 +00001// Copyright (c) 2009 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Update file format: A delta update file contains all the deltas needed
6// to update a system from one specific version to another specific
7// version. The update format is represented by this struct pseudocode:
8// struct delta_update_file {
9// char magic[4] = "CrAU";
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080010// uint32 file_format_version = 1;
11// uint64 manifest_size; // Size of protobuf DeltaArchiveManifest
12// // The Bzip2 compressed DeltaArchiveManifest
13// char manifest[];
adlr@google.com3defe6a2009-12-04 20:57:17 +000014//
15// // Data blobs for files, no specific format. The specific offset
16// // and length of each data blob is recorded in the DeltaArchiveManifest.
17// struct {
18// char data[];
19// } blobs[];
20//
adlr@google.com3defe6a2009-12-04 20:57:17 +000021// };
22
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080023// The DeltaArchiveManifest protobuf is an ordered list of InstallOperation
24// objects. These objects are stored in a linear array in the
25// DeltaArchiveManifest. Each operation is applied in order by the client.
adlr@google.com3defe6a2009-12-04 20:57:17 +000026
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080027// The DeltaArchiveManifest also contains the initial and final
28// checksums for the device.
adlr@google.com3defe6a2009-12-04 20:57:17 +000029
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080030// The client will perform each InstallOperation in order, beginning even
31// before the entire delta file is downloaded (but after at least the
32// protobuf is downloaded). The types of operations are explained:
33// - REPLACE: Replace the dst_extents on the drive with the attached data,
34// zero padding out to block size.
35// - REPLACE_BZ: bzip2-uncompress the attached data and write it into
36// dst_extents on the drive, zero padding to block size.
37// - MOVE: Copy the data in src_extents to dst_extents. Extents may overlap,
38// so it may be desirable to read all src_extents data into memory before
39// writing it out.
40// - BSDIFF: Read src_length bytes from src_extents into memory, perform
41// bspatch with attached data, write new data to dst_extents, zero padding
42// to block size.
adlr@google.com3defe6a2009-12-04 20:57:17 +000043
44package chromeos_update_engine;
45
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080046// Data is packed into blocks on disk, always starting from the beginning
47// of the block. If a file's data is too large for one block, it overflows
48// into another block, which may or may not be the following block on the
49// physical partition. An ordered list of extents is another
50// representation of an ordered list of blocks. For example, a file stored
51// in blocks 9, 10, 11, 2, 18, 12 (in that order) would be stored in
52// extents { {9, 3}, {2, 1}, {18, 1}, {12, 1} } (in that order).
53// In general, files are stored sequentially on disk, so it's more efficient
54// to use extents to encode the block lists (this is effectively
55// run-length encoding).
56// A sentinel value (kuint64max) as the start block denotes a sparse-hole
57// in a file whose block-length is specified by num_blocks.
adlr@google.com3defe6a2009-12-04 20:57:17 +000058
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080059message Extent {
60 optional uint64 start_block = 1;
61 optional uint64 num_blocks = 2;
adlr@google.com3defe6a2009-12-04 20:57:17 +000062}
63
Andrew de los Reyes1e338b82010-01-22 14:57:27 -080064message DeltaArchiveManifest {
65 message InstallOperation {
66 enum Type {
67 REPLACE = 0; // Replace destination extents w/ attached data
68 REPLACE_BZ = 1; // Replace destination extents w/ attached bzipped data
69 MOVE = 2; // Move source extents to destination extents
70 BSDIFF = 3; // The data is a bsdiff binary diff
71 }
72 required Type type = 1;
73 // The offset into the delta file (after the protobuf)
74 // where the data (if any) is stored
75 optional uint32 data_offset = 2;
76 // The length of the data in the delta file
77 optional uint32 data_length = 3;
78
79 // Ordered list of extents that are read from (if any) and written to.
80 repeated Extent src_extents = 4;
81 // Byte length of src, not necessarily block aligned. It's only used for
82 // BSDIFF, because we need to pass that external program the number
83 // of bytes to read from the blocks we pass it.
84 optional uint64 src_length = 5;
85
86 repeated Extent dst_extents = 6;
87 // byte length of dst, not necessarily block aligned. It's only used for
88 // BSDIFF, because we need to fill in the rest of the last block
89 // that bsdiff writes with '\0' bytes.
90 optional uint64 dst_length = 7;
91 }
92 repeated InstallOperation install_operations = 1;
93 // The checksums of the install device before and after the install process.
94 optional string src_checksum = 2;
95 optional string dst_checksum = 3;
96
97 // (At time of writing) usually 4096
98 optional uint32 block_size = 5 [default = 4096];
99}