Commit Graph

168 Commits

Author SHA1 Message Date
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
Pascal Roeleven 91447ba986 Make Crc32Hasher more Pythonic 2023-03-02 13:54:10 +01:00
Andrew Gunnerson 216c3b7d06 Merge pull request #72 from chenxiaolong/parallel_download
tests: Add native Python parallel download implementation
2023-03-01 17:51:10 -05:00
Andrew Gunnerson 003fbf18ba tests/downloader.py: Add MiB/s to DefaultDisplayCallback output
No fancy algorithm. Just a simple moving average over 5 seconds, updated
at 100ms intervals.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-01 17:44:17 -05:00
Andrew Gunnerson 76eec8fb6e tests/downloader.py: Avoid unnecessary buffer allocations in DownloadWorker
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-01 17:44:16 -05:00
Andrew Gunnerson db562315e9 tests: Drop aria2 dependency
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-01 17:44:15 -05:00
Andrew Gunnerson 69cb0dd4d7 tests: Add native Python parallel download implementation
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-03-01 17:44:03 -05:00
Andrew Gunnerson 1e07010eb7 Merge pull request #70 from pascallj/ci
Test all device images in Github Actions
2023-03-01 17:33:53 -05:00
Andrew Gunnerson e7c6d06e45 Merge pull request #69 from pascallj/device_test
Use dummy images for testing
2023-03-01 17:22:16 -05:00
Pascal Roeleven f8ef998794 Reorder steps 2023-03-01 16:50:12 +01:00
Pascal Roeleven 4ac7826c32 Cache tox environments with tox hash 2023-03-01 16:11:32 +01:00
Pascal Roeleven 50b8d28779 Cache images with database hash 2023-03-01 16:04:14 +01:00
Pascal Roeleven 0b6f76637f Move caching of Magisk to setup workflow
It's unnecessary to spin up an entire runner for just this short and
simple task.
2023-03-01 16:04:14 +01:00
Pascal Roeleven 41ce7d653f Cache Magisk with database hash
Simplify caching by caching on database hash instead of Magisk hash.
hashFiles is only available in the steps, hence the reason for it being
exported to the outputs from the steps (and not directly).
2023-03-01 16:03:59 +01:00
Pascal Roeleven ccf64c40b0 Add url for Oneplus 10 Pro 2023-03-01 13:12:24 +01:00
Pascal Roeleven a7170ea4c0 Replace double quotes with single quotes where possible
Also formatted differently to adhere more to the style used in the rest
of the project
2023-02-28 21:39:54 +01:00
Pascal Roeleven 13b9877e2c Fix testing for Oneplus images
Also added to the database
2023-02-28 21:35:07 +01:00
Pascal Roeleven f12d42359d Update database 2023-02-28 21:35:07 +01:00
Pascal Roeleven 017889684d Automatically test full OTA zip 2023-02-28 21:35:07 +01:00
Pascal Roeleven 6ce86be917 Add hashes to database automatically 2023-02-28 21:35:07 +01:00
Pascal Roeleven 38dd0917e6 Automatically add device to database 2023-02-28 21:35:07 +01:00
Pascal Roeleven 10d964b7ef Zero all partitions we never intend to use 2023-02-28 21:35:07 +01:00
Pascal Roeleven fc6564ea47 Use constant instead of value 2023-02-28 21:35:07 +01:00
Pascal Roeleven 0aa18ff0a6 Use unittest.mock instead of manually patching 2023-02-28 21:34:49 +01:00
Pascal Roeleven a4f0086368 Improve reliability for getting file offset in zip 2023-02-28 12:55:47 +01:00
Andrew Gunnerson 07b0e552f9 Merge pull request #71 from chenxiaolong/ota
avbroot/ota.py: Remove OnePlus comment about ZERO blocks
2023-02-27 20:14:41 -05:00
Andrew Gunnerson 3bd5f77716 avbroot/ota.py: Remove OnePlus comment about ZERO blocks
There's no OnePlus-specific behavior here. ZERO blocks are supposed to
be missing several fields, including data_sha256_hash.

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
2023-02-27 20:13:06 -05:00
Andrew Gunnerson ed915b5ad6 Merge pull request #68 from pascallj/external
Import external in ota
2023-02-27 16:30:07 -05:00
Pascal Roeleven fb2c512248 Test all device images in Github Actions 2023-02-27 16:38:39 +01:00
Pascal Roeleven 0090de3a48 Test dummy images with tox 2023-02-27 16:38:26 +01:00
Pascal Roeleven 8f2d09b447 Add script to test with dummy images 2023-02-27 16:38:26 +01:00