The zip crate gained support for streaming writes in its master branch, so we can finally upgrade from our ancient fork of it. The new implementation is done a bit differently, with seekable writers having the ZipWriter<W> type and streaming writers having the ZipWriter<StreamWriter<W>> type. This forces us to add a new wrapper type since we have to switch between them at runtime. We still need to maintain a (hopefully temporary) fork of the crate due to a few issues: 1. There's no way to get the original underlying writer instance back after finalizing a streaming zip. A fix for this has been submitted upstream: https://github.com/zip-rs/zip2/pull/367 2. The streaming writes implementation does not include the magic signature for data descriptors. While the zip spec says the magic value is optional and parsers should not require it, older versions of Android's libziparchive do. A fix for this has been submitted upstream: https://github.com/zip-rs/zip2/pull/368 3. There is currently no way to get the data offset of zip entries. avbroot requires this to fill in the OTA metadata's "property files" entries, which Android uses to read file data without parsing the zip file structures. This new zip update produces files that are slightly different to before. The "version made by" and "version needed to extract" fields are now set to their minimum possible values. Previously, the zip crate was hardcoded to use versions 4.6 and 2.0, respectively. Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
End-to-end tests
avbroot's output file is reproducible for a given input file. e2e.toml lists some profiles for generating mock OTA images with unique properties and the expected checksums before and after patching. These tests use pregenerated, hardcoded test keys for signing. These keys should NEVER be used for any other purpose.
For each profile listed in the config, the test process will:
- Generate a mock OTA based on the specification
- Verify tha original OTA checksum
- Run avbroot against the OTA using
--magisk(with a mock Magisk APK) - Verify the patched OTA checksum
- Extract the AVB-related partitions from the patched OTA
- Run avbroot against the OTA again using
--prepatched - Verify the patched OTA checksum again
The default profiles shipped with the project mimic how various stock OTAs for Pixel devices are built. The generated mock OTAs have valid signatures and data structures for all components, but without any actual data where possible. For example, most files in the ramdisks are empty files. To ensure the mock OTAs cannot be mistakenly installed on a real device, the OTA metadata lists a fake device name in the preconditions section.
Running the tests
To test against the profiles listed in e2e.toml, run:
# To test all profiles
cargo run --release -- test -a
# Or to test against specific profiles
cargo run --release -- test -p pixel_v4_gki -p pixel_v4_non_gki