Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .github/scripts/release/bundle-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,22 @@ def bundle_platform_tools(url: str) -> None:


def bundle_avb_tools() -> None:
"""Copy AVB tools from vendor/avb submodule into bin/tools/ for packaging."""
avb_dir = REPO_ROOT / "vendor" / "avb"
"""Copy AVB test keys from vendor/avbtool-rs into bin/tools/ for packaging."""
keys_dir = REPO_ROOT / "vendor" / "avbtool-rs" / "src" / "keys"
copy_map = {
avb_dir / "avbtool.py": TOOLS_DIR / "avbtool.py",
avb_dir / "test" / "data" / "testkey_rsa4096.pem": TOOLS_DIR
/ "testkey_rsa4096.pem",
avb_dir / "test" / "data" / "testkey_rsa2048.pem": TOOLS_DIR
/ "testkey_rsa2048.pem",
keys_dir / "testkey_rsa4096.pem": TOOLS_DIR / "testkey_rsa4096.pem",
keys_dir / "testkey_rsa2048.pem": TOOLS_DIR / "testkey_rsa2048.pem",
}

if all(dst.exists() for dst in copy_map.values()):
print("[bundle-tools] AVB tools already present, skipping.")
print("[bundle-tools] AVB test keys already present, skipping.")
return

for src, dst in copy_map.items():
if not src.exists():
raise RuntimeError(
f"vendor/avb submodule missing {src.relative_to(REPO_ROOT)}. "
f"Run: git submodule update --init vendor/avb"
f"vendor/avbtool-rs submodule missing {src.relative_to(REPO_ROOT)}. "
f"Run: git submodule update --init vendor/avbtool-rs"
)
shutil.copy2(src, dst)
print(f"[bundle-tools] Copied {src.name} -> {dst.relative_to(REPO_ROOT)}")
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/build-archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ jobs:
name: qdl-rs-windows
path: bin/tools/

- name: Download avbtool-rs artifact
uses: actions/download-artifact@v8
with:
name: avbtool-rs-windows
path: bin/tools/

- name: Bundle base tools
run: python .github/scripts/release/bundle-tools.py

Expand All @@ -59,7 +65,7 @@ jobs:
'bin/tools/magiskboot_xz_helper.exe',
'bin/tools/adb.exe',
'bin/tools/fastboot.exe',
'bin/tools/avbtool.py',
'bin/tools/avbtool-rs.exe',
'bin/tools/kptools.exe',
'bin/tools/testkey_rsa4096.pem',
'bin/tools/testkey_rsa2048.pem',
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/build-avbtool-rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build avbtool-rs

on:
push:
paths:
- 'vendor/avbtool-rs/**'
- '.github/workflows/build-avbtool-rs.yml'
pull_request:
paths:
- 'vendor/avbtool-rs/**'
- '.github/workflows/build-avbtool-rs.yml'
workflow_call:

jobs:
build-windows:
runs-on: windows-latest
timeout-minutes: 20
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v6
with:
submodules: true

- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc

- uses: Swatinem/rust-cache@v2
with:
workspaces: vendor/avbtool-rs
cache-on-failure: true

- name: Build avbtool-rs
working-directory: vendor/avbtool-rs
run: cargo build --release

- name: Smoke test
run: vendor/avbtool-rs/target/release/avbtool-rs.exe version

- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: avbtool-rs-windows
path: vendor/avbtool-rs/target/release/avbtool-rs.exe
if-no-files-found: error
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
build-qdlrs:
uses: ./.github/workflows/build-qdlrs.yml

build-avbtool-rs:
uses: ./.github/workflows/build-avbtool-rs.yml

preflight:
needs: test
runs-on: windows-latest
Expand Down Expand Up @@ -47,7 +50,7 @@ jobs:
"- Config version matches tag ?" >> $env:GITHUB_STEP_SUMMARY

build:
needs: [preflight, build-qdlrs]
needs: [preflight, build-qdlrs, build-avbtool-rs]
uses: ./.github/workflows/build-archive.yml
with:
tag-name: ${{ needs.preflight.outputs.tag_name }}
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/windows_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
with:
task: architecture

build-avbtool-rs:
uses: ./.github/workflows/build-avbtool-rs.yml

build-tools:
runs-on: windows-latest
timeout-minutes: 15
Expand Down Expand Up @@ -59,11 +62,10 @@ jobs:
path: |
bin/tools/magiskboot.exe
bin/tools/magiskboot_xz_helper.exe
bin/tools/openssl.exe
bin/tools/*.dll

integration-test:
needs: [unit-test, build-tools]
needs: [unit-test, build-tools, build-avbtool-rs]
runs-on: windows-latest
timeout-minutes: 30
env:
Expand Down Expand Up @@ -96,6 +98,12 @@ jobs:
name: tools-exe
path: bin/tools

- name: Download avbtool-rs artifact
uses: actions/download-artifact@v8
with:
name: avbtool-rs-windows
path: bin/tools

- name: Run Integration Tests
run: |
pytest -s tests/ -m integration --run-integration --cov=bin/ltbox --cov-report=term-missing
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[submodule "vendor/qdlrs"]
path = vendor/qdlrs
url = https://github.com/qualcomm/qdlrs.git
url = https://github.com/miner7222/qdlrs.git
[submodule "vendor/avb"]
path = vendor/avb
url = https://android.googlesource.com/platform/external/avb
branch = refs/heads/main-kernel
[submodule "vendor/MagiskbootAlone"]
path = vendor/MagiskbootAlone
url = https://github.com/miner7222/MagiskbootAlone.git
[submodule "vendor/avbtool-rs"]
path = vendor/avbtool-rs
url = https://github.com/miner7222/avbtool-rs
3 changes: 1 addition & 2 deletions bin/ltbox/actions/root/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,7 @@ def _sign_recovery_image(

subprocess.run(
[
str(const.PYTHON_EXE),
str(const.AVBTOOL_PY),
str(const.AVBTOOL_RS),
"erase_footer",
"--image",
str(final_twrp),
Expand Down
16 changes: 9 additions & 7 deletions bin/ltbox/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,20 @@ def __init__(self):

# --- Vendor Paths ---
self.vendor_dir = self.base_dir / "vendor"
self.avb_dir = self.vendor_dir / "avb"
self.avb_testkeys_dir = self.avb_dir / "test" / "data"
self.avbtool_rs_dir = self.vendor_dir / "avbtool-rs"
self.avb_testkeys_dir = self.avbtool_rs_dir / "src" / "keys"

# --- Executables ---
self.python_exe = self.python_dir / "python.exe"
if not self.python_exe.exists():
self.python_exe = Path(sys.executable)
self.adb_exe = self.tools_dir / "adb.exe"
self.fastboot_exe = self.tools_dir / "fastboot.exe"
self.avbtool_py = self.avb_dir / "avbtool.py"
if not self.avbtool_py.exists():
self.avbtool_py = self.tools_dir / "avbtool.py"
self.avbtool_rs = self.tools_dir / "avbtool-rs.exe"
if not self.avbtool_rs.exists():
self.avbtool_rs = (
self.avbtool_rs_dir / "target" / "release" / "avbtool-rs.exe"
)
self.qdlrs_exe = self.tools_dir / "qdl-rs.exe"
self.magiskboot_exe = self.tools_dir / "magiskboot.exe"

Expand Down Expand Up @@ -248,13 +250,13 @@ def load_settings_raw() -> Dict[str, Any]:
FN_VENDOR_BOOT_PRC = CONF.fn_vendor_boot_prc

VENDOR_DIR = CONF.vendor_dir
AVB_DIR = CONF.avb_dir
AVBTOOL_RS_DIR = CONF.avbtool_rs_dir
AVB_TESTKEYS_DIR = CONF.avb_testkeys_dir

PYTHON_EXE = CONF.python_exe
ADB_EXE = CONF.adb_exe
FASTBOOT_EXE = CONF.fastboot_exe
AVBTOOL_PY = CONF.avbtool_py
AVBTOOL_RS = CONF.avbtool_rs
QDLRS_EXE = CONF.qdlrs_exe
MAGISKBOOT_EXE = CONF.magiskboot_exe

Expand Down
3 changes: 1 addition & 2 deletions bin/ltbox/info_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def collect_info_scan_files(paths: List[str]) -> List[Path]:

def build_info_scan_command(image_path: Path, constants: Any) -> List[str]:
return [
str(constants.PYTHON_EXE),
str(constants.AVBTOOL_PY),
str(constants.AVBTOOL_RS),
"info_image",
"--image",
str(image_path),
Expand Down
Loading
Loading