605 Commits

Author SHA1 Message Date
Andrew Gunnerson 7ffeb5e5cb Version 3.8.0
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.8.0
2024-10-13 22:25:18 -04:00
Andrew Gunnerson a9a1aa55e9 CHANGELOG.md: Add entry for PR #364
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-10-13 22:18:58 -04:00
Andrew Gunnerson 0ca2872111 Update dependencies
zerocopy 0.8 is the only dependency with breaking changes.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-10-13 22:16:59 -04:00
Andrew Gunnerson a403c26b54 CHANGELOG.md: Add entry for PR #363
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-10-13 21:36:47 -04:00
Andrew Gunnerson 4afa1d1ba6 cli/avb: Add subcommand for computing vbmeta digest
This computes the special SHA256 digest that is equal to the
ro.boot.vbmeta.digest property value on a real device.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-10-13 21:29:04 -04:00
Andrew Gunnerson 9f669bc53e Version 3.7.1
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.7.1
2024-10-10 18:12:48 -04:00
Andrew Gunnerson fc89159f09 CHANGELOG.md: Add entry for PR #362
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-10-10 18:04:25 -04:00
Andrew Gunnerson 18f43a0e57 Add support for Magisk 28000
There is nothing new that isn't already supported.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-10-10 18:03:04 -04:00
Andrew Gunnerson af7262a0d2 cli/sparse: Fix clippy warning on non-Linux/Android builds
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-22 21:21:11 -04:00
Andrew Gunnerson 5a7885674e ci.yml: Use target name in Rust cache key
Otherwise, the x86_64-unknown-linux-gnu build running on Ubuntu 22.04
can use the cache from the aarch64-linux-android31 build that originally
ran on Ubuntu 24.04. This fails due to some cached components having
been compiled against a newer version of glibc.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-22 21:13:33 -04:00
Andrew Gunnerson c974ab5ec3 Use Rust conventional comment style for license headers
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-22 14:58:01 -04:00
Andrew Gunnerson 02ae9cd0e3 Version 3.7.0
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.7.0
2024-09-21 18:42:42 -04:00
Andrew Gunnerson 9c92d32a80 CHANGELOG.md: Add entry for PR #357
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-21 18:42:19 -04:00
Andrew Gunnerson 296df25fb9 Ensure that PrepatchedImagePatcher runs before other patchers
On older devices, like the Pixel 4a, where `boot` is used for both
Android and recovery mode, the image will be patched by OtaCertPatcher
and PrepatchedImagePatcher. OtaCertPatcher was always set to run first,
so when PrepatchedImagePatcher used the user-supplied image as-is, prior
modifications got wiped out. This made is so users could no longer flash
further patched OTAs.

This is an unfortunate regression that was introduced in avbroot 2.0.0.
The e2e tests never caught this issue because the --prepatched test was
being fed the boot image previously patched by --magisk. That already
had valid certs so the result of OtaCertPatcher's modifications being
lost were not visible. This commit also fixes the e2e tests so that this
type of issue will be caught in the future.

Fixes: #356

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-21 18:17:46 -04:00
Andrew Gunnerson 352352b4d4 CHANGELOG.md: Add entry for PR #355
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-15 20:06:57 -04:00
Andrew Gunnerson e28ef42c0e Switch to passterm library for password prompts
This library behaves exactly the same as rpassword, but has zero
dependencies so we no longer need to pull in the ancient windows-sys
0.48.x libraries.

We still transitively depend on both windows-sys 0.52.x and 0.59.x
though.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-15 17:46:52 -04:00
Andrew Gunnerson 5775c86e5b CHANGELOG.md: Add entry for PR #354
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-15 16:19:31 -04:00
Andrew Gunnerson 3dc8e07c0f cli/payload: Allow inspecting delta payloads
The pack and unpack commands can never support delta payloads, but
there's no reason not to allow the repack and info commands to read
them.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-15 16:12:17 -04:00
Andrew Gunnerson 040dcd1a5c Return ExitCode from main
std::process::exit() calls the exit syscall, which doesn't run
destructors. It doesn't matter for avbroot, but better to use ExitCode
anyway.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-01 22:36:41 -04:00
Andrew Gunnerson 41a578975f CHANGELOG.md: Add entry for PR #347
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-01 02:23:05 -04:00
Andrew Gunnerson e9638d25b0 Add support for packing and unpacking Android sparse images
This supports all features of Android sparse images, including holes,
and CRC32 (both full image checksum and CRC32 chunks).

Partial sparse images, like those included in GrapheneOS' new optimized
factory images, can also be packed and unpacked with these new commands,
unlike AOSP's simg2img and img2simg tools.

This new functionality is not relevant for avbroot's main use case, but
is useful for unpacking certain factory images for comparison with OTAs
during troubleshooting.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-09-01 02:14:11 -04:00
Andrew Gunnerson e25080ddef Merge pull request #346 from bugreportion/patch-1
README.ru.md: update translation
2024-08-31 12:43:48 -04:00
Ivan Katrovsky 0e7d778cf5 README.ru.md: update translation
* https://github.com/chenxiaolong/avbroot/commit/8e52a9cf8c6f3bd6ea281d93364ac3cb9eddd806
* https://github.com/chenxiaolong/avbroot/commit/4a1dab40694b50cc4b914ff9bbfc869344afed9c
* https://github.com/chenxiaolong/avbroot/commit/24320d4fae309cd4f19a8ccff0ab923905d04e8f
* https://github.com/chenxiaolong/avbroot/commit/7113fb32efc9d1db5c76529d28317fcd3e42ebcb
* https://github.com/chenxiaolong/avbroot/commit/8ca1a289a8111da76ac0cc25ec64fdb2b051f643

Signed-off-by: Ivan Katrovsky <notbugreporter@proton.me>
2024-08-31 02:52:50 +03:00
Andrew Gunnerson 8ca1a289a8 README.md: Split setting ANDROID_PRODUCT_OUT env var to separate step
Also add examples for powershell and cmd instead of assuming bash
syntax.

Fixes: #340

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-30 19:12:56 -04:00
Andrew Gunnerson dfbc2f807f CHANGELOG.md: Add entry for PR #343
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-28 18:37:45 -04:00
Andrew Gunnerson e55cf3d679 lp: Sparse files are not required when packing and unpacking empty images
Empty images don't contain any extent metadata so the partition sizes
are just discarded.

Don't write parsers when you're tired, folks!

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-28 18:30:57 -04:00
Andrew Gunnerson 7c38c5609b CHANGELOG.md: Add entry for PR #342
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-27 23:57:59 -04:00
Andrew Gunnerson 13c910274e Add support for packing and unpacking logical partition images
This supports both empty and normal LP images, including those that span
multiple files/devices.

Currently, repacked files are semantically equivalent, but not exactly
identical. avbroot's data structure for the metadata does not preserve
the arbitrary partition ordering of the LP image. Instead, to make the
API a bit nicer, it only preserves the relative partition ordering
within partition groups.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-27 23:32:29 -04:00
Andrew Gunnerson dd40f64918 CHANGELOG.md: Add entry for PR #337
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-20 21:37:57 -04:00
Andrew Gunnerson 7113fb32ef Add support for outputting zip files with no data descriptors
This commit adds a new `--zip-mode` parameter to `avbroot ota patch` to
control whether the patched OTA zip is written with data descriptors or
not. By default, the `streaming` mode is used, which matches the current
behavior where the zip is hashed for signing as it is being written. The
new `seekable` mode fully writes the zip before rereading it to hash the
contents.

The new mode is useful for devices with broken zip parsers that fail to
properly handle data descriptors.

All of the end-to-end tests have been duplicated to test both modes.

Adding the seekable mode necessitated a couple other changes:

* BufWriter is no longer used. Type erasure is very painful in Rust, so
  we need to keep the writer types the same for both the streaming and
  seekable modes. BufWriter is unusable in the seekable mode because we
  need to be able to read back what was written, which isn't supported.

* HolePunchingWriter has been removed. It was a simple way to produce
  sparse files by seeking whenever a write buffer consists fully of
  zeros. When combined with BufWriter, there was previously never a
  situation where this was undesirable. However, with the new seekable
  mode and the zip library's pattern of writing one field at a time, the
  final 2 zero bytes (representing an empty archive comment) is never
  written and the file size is not increased either.

  Removing this is not a big deal since we no longer use stripped OTAs
  for the end-to-end tests. Those were really the only OTAs that
  benefitted from sparse files. A real OTA has very few zero bytes due
  to compression.

Issue: #328

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-20 21:31:33 -04:00
Andrew Gunnerson 9c9d656ea2 CHANGELOG.md: Add entry for PR #336
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-19 15:03:26 -04:00
Andrew Gunnerson e06674a7f0 Print a useful error message when there's no TTY for a password prompt
ENXIO (No such device or address) and ENOTTY (Inappropriate ioctl for
device) are not very user-friendly error messages.

Issue: https://github.com/chenxiaolong/my-avbroot-setup/issues/2

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-19 14:57:46 -04:00
Andrew Gunnerson cf5ef13e47 Version 3.6.0
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.6.0
2024-08-19 00:03:38 -04:00
Andrew Gunnerson 5fada419cb CHANGELOG.md: Add entry for PR #335
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-19 00:03:05 -04:00
Andrew Gunnerson eeea9f41b4 cli/args: Use tracing::Level directly
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-18 23:58:11 -04:00
Andrew Gunnerson 0bebf120c6 CHANGELOG.md: Add entry for PR #334
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-18 23:57:40 -04:00
Andrew Gunnerson 264c602fdb cli/ota: Remove unnecessary mutex
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-18 23:49:41 -04:00
Andrew Gunnerson 343e2e279c CHANGELOG.md: Add entry for PR #333
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-18 23:44:45 -04:00
Andrew Gunnerson 59ca759262 Add support for gzip VABC algorithm
Older devices, like the Pixel 4a 5G (bramble) use gzip instead of lz4.

This commit also reworks the CoW size estimate calculation to add the
same constant headroom that AOSP's delta_generator adds. Previously,
avbroot was already adding an additional 1% to account for differences
in compression ratios across compression library implementations. This
papered over the issue for large partitions, but small partitions could
still have a CoW size estimate that's too small. Adding the constant
headroom prevents ENOSPC when flashing those partitions.

Fixes: #332

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-18 23:33:43 -04:00
Andrew Gunnerson 83ab475c11 Version 3.5.0
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.5.0
2024-08-15 20:45:04 -04:00
Andrew Gunnerson fe54640029 CHANGELOG.md: Add entry for PR #331
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-15 20:44:32 -04:00
Andrew Gunnerson fec1840a5f Add subcommands for packing and unpacking payload binaries
Some devices have "full" OTAs where the payload is missing the recovery
partition. These subcommands make it possible to manually add back the
missing image. Given the strict requirements for how the OTA zip is laid
out and signed, users can't just replace payload.bin in a zip and call
it a day, but it's sufficient for feeding a modified input to
`avbroot ota patch`.

Issue: #328

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-15 20:38:52 -04:00
Andrew Gunnerson 395f6934ff CHANGELOG.md: Add entry for PR #329
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-14 22:07:47 -04:00
Andrew Gunnerson a83b2fbfa9 Update dependencies
prost and protox have breaking changes, but none that affect avbroot.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-08-14 21:06:21 -04:00
Andrew Gunnerson e18ef20e4d Version 3.4.1
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
v3.4.1
2024-07-28 18:04:20 -04:00
Andrew Gunnerson b140620ed3 CHANGELOG.md: Add entry for PR #323
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-07-28 18:03:16 -04:00
Andrew Gunnerson dd9d8959fd Add support for Magisk 27006
Version 27006 now requires init-ld to be included in the ramdisk.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-07-28 17:58:13 -04:00
Andrew Gunnerson 9a7cece973 CHANGELOG.md: Add entry for PR #321
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-07-15 21:44:29 -04:00
Andrew Gunnerson aac3aded78 Update all dependencies
Version 1.6.0 of the bytes library was yanked. There's no vulnerability
that impacts avbroot, but it was tripping the cargo-deny checks.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-07-15 21:32:14 -04:00
Andrew Gunnerson 24320d4fae README.md: Move signature verification instructions to shared repo
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2024-07-14 18:23:55 -04:00