mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 19:57:43 +00:00
Perform proto codegen in build script
This commit is contained in:
parent
7bf2e3875f
commit
21ddb26db8
354
native/src/Cargo.lock
generated
354
native/src/Cargo.lock
generated
@ -2,6 +2,27 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.71"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "base"
|
||||
version = "0.0.0"
|
||||
@ -11,6 +32,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
@ -51,12 +78,105 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
|
||||
dependencies = [
|
||||
"errno-dragonfly",
|
||||
"libc",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno-dragonfly"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
|
||||
dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.142"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b64f40e5e03e0d54f03845c8197d0291253cdbedfb1cb46b13c2c117554a9f4c"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "magisk"
|
||||
version = "0.0.0"
|
||||
@ -73,6 +193,7 @@ dependencies = [
|
||||
"byteorder",
|
||||
"cxx",
|
||||
"protobuf",
|
||||
"protobuf-codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -90,6 +211,12 @@ dependencies = [
|
||||
"base",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.1"
|
||||
@ -116,6 +243,37 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "protobuf-codegen"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dd418ac3c91caa4032d37cb80ff0d44e2ebe637b2fb243b6234bf89cdac4901"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"once_cell",
|
||||
"protobuf",
|
||||
"protobuf-parse",
|
||||
"regex",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "protobuf-parse"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d39b14605eaa1f6a340aec7f320b34064feb26c93aec35d6a9a2272a8ddfa49"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap",
|
||||
"log",
|
||||
"protobuf",
|
||||
"protobuf-support",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "protobuf-support"
|
||||
version = "3.2.0"
|
||||
@ -134,6 +292,46 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.37.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8bbfc1d1c7c40c01715f47d71444744a81669ca84e8b63e25a55e169b1f86433"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.15"
|
||||
@ -145,6 +343,19 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"redox_syscall",
|
||||
"rustix",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.40"
|
||||
@ -170,3 +381,146 @@ name = "unicode-ident"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
|
||||
dependencies = [
|
||||
"either",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
|
||||
dependencies = [
|
||||
"windows-targets 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.42.2",
|
||||
"windows_aarch64_msvc 0.42.2",
|
||||
"windows_i686_gnu 0.42.2",
|
||||
"windows_i686_msvc 0.42.2",
|
||||
"windows_x86_64_gnu 0.42.2",
|
||||
"windows_x86_64_gnullvm 0.42.2",
|
||||
"windows_x86_64_msvc 0.42.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.48.0",
|
||||
"windows_aarch64_msvc 0.48.0",
|
||||
"windows_i686_gnu 0.48.0",
|
||||
"windows_i686_msvc 0.48.0",
|
||||
"windows_x86_64_gnu 0.48.0",
|
||||
"windows_x86_64_gnullvm 0.48.0",
|
||||
"windows_x86_64_msvc 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.42.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
||||
|
1
native/src/boot/.gitignore
vendored
Normal file
1
native/src/boot/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
update_metadata.rs
|
@ -7,6 +7,9 @@ edition = "2021"
|
||||
crate-type = ["staticlib"]
|
||||
path = "lib.rs"
|
||||
|
||||
[build-dependencies]
|
||||
protobuf-codegen = "3.2.0"
|
||||
|
||||
[dependencies]
|
||||
base = { path = "../base" }
|
||||
cxx = { path = "../external/cxx-rs" }
|
||||
|
12
native/src/boot/build.rs
Normal file
12
native/src/boot/build.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use protobuf_codegen::Customize;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=update_metadata.proto");
|
||||
protobuf_codegen::Codegen::new()
|
||||
.pure()
|
||||
.include(".")
|
||||
.input("update_metadata.proto")
|
||||
.customize(Customize::default().gen_mod_rs(false))
|
||||
.out_dir(".")
|
||||
.run_from_script();
|
||||
}
|
369
native/src/boot/update_metadata.proto
Normal file
369
native/src/boot/update_metadata.proto
Normal file
@ -0,0 +1,369 @@
|
||||
//
|
||||
// Copyright (C) 2010 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Update file format: An update file contains all the operations needed
|
||||
// to update a system to a specific version. It can be a full payload which
|
||||
// can update from any version, or a delta payload which can only update
|
||||
// from a specific version.
|
||||
// The update format is represented by this struct pseudocode:
|
||||
// struct delta_update_file {
|
||||
// char magic[4] = "CrAU";
|
||||
// uint64 file_format_version; // payload major version
|
||||
// uint64 manifest_size; // Size of protobuf DeltaArchiveManifest
|
||||
//
|
||||
// // Only present if format_version >= 2:
|
||||
// uint32 metadata_signature_size;
|
||||
//
|
||||
// // The DeltaArchiveManifest protobuf serialized, not compressed.
|
||||
// char manifest[manifest_size];
|
||||
//
|
||||
// // The signature of the metadata (from the beginning of the payload up to
|
||||
// // this location, not including the signature itself). This is a serialized
|
||||
// // Signatures message.
|
||||
// char metadata_signature_message[metadata_signature_size];
|
||||
//
|
||||
// // Data blobs for files, no specific format. The specific offset
|
||||
// // and length of each data blob is recorded in the DeltaArchiveManifest.
|
||||
// struct {
|
||||
// char data[];
|
||||
// } blobs[];
|
||||
//
|
||||
// // The signature of the entire payload, everything up to this location,
|
||||
// // except that metadata_signature_message is skipped to simplify signing
|
||||
// // process. These two are not signed:
|
||||
// uint64 payload_signatures_message_size;
|
||||
// // This is a serialized Signatures message.
|
||||
// char payload_signatures_message[payload_signatures_message_size];
|
||||
//
|
||||
// };
|
||||
// The DeltaArchiveManifest protobuf is an ordered list of InstallOperation
|
||||
// objects. These objects are stored in a linear array in the
|
||||
// DeltaArchiveManifest. Each operation is applied in order by the client.
|
||||
// The DeltaArchiveManifest also contains the initial and final
|
||||
// checksums for the device.
|
||||
// The client will perform each InstallOperation in order, beginning even
|
||||
// before the entire delta file is downloaded (but after at least the
|
||||
// protobuf is downloaded). The types of operations are explained:
|
||||
// - REPLACE: Replace the dst_extents on the drive with the attached data,
|
||||
// zero padding out to block size.
|
||||
// - REPLACE_BZ: bzip2-uncompress the attached data and write it into
|
||||
// dst_extents on the drive, zero padding to block size.
|
||||
// - MOVE: Copy the data in src_extents to dst_extents. Extents may overlap,
|
||||
// so it may be desirable to read all src_extents data into memory before
|
||||
// writing it out. (deprecated)
|
||||
// - SOURCE_COPY: Copy the data in src_extents in the old partition to
|
||||
// dst_extents in the new partition. There's no overlapping of data because
|
||||
// the extents are in different partitions.
|
||||
// - BSDIFF: Read src_length bytes from src_extents into memory, perform
|
||||
// bspatch with attached data, write new data to dst_extents, zero padding
|
||||
// to block size. (deprecated)
|
||||
// - SOURCE_BSDIFF: Read the data in src_extents in the old partition, perform
|
||||
// bspatch with the attached data and write the new data to dst_extents in the
|
||||
// new partition.
|
||||
// - ZERO: Write zeros to the destination dst_extents.
|
||||
// - DISCARD: Discard the destination dst_extents blocks on the physical medium.
|
||||
// the data read from those blocks is undefined.
|
||||
// - REPLACE_XZ: Replace the dst_extents with the contents of the attached
|
||||
// xz file after decompression. The xz file should only use crc32 or no crc at
|
||||
// all to be compatible with xz-embedded.
|
||||
// - PUFFDIFF: Read the data in src_extents in the old partition, perform
|
||||
// puffpatch with the attached data and write the new data to dst_extents in
|
||||
// the new partition.
|
||||
//
|
||||
// The operations allowed in the payload (supported by the client) depend on the
|
||||
// major and minor version. See InstallOperation.Type below for details.
|
||||
syntax = "proto2";
|
||||
package chromeos_update_engine;
|
||||
// Data is packed into blocks on disk, always starting from the beginning
|
||||
// of the block. If a file's data is too large for one block, it overflows
|
||||
// into another block, which may or may not be the following block on the
|
||||
// physical partition. An ordered list of extents is another
|
||||
// representation of an ordered list of blocks. For example, a file stored
|
||||
// in blocks 9, 10, 11, 2, 18, 12 (in that order) would be stored in
|
||||
// extents { {9, 3}, {2, 1}, {18, 1}, {12, 1} } (in that order).
|
||||
// In general, files are stored sequentially on disk, so it's more efficient
|
||||
// to use extents to encode the block lists (this is effectively
|
||||
// run-length encoding).
|
||||
// A sentinel value (kuint64max) as the start block denotes a sparse-hole
|
||||
// in a file whose block-length is specified by num_blocks.
|
||||
message Extent {
|
||||
optional uint64 start_block = 1;
|
||||
optional uint64 num_blocks = 2;
|
||||
}
|
||||
// Signatures: Updates may be signed by the OS vendor. The client verifies
|
||||
// an update's signature by hashing the entire download. The section of the
|
||||
// download that contains the signature is at the end of the file, so when
|
||||
// signing a file, only the part up to the signature part is signed.
|
||||
// Then, the client looks inside the download's Signatures message for a
|
||||
// Signature message that it knows how to handle. Generally, a client will
|
||||
// only know how to handle one type of signature, but an update may contain
|
||||
// many signatures to support many different types of client. Then client
|
||||
// selects a Signature message and uses that, along with a known public key,
|
||||
// to verify the download. The public key is expected to be part of the
|
||||
// client.
|
||||
message Signatures {
|
||||
message Signature {
|
||||
optional uint32 version = 1 [deprecated = true];
|
||||
optional bytes data = 2;
|
||||
// The DER encoded signature size of EC keys is nondeterministic for
|
||||
// different input of sha256 hash. However, we need the size of the
|
||||
// serialized signatures protobuf string to be fixed before signing;
|
||||
// because this size is part of the content to be signed. Therefore, we
|
||||
// always pad the signature data to the maximum possible signature size of
|
||||
// a given key. And the payload verifier will truncate the signature to
|
||||
// its correct size based on the value of |unpadded_signature_size|.
|
||||
optional fixed32 unpadded_signature_size = 3;
|
||||
}
|
||||
repeated Signature signatures = 1;
|
||||
}
|
||||
message PartitionInfo {
|
||||
optional uint64 size = 1;
|
||||
optional bytes hash = 2;
|
||||
}
|
||||
message InstallOperation {
|
||||
enum Type {
|
||||
REPLACE = 0; // Replace destination extents w/ attached data.
|
||||
REPLACE_BZ = 1; // Replace destination extents w/ attached bzipped data.
|
||||
MOVE = 2 [deprecated = true]; // Move source extents to target extents.
|
||||
BSDIFF = 3 [deprecated = true]; // The data is a bsdiff binary diff.
|
||||
// On minor version 2 or newer, these operations are supported:
|
||||
SOURCE_COPY = 4; // Copy from source to target partition
|
||||
SOURCE_BSDIFF = 5; // Like BSDIFF, but read from source partition
|
||||
// On minor version 3 or newer and on major version 2 or newer, these
|
||||
// operations are supported:
|
||||
REPLACE_XZ = 8; // Replace destination extents w/ attached xz data.
|
||||
// On minor version 4 or newer, these operations are supported:
|
||||
ZERO = 6; // Write zeros in the destination.
|
||||
DISCARD = 7; // Discard the destination blocks, reading as undefined.
|
||||
BROTLI_BSDIFF = 10; // Like SOURCE_BSDIFF, but compressed with brotli.
|
||||
// On minor version 5 or newer, these operations are supported:
|
||||
PUFFDIFF = 9; // The data is in puffdiff format.
|
||||
// On minor version 8 or newer, these operations are supported:
|
||||
ZUCCHINI = 11;
|
||||
// On minor version 9 or newer, these operations are supported:
|
||||
LZ4DIFF_BSDIFF = 12;
|
||||
LZ4DIFF_PUFFDIFF = 13;
|
||||
}
|
||||
required Type type = 1;
|
||||
// Only minor version 6 or newer support 64 bits |data_offset| and
|
||||
// |data_length|, older client will read them as uint32.
|
||||
// The offset into the delta file (after the protobuf)
|
||||
// where the data (if any) is stored
|
||||
optional uint64 data_offset = 2;
|
||||
// The length of the data in the delta file
|
||||
optional uint64 data_length = 3;
|
||||
// Ordered list of extents that are read from (if any) and written to.
|
||||
repeated Extent src_extents = 4;
|
||||
// Byte length of src, equal to the number of blocks in src_extents *
|
||||
// block_size. It is used for BSDIFF and SOURCE_BSDIFF, because we need to
|
||||
// pass that external program the number of bytes to read from the blocks we
|
||||
// pass it. This is not used in any other operation.
|
||||
optional uint64 src_length = 5;
|
||||
repeated Extent dst_extents = 6;
|
||||
// Byte length of dst, equal to the number of blocks in dst_extents *
|
||||
// block_size. Used for BSDIFF and SOURCE_BSDIFF, but not in any other
|
||||
// operation.
|
||||
optional uint64 dst_length = 7;
|
||||
// Optional SHA 256 hash of the blob associated with this operation.
|
||||
// This is used as a primary validation for http-based downloads and
|
||||
// as a defense-in-depth validation for https-based downloads. If
|
||||
// the operation doesn't refer to any blob, this field will have
|
||||
// zero bytes.
|
||||
optional bytes data_sha256_hash = 8;
|
||||
// Indicates the SHA 256 hash of the source data referenced in src_extents at
|
||||
// the time of applying the operation. If present, the update_engine daemon
|
||||
// MUST read and verify the source data before applying the operation.
|
||||
optional bytes src_sha256_hash = 9;
|
||||
}
|
||||
// Hints to VAB snapshot to skip writing some blocks if these blocks are
|
||||
// identical to the ones on the source image. The src & dst extents for each
|
||||
// CowMergeOperation should be contiguous, and they're a subset of an OTA
|
||||
// InstallOperation.
|
||||
// During merge time, we need to follow the pre-computed sequence to avoid
|
||||
// read after write, similar to the inplace update schema.
|
||||
message CowMergeOperation {
|
||||
enum Type {
|
||||
COW_COPY = 0; // identical blocks
|
||||
COW_XOR = 1; // used when src/dst blocks are highly similar
|
||||
COW_REPLACE = 2; // Raw replace operation
|
||||
}
|
||||
optional Type type = 1;
|
||||
optional Extent src_extent = 2;
|
||||
optional Extent dst_extent = 3;
|
||||
// For COW_XOR, source location might be unaligned, so this field is in range
|
||||
// [0, block_size), representing how much should the src_extent shift toward
|
||||
// larger block number. If this field is non-zero, then src_extent will
|
||||
// include 1 extra block in the end, as the merge op actually references the
|
||||
// first |src_offset| bytes of that extra block. For example, if |dst_extent|
|
||||
// is [10, 15], |src_offset| is 500, then src_extent might look like [25, 31].
|
||||
// Note that |src_extent| contains 1 extra block than the |dst_extent|.
|
||||
optional uint32 src_offset = 4;
|
||||
}
|
||||
// Describes the update to apply to a single partition.
|
||||
message PartitionUpdate {
|
||||
// A platform-specific name to identify the partition set being updated. For
|
||||
// example, in Chrome OS this could be "ROOT" or "KERNEL".
|
||||
required string partition_name = 1;
|
||||
// Whether this partition carries a filesystem with post-install program that
|
||||
// must be run to finalize the update process. See also |postinstall_path| and
|
||||
// |filesystem_type|.
|
||||
optional bool run_postinstall = 2;
|
||||
// The path of the executable program to run during the post-install step,
|
||||
// relative to the root of this filesystem. If not set, the default "postinst"
|
||||
// will be used. This setting is only used when |run_postinstall| is set and
|
||||
// true.
|
||||
optional string postinstall_path = 3;
|
||||
// The filesystem type as passed to the mount(2) syscall when mounting the new
|
||||
// filesystem to run the post-install program. If not set, a fixed list of
|
||||
// filesystems will be attempted. This setting is only used if
|
||||
// |run_postinstall| is set and true.
|
||||
optional string filesystem_type = 4;
|
||||
// If present, a list of signatures of the new_partition_info.hash signed with
|
||||
// different keys. If the update_engine daemon requires vendor-signed images
|
||||
// and has its public key installed, one of the signatures should be valid
|
||||
// for /postinstall to run.
|
||||
repeated Signatures.Signature new_partition_signature = 5;
|
||||
optional PartitionInfo old_partition_info = 6;
|
||||
optional PartitionInfo new_partition_info = 7;
|
||||
// The list of operations to be performed to apply this PartitionUpdate. The
|
||||
// associated operation blobs (in operations[i].data_offset, data_length)
|
||||
// should be stored contiguously and in the same order.
|
||||
repeated InstallOperation operations = 8;
|
||||
// Whether a failure in the postinstall step for this partition should be
|
||||
// ignored.
|
||||
optional bool postinstall_optional = 9;
|
||||
// On minor version 6 or newer, these fields are supported:
|
||||
// The extent for data covered by verity hash tree.
|
||||
optional Extent hash_tree_data_extent = 10;
|
||||
// The extent to store verity hash tree.
|
||||
optional Extent hash_tree_extent = 11;
|
||||
// The hash algorithm used in verity hash tree.
|
||||
optional string hash_tree_algorithm = 12;
|
||||
// The salt used for verity hash tree.
|
||||
optional bytes hash_tree_salt = 13;
|
||||
// The extent for data covered by FEC.
|
||||
optional Extent fec_data_extent = 14;
|
||||
// The extent to store FEC.
|
||||
optional Extent fec_extent = 15;
|
||||
// The number of FEC roots.
|
||||
optional uint32 fec_roots = 16 [default = 2];
|
||||
// Per-partition version used for downgrade detection, added
|
||||
// as an effort to support partial updates. For most partitions,
|
||||
// this is the build timestamp.
|
||||
optional string version = 17;
|
||||
// A sorted list of CowMergeOperation. When writing cow, we can choose to
|
||||
// skip writing the raw bytes for these extents. During snapshot merge, the
|
||||
// bytes will read from the source partitions instead.
|
||||
repeated CowMergeOperation merge_operations = 18;
|
||||
// Estimated size for COW image. This is used by libsnapshot
|
||||
// as a hint. If set to 0, libsnapshot should use alternative
|
||||
// methods for estimating size.
|
||||
optional uint64 estimate_cow_size = 19;
|
||||
}
|
||||
message DynamicPartitionGroup {
|
||||
// Name of the group.
|
||||
required string name = 1;
|
||||
// Maximum size of the group. The sum of sizes of all partitions in the group
|
||||
// must not exceed the maximum size of the group.
|
||||
optional uint64 size = 2;
|
||||
// A list of partitions that belong to the group.
|
||||
repeated string partition_names = 3;
|
||||
}
|
||||
message VABCFeatureSet {
|
||||
optional bool threaded = 1;
|
||||
optional bool batch_writes = 2;
|
||||
}
|
||||
// Metadata related to all dynamic partitions.
|
||||
message DynamicPartitionMetadata {
|
||||
// All updatable groups present in |partitions| of this DeltaArchiveManifest.
|
||||
// - If an updatable group is on the device but not in the manifest, it is
|
||||
// not updated. Hence, the group will not be resized, and partitions cannot
|
||||
// be added to or removed from the group.
|
||||
// - If an updatable group is in the manifest but not on the device, the group
|
||||
// is added to the device.
|
||||
repeated DynamicPartitionGroup groups = 1;
|
||||
// Whether dynamic partitions have snapshots during the update. If this is
|
||||
// set to true, the update_engine daemon creates snapshots for all dynamic
|
||||
// partitions if possible. If this is unset, the update_engine daemon MUST
|
||||
// NOT create snapshots for dynamic partitions.
|
||||
optional bool snapshot_enabled = 2;
|
||||
// If this is set to false, update_engine should not use VABC regardless. If
|
||||
// this is set to true, update_engine may choose to use VABC if device
|
||||
// supports it, but not guaranteed.
|
||||
// VABC stands for Virtual AB Compression
|
||||
optional bool vabc_enabled = 3;
|
||||
// The compression algorithm used by VABC. Available ones are "gz", "brotli".
|
||||
// See system/core/fs_mgr/libsnapshot/cow_writer.cpp for available options,
|
||||
// as this parameter is ultimated forwarded to libsnapshot's CowWriter
|
||||
optional string vabc_compression_param = 4;
|
||||
// COW version used by VABC. The represents the major version in the COW
|
||||
// header
|
||||
optional uint32 cow_version = 5;
|
||||
// A collection of knobs to tune Virtual AB Compression
|
||||
optional VABCFeatureSet vabc_feature_set = 6;
|
||||
}
|
||||
// Definition has been duplicated from
|
||||
// $ANDROID_BUILD_TOP/build/tools/releasetools/ota_metadata.proto. Keep in sync.
|
||||
message ApexInfo {
|
||||
optional string package_name = 1;
|
||||
optional int64 version = 2;
|
||||
optional bool is_compressed = 3;
|
||||
optional int64 decompressed_size = 4;
|
||||
}
|
||||
// Definition has been duplicated from
|
||||
// $ANDROID_BUILD_TOP/build/tools/releasetools/ota_metadata.proto. Keep in sync.
|
||||
message ApexMetadata {
|
||||
repeated ApexInfo apex_info = 1;
|
||||
}
|
||||
message DeltaArchiveManifest {
|
||||
// Only present in major version = 1. List of install operations for the
|
||||
// kernel and rootfs partitions. For major version = 2 see the |partitions|
|
||||
// field.
|
||||
reserved 1, 2;
|
||||
// (At time of writing) usually 4096
|
||||
optional uint32 block_size = 3 [default = 4096];
|
||||
// If signatures are present, the offset into the blobs, generally
|
||||
// tacked onto the end of the file, and the length. We use an offset
|
||||
// rather than a bool to allow for more flexibility in future file formats.
|
||||
// If either is absent, it means signatures aren't supported in this
|
||||
// file.
|
||||
optional uint64 signatures_offset = 4;
|
||||
optional uint64 signatures_size = 5;
|
||||
// Fields deprecated in major version 2.
|
||||
reserved 6,7,8,9,10,11;
|
||||
// The minor version, also referred as "delta version", of the payload.
|
||||
// Minor version 0 is full payload, everything else is delta payload.
|
||||
optional uint32 minor_version = 12 [default = 0];
|
||||
// Only present in major version >= 2. List of partitions that will be
|
||||
// updated, in the order they will be updated. This field replaces the
|
||||
// |install_operations|, |kernel_install_operations| and the
|
||||
// |{old,new}_{kernel,rootfs}_info| fields used in major version = 1. This
|
||||
// array can have more than two partitions if needed, and they are identified
|
||||
// by the partition name.
|
||||
repeated PartitionUpdate partitions = 13;
|
||||
// The maximum timestamp of the OS allowed to apply this payload.
|
||||
// Can be used to prevent downgrading the OS.
|
||||
optional int64 max_timestamp = 14;
|
||||
// Metadata related to all dynamic partitions.
|
||||
optional DynamicPartitionMetadata dynamic_partition_metadata = 15;
|
||||
// If the payload only updates a subset of partitions on the device.
|
||||
optional bool partial_update = 16;
|
||||
// Information on compressed APEX to figure out how much space is required for
|
||||
// their decompression
|
||||
repeated ApexInfo apex_info = 17;
|
||||
// Security patch level of the device, usually in the format of
|
||||
// yyyy-mm-dd
|
||||
optional string security_patch_level = 18;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user