avbroot-inc-ota
is a tool for generating a signed incremental Android A/B OTA zip from two full OTA zips.
This is a proof of concept, but has been tested on real devices and should work with any valid full OTA zip. This will likely not be integrated in avbroot, nor will it receive further development because the delta payload.bin
generation depends on AOSP's delta_generator
and it is too complicated to reimplement.
Download the AOSP source code (or the source code for any AOSP-based OS). This will likely require 100-200 GiB of disk space.
Inside the AOSP source directory, build delta_generator
.
source build/envsetup.sh
m delta_generator
The output will be in out/host/linux-x86/bin/delta_generator
.
Ensure the Rust toolchain is installed.
Clone this git repo and build avbroot-inc-ota
.
cargo build --release
The output will be in target/release/avbroot-inc-ota
.
Generate an incremental OTA from two full OTAs:
avbroot-inc-ota \
--input-old /path/to/old/full/ota.zip \
--input-new /path/to/new/full/ota.zip \
--output /path/to/output/incremental/ota.zip \
--delta-generator /path/to/aosp/out/host/linux-x86/bin/delta_generator \
--key /path/to/ota.key \
--cert /path/to/ota.crt
For testing, it is perfectly valid to use the same file as both the old and new full OTAs. The resulting incremental OTA will just "upgrade" to the same Android build.
That's it! The output OTA can be sideloaded with adb sideload
if the currently installed Android build matches the old full OTA.
The delta payload.bin
is generated by AOSP's delta_generator
. It computes the binary diff between old and new raw partition images and stores the resulting bsdiff
diffs in an unsigned payload. Since bsdiff computation is slow, CPU/memory intensive, and produces large diffs when an unmodified block is moved to a different offset in the new image, delta_generator
includes ext4 and erofs filesystem parsers to compare the data of individual files. This allows diff computation for blocks containing identical files to be avoided entirely and instead, stores SOURCE_COPY
operations in the payload. (The necessity of these filesystem parsers is why this project won't be integrated into avbroot.)
delta_generator
also requires a few additional input files:
apex_info.pb
- This is simply extracted from the new full OTA's zip.dynamic_partitions_info.txt
- This is a key=value
text file used in AOSP's target_files
directory structure that stores information about the super
partition and virtual A/B compression. Only a partial set of the keys can be generated from information contained in the new full OTA, but that subset is sufficient for running delta_generator
. This information is ultimately stored in the incremental OTA's payload.bin
header.postinstall_config.txt
- This is another key=value
text file used in AOSP's target_files
directory structure that stores information about the postinstall scripts that run after the OTA is installed. This information can be completely generated from the new full OTA and is stored in the incremental OTA's payload.bin
header.The META-INF/com/android/metadata{,.pb}
files are generated from the new full OTA, but with the build
and build-incremental
precondition fields set to the appropriate values from the old full OTA. This prevents the incremental OTA from being installed on top of an Android build that it wasn't built for.
The payload and OTA signing is provided by avbroot's library functions.
avbroot-inc-ota is licensed under GPLv3. Please see LICENSE
for the full license text.