Commit Graph

198 Commits

Author SHA1 Message Date
Andrew Gunnerson 1b5d98d718 README.md: Improve project description and remove suggestion for compiling AOSP from source
Issue: #106

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-06-22 19:56:23 -04:00
Andrew Gunnerson 5b1622c382 Merge pull request #105 from chenxiaolong/windows
modules/build.py: Windows requires `.bat` extension to be specified explicitly
2023-06-14 18:05:38 -04:00
Andrew Gunnerson 6c7165cfb7 modules/build.py: Windows requires .bat extension to be specified explicitly
Fixes: #104

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-06-14 18:04:47 -04:00
Andrew Gunnerson 5dda181e90 Merge pull request #101 from chenxiaolong/readme
README.md: Add note about using unencrypted private keys
2023-05-31 00:05:27 -04:00
Andrew Gunnerson 0ff1bb2b2f README.md: Add note about using unencrypted private keys
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-31 00:04:48 -04:00
Andrew Gunnerson 19bfc0bd8e Merge pull request #100 from chenxiaolong/env_var
Add support for supplying the private key passphrases non-interactively
2023-05-31 00:04:04 -04:00
Andrew Gunnerson 6be4665557 Update tests for non-interactive patching with encrypted keys
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-30 23:54:16 -04:00
Andrew Gunnerson 601c24222f Add support for supplying the private key passphrases non-interactively
Fixes: #99

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-30 22:35:49 -04:00
Andrew Gunnerson 669ea9c471 Merge pull request #98 from chenxiaolong/rootless
Add option to skip applying the root patch entirely
2023-05-27 16:42:58 -04:00
Andrew Gunnerson da3c9da2bf Add option to skip applying the root patch entirely
This allows users to use avbroot for just resigning an OTA with their
own signing keys.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-27 16:35:46 -04:00
Andrew Gunnerson 883a5da7a8 Merge pull request #96 from chenxiaolong/deps
Update AOSP submodules and test container image versions
2023-05-23 15:38:05 -04:00
Andrew Gunnerson e51c3661dd tests: Update container image distros to the latest versions
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-23 15:27:20 -04:00
Andrew Gunnerson 6e6805cdb5 Update AOSP submodules dependencies to the latest master commits
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-23 15:11:47 -04:00
Andrew Gunnerson 6e7c516736 Merge pull request #95 from chenxiaolong/readme-calyxos
README.md: Add reference to `oemunlockonboot` in the CalyxOS warning message
2023-05-23 13:44:58 -04:00
Andrew Gunnerson 2982f00ef3 README.md: Add reference to oemunlockonboot in the CalyxOS warning message
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-23 13:43:55 -04:00
Andrew Gunnerson 59a3947ae3 Merge pull request #92 from chenxiaolong/oemunlock
Add Magisk module to enable OEM unlocking on every boot
2023-05-23 13:36:49 -04:00
Andrew Gunnerson f507e5a32f modules/build.py: Allow building individual modules
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-23 00:06:24 -04:00
Andrew Gunnerson 53e0e30c86 Add Magisk module to enable OEM unlocking on every boot
The module helps reduce the chance of OEM unlocking being disabled,
whether by the user or by some OS's initial setup wizard. It works by
running some Java code at boot, which connects to the `OemLockService`
binder service and calls `setOemUnlockAllowedByUser(true)`, the same as
what the Settings app does.

Fixes: #8
Issue: #84

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-23 00:06:24 -04:00
Andrew Gunnerson ad0f640890 Merge pull request #94 from chenxiaolong/zip_extra
Strip out 0xd935 extra field record in zip entries
2023-05-23 00:05:39 -04:00
Andrew Gunnerson dc81e8571f Strip out 0xd935 extra field record in zip entries
The extra field record was previously stripped out due to a bug in
Python's zipfile implementation. That was fixed by [1], which was
backported to 3.10 and 3.11, but not 3.9.

This commit explicitly strips out the 0xd935 record to ensure that the
checksums of the patched files are the same across all Python versions.
This is probably the correct thing to do anyway, since the record is
related to zip entry alignment [2], which we don't do.

Note that the Python bug can affect other extra field records too, but
we don't see that in practice.

[1] https://github.com/python/cpython/commit/62c0327487ce39ec6504919b7712e0f197075ef9
[2] https://android.googlesource.com/platform/build/+/android-13.0.0_r1/tools/signapk/src/com/android/signapk/SignApk.java#133

Fixes: #93

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-05-22 23:52:03 -04:00
Andrew Gunnerson 7d5977b410 Merge pull request #89 from chenxiaolong/magisk-26.1
avbroot/boot.py: Allow Magisk 261xx versions
2023-04-12 02:31:45 -04:00
Andrew Gunnerson 7c2e322a37 avbroot/boot.py: Allow Magisk 261xx versions
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-04-12 02:31:23 -04:00
Andrew Gunnerson f1eb67b906 Merge pull request #88 from chenxiaolong/old_magisk
Drop support for Magisk versions <25102
2023-04-05 18:43:48 -04:00
Andrew Gunnerson fbfaae090c Drop support for Magisk versions <25102
These versions are missing Magisk commit
1f8c063dc64806c4f7320ed66c785ff7bc116383, which fixes booting into
recovery on devices that use Android 13 GKIs. Trying to use these
versions with avbroot would prevent the user from installing future OTAs
without manually flashing a boot image patched with a newer Magisk
version while booted into Android first.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-04-05 18:32:38 -04:00
Andrew Gunnerson 00fad4effc Merge pull request #87 from chenxiaolong/magisk_26000
Add support for Magisk >=25211
2023-04-05 18:31:17 -04:00
Andrew Gunnerson 50483b4ffa tests: Update Magisk to 26000 and OTAs to their latest versions
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-04-05 18:14:32 -04:00
Andrew Gunnerson 9c01d3b7e6 Add support for Magisk >=25211
In addition to the preinit device, Magisk now requires a random seed to
be added to the Magisk config in the boot image. Magisk's boot_patch.sh
generates a new seed every time an image is patched, but avbroot will
use the hardcoded seed 0xfedcba9876543210 to guarantee byte-for-byte
reproducibility of the output file. This can be overridden with
--magisk-random-seed <uint64>.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-04-05 17:27:08 -04:00
Andrew Gunnerson f5b886df84 Merge pull request #86 from chenxiaolong/magisk-preinit
Switch to Magisk 25211's PREINITDEVICE
2023-04-05 15:54:42 -04:00
Andrew Gunnerson 27c2bed773 Switch to Magisk 25211's PREINITDEVICE
Unlike the prior RULESDEVICE, PREINITDEVICE uses a block device name
since the rdev major/minor is not guaranteed to remain the same across
reboots. This commit completely drops support for RULESDEVICE (25207
through 25210) since it never made it to a stable Magisk release.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-25 19:51:22 -04:00
Andrew Gunnerson 0fff7b77dd Merge pull request #85 from chenxiaolong/calyxos
README.md: Add warning about CalyxOS automatically turning off OEM unlocking
2023-03-24 18:41:12 -04:00
Andrew Gunnerson 543d2eafc6 README.md: Add warning about CalyxOS automatically turning off OEM unlocking
Issue: #84

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-24 18:32:34 -04:00
Andrew Gunnerson 5c1a4d19b0 Merge pull request #82 from chenxiaolong/magisk-25207
Magisk >=25207 require a rules device ID
2023-03-11 20:38:23 -05:00
Andrew Gunnerson 0a1888ad94 Magisk >=25207 require a rules device ID
Newer Magisk versions no longer try to autodetect a writable ext4
partition for storing SELinux rules during boot. Instead, the block
device is detected during boot image patching and is stored in the
ramdisk's `.backup/.magisk` as `makedev(rdev_maj, rdev_min)`.

This unfortunately complicates the patching process for avbroot. Even if
we replicate Magisk's algorithm for finding a suitable partition,
there's no way to find the block device's rdev for it with the
information contained in the OTA package. This is the first change that
adds a hard dependency on information only attainable from a running
device.

For these newer Magisk versions, the user will have to patch the boot
image once in the Magisk app (must be on the target device) and then run
`avbroot magisk-info` to show the computed device ID. Then, avbroot can
use this during patching via `--magisk-rules-device`. If the user's
device is unable to run the Magisk app prior to patching (eg.
unbootable), they'll have to go through the patching process twice, once
with `--ignore-magisk-warnings` and a second time with the proper device
ID specified.

When using `--ignore-magisk-warnings`, root still works, but there will
be subtle issues, like certain modules failing to load.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-09 17:01:39 -05:00
Andrew Gunnerson 90b1964b55 Merge pull request #81 from pascallj/lookup_only
Use `lookup-only` action to check if cache exists
2023-03-09 16:50:43 -05:00
Pascal Roeleven 9d50d41f6b Give names to reusable workflows 2023-03-09 19:57:02 +01:00
Pascal Roeleven d53896f952 Use actions/cache lookup-only instead of custom action
Now that the lookup-only option is available, we should use this instead
2023-03-09 19:57:00 +01:00
Andrew Gunnerson 1bde511aba Merge pull request #79 from pascallj/cache_keys
Make cache pre-checks more robust
2023-03-06 12:43:55 -05:00
Pascal Roeleven df9a6c2970 Make cache pre-checks more robust
Also fix preload Magisk cache workflow
2023-03-06 12:18:57 +01:00
Andrew Gunnerson 6cb035870e Merge pull request #78 from chenxiaolong/external
Move sys.path modification to __init__.py
2023-03-05 15:00:52 -05:00
Andrew Gunnerson 1bdac19c44 Move sys.path modification to __init__.py
This way, the module path is automatically updated when avbroot is
imported. This also fixes the lint warning about `external` being
imported, but not used.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-05 14:44:54 -05:00
Andrew Gunnerson 2f9b2c5d92 Merge pull request #75 from chenxiaolong/combine
Merge `tests_ci` into `tests`
2023-03-05 14:43:01 -05:00
Andrew Gunnerson 4847ebf27a Merge tests_ci into tests
This commit merges the CI tests from `tests_ci/` into `tests/` so we
have a single way to test against both full OTAs and stripped/dummy
OTAs.

Features kept from tests_ci:

* Support for dummy OTAs. They're now called stripped OTAs to hopefully
  better signify that they're a stripped down version of the original
  file instead of a test file created from scratch.
* Extracting AVB partitions and verifying their hashes.
* Writing sparse files where possible.
* Ability to change the working directory for downloads and output
  files.

Test script changes:

* There are now 4 subcommands:
    strip -i <input> -o <output>
    add -u <url> -d <device> [-H <expected hash>]
    download [--magisk | --no-magisk] [[-d <device>] ... | --no-devices]
    test [[-d <device>] ...]
* Downloads now use the parallel downloader for both full and stripped
  OTAs.

Config file changes:

* It now uses strictyaml instead of configparser/TOML since it's a bit
  more readable now that we have more nesting in the data structure. The
  config loader now also makes use of strictyaml's schema feature.
* All hashes are now SHA-256 for consistency.
* For stripped OTAs, the list of byte ranges now uses half-open
  intervals for easier calculations.
* Use device IDs as the key instead of the marketing model name.

CI changes:

* Compute all cache keys (and prefixes) in the main workflow and pass
  them to the preload scripts.
* Only run on `push` for the `master` branch to avoid double workflow
  runs on PRs from internal branches.
* Increase timeout for patching tests because `tests.py` patches twice
  (once with `--magisk` and once with `--prepatched`).

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-04 21:39:08 -05:00
Andrew Gunnerson 87af006b35 Merge pull request #77 from pascallj/pull_request
Run workflow on pull requests
2023-03-03 15:10:50 -05:00
Pascal Roeleven e9419850f5 Run workflow on pull requests 2023-03-03 16:00:25 +01:00
Andrew Gunnerson 545007eee0 Merge pull request #74 from chenxiaolong/sparse
Produce sparse output files
2023-03-02 16:04:13 -05:00
Andrew Gunnerson 21225c218b Produce sparse output files
This significantly reduces the size when patching dummy OTAs. This is a
naive implementation that just seeks when the entire write() buffer is
all zeroes, but that seems to be more than sufficient. The output files
have fewer blocks allocated than the (dummy) input files.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-02 15:58:06 -05:00
Andrew Gunnerson 190dd23e35 Merge pull request #73 from pascallj/sparse
Use sparse testing images
2023-03-02 15:26:00 -05:00
Pascal Roeleven 9dec3f8408 Use sparse images in GA
Also invalidate caches by adding version prefix
2023-03-02 15:22:34 +01:00
Pascal Roeleven 632cbeecaa Don't compress images by default
Now that we are writing sparse images, compressing is no longer
necessary by default.
2023-03-02 15:22:25 +01:00
Pascal Roeleven d9495219f7 Write sparse file instead of zeros 2023-03-02 14:08:01 +01:00