Skip to content
Closed
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
5 changes: 2 additions & 3 deletions .github/workflows/build-archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
fw-password: ${{ secrets.TEST_FW_PASSWORD }}
fw-url: ${{ secrets.TEST_FW_URL }}

- name: Download tools artifact from test job
- name: Download magiskboot-rs artifact
uses: actions/download-artifact@v8
with:
name: tools-exe
name: magiskboot-rs-windows
path: bin/tools/

- name: Download qdl-rs artifact
Expand All @@ -62,7 +62,6 @@ jobs:
$requiredFiles = @(
'bin/tools/qdl-rs.exe',
'bin/tools/magiskboot.exe',
'bin/tools/magiskboot_xz_helper.exe',
'bin/tools/adb.exe',
'bin/tools/fastboot.exe',
'bin/tools/avbtool-rs.exe',
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/build-magiskboot-rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build magiskboot-rs

on:
push:
paths:
- 'vendor/magiskboot-rs/**'
- '.github/workflows/build-magiskboot-rs.yml'
pull_request:
paths:
- 'vendor/magiskboot-rs/**'
- '.github/workflows/build-magiskboot-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/magiskboot-rs
cache-on-failure: true

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

- name: Smoke test
run: vendor/magiskboot-rs/target/release/magiskboot.exe sha1 vendor/magiskboot-rs/LICENSE

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

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

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

build:
needs: [preflight, build-qdlrs, build-avbtool-rs]
needs: [preflight, build-qdlrs, build-avbtool-rs, build-magiskboot-rs]
uses: ./.github/workflows/build-archive.yml
with:
tag-name: ${{ needs.preflight.outputs.tag_name }}
Expand All @@ -71,6 +74,7 @@ jobs:
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.preflight.outputs.tag_name }}
draft: true
prerelease: true
generate_release_notes: true
files: |
Expand Down
50 changes: 5 additions & 45 deletions .github/workflows/windows_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,11 @@ jobs:
build-avbtool-rs:
uses: ./.github/workflows/build-avbtool-rs.yml

build-tools:
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
submodules: true

- name: Setup Python & Dependencies
uses: ./.github/actions/setup-python-deps
with:
python-version: '3.14'

- name: Cache and Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MSYS
install: gcc cmake make zlib-devel git
cache: true

- name: Cache Compiled Tools
uses: actions/cache@v5
with:
path: bin/tools
key: tools-bin-v4-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('vendor/MagiskbootAlone/**', 'tests/scripts/build_tools.py', 'tests/scripts/cache_fw.py', 'bin/ltbox/config.json', '.github/ci-tools.json', '.github/actions/setup-fw-env/action.yml', '.github/workflows/windows_test.yml') }}
restore-keys: |
tools-bin-v4-${{ runner.os }}-${{ runner.arch }}-

- name: Build magiskboot
run: python tests/scripts/build_tools.py

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

- name: Upload tools artifact
uses: actions/upload-artifact@v7
with:
name: tools-exe
path: |
bin/tools/magiskboot.exe
bin/tools/magiskboot_xz_helper.exe
bin/tools/*.dll
build-magiskboot-rs:
uses: ./.github/workflows/build-magiskboot-rs.yml

integration-test:
needs: [unit-test, build-tools, build-avbtool-rs]
needs: [unit-test, build-magiskboot-rs, build-avbtool-rs]
runs-on: windows-latest
timeout-minutes: 30
env:
Expand All @@ -92,10 +52,10 @@ jobs:
fw-password: ${{ secrets.TEST_FW_PASSWORD }}
fw-url: ${{ secrets.TEST_FW_URL }}

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

- name: Download avbtool-rs artifact
Expand Down
10 changes: 3 additions & 7 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
[submodule "vendor/qdlrs"]
path = vendor/qdlrs
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
[submodule "vendor/magiskboot-rs"]
path = vendor/magiskboot-rs
url = https://github.com/miner7222/magiskboot-rs
3 changes: 0 additions & 3 deletions bin/ltbox/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ def _get_tool_env() -> dict:
env = os.environ.copy()
paths = [str(const.TOOLS_DIR)]
env["PATH"] = os.pathsep.join(paths) + os.pathsep + env["PATH"]
magiskboot_xz_helper = const.TOOLS_DIR / "magiskboot_xz_helper.exe"
if magiskboot_xz_helper.exists():
env["MAGISKBOOT_RUST_XZ_HELPER"] = str(magiskboot_xz_helper)
return env


Expand Down
5 changes: 0 additions & 5 deletions tests/actions/integration/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

_REAL_TOOLS_DIR = Path(__file__).resolve().parents[3] / "bin" / "tools"
MAGISKBOOT_PATH = _REAL_TOOLS_DIR / "magiskboot.exe"
MAGISKBOOT_XZ_HELPER_PATH = _REAL_TOOLS_DIR / "magiskboot_xz_helper.exe"
KPTOOLS_PATH = _REAL_TOOLS_DIR / "kptools.exe"


Expand Down Expand Up @@ -66,10 +65,6 @@ def _copy_bundled_magiskboot(tools_dir: Path) -> Path:

magiskboot_exe = tools_dir / "magiskboot.exe"
shutil.copy(MAGISKBOOT_PATH, magiskboot_exe)
if MAGISKBOOT_XZ_HELPER_PATH.exists():
shutil.copy(MAGISKBOOT_XZ_HELPER_PATH, tools_dir / "magiskboot_xz_helper.exe")
for dll_file in MAGISKBOOT_PATH.parent.glob("*.dll"):
shutil.copy(dll_file, tools_dir / dll_file.name)
return magiskboot_exe


Expand Down
5 changes: 1 addition & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

ROOT = Path(__file__).resolve().parents[1]
BIN_PATH = ROOT / "bin"
INTEGRATION_TOOL_FILES = (
"magiskboot.exe",
"magiskboot_xz_helper.exe",
)
INTEGRATION_TOOL_FILES = ("magiskboot.exe",)

if str(BIN_PATH) not in sys.path:
sys.path.insert(0, str(BIN_PATH))
Expand Down
5 changes: 1 addition & 4 deletions tests/core/test_conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ def test_integration_tools_ready_true_when_all_downloaded_tools_exist(
with patch.object(conftest, "ROOT", tmp_path):
assert conftest._integration_tools_ready() is True

def test_integration_tools_ready_false_when_any_required_tool_missing(
self, tmp_path
):
def test_integration_tools_ready_false_when_no_tools_exist(self, tmp_path):
tools_dir = tmp_path / "bin" / "tools"
tools_dir.mkdir(parents=True)
(tools_dir / "magiskboot.exe").write_text("stub", encoding="utf-8")

with patch.object(conftest, "ROOT", tmp_path):
assert conftest._integration_tools_ready() is False
20 changes: 1 addition & 19 deletions tests/core/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@


class TestUtils:
def test_get_tool_env_sets_magiskboot_helper_when_present(self, tmp_path):
def test_get_tool_env_prepends_tools_dir_to_path(self, tmp_path):
tools_dir = tmp_path / "tools"
tools_dir.mkdir()
helper = tools_dir / "magiskboot_xz_helper.exe"
helper.write_text("stub", encoding="utf-8")

utils._get_tool_env.cache_clear()
with (
Expand All @@ -25,22 +23,6 @@ def test_get_tool_env_sets_magiskboot_helper_when_present(self, tmp_path):
):
env = utils._get_tool_env()

assert env["MAGISKBOOT_RUST_XZ_HELPER"] == str(helper)
assert env["PATH"].split(";")[0] == str(tools_dir)
utils._get_tool_env.cache_clear()

def test_get_tool_env_skips_magiskboot_helper_when_missing(self, tmp_path):
tools_dir = tmp_path / "tools"
tools_dir.mkdir()

utils._get_tool_env.cache_clear()
with (
patch("ltbox.utils.const.TOOLS_DIR", tools_dir),
patch.dict("ltbox.utils.os.environ", {"PATH": "C:\\base"}, clear=True),
):
env = utils._get_tool_env()

assert "MAGISKBOOT_RUST_XZ_HELPER" not in env
assert env["PATH"].split(";")[0] == str(tools_dir)
utils._get_tool_env.cache_clear()

Expand Down
10 changes: 4 additions & 6 deletions tests/patch/test_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def run(self, *args, **kwargs):
assert result == tmp_path / "init_boot_patched.img"
assert not any(call and call[0] == "dtb" for call in run_calls)

def test_magisk_cpio_patch_keeps_helper_env(self, tmp_path):
def test_magisk_cpio_patch_passes_env_vars(self, tmp_path):
work_dir = tmp_path / "work"
work_dir.mkdir()
for name in [
Expand Down Expand Up @@ -497,16 +497,15 @@ def run(self, *args, **kwargs):
(work_dir / "new-boot.img").write_bytes(b"\x00" * 64)
return result

helper_path = tmp_path / "bin" / "tools" / "magiskboot_xz_helper.exe"
helper_path.parent.mkdir(parents=True)
helper_path.write_text("stub", encoding="utf-8")
tools_dir = tmp_path / "bin" / "tools"
tools_dir.mkdir(parents=True)

with (
patch("ltbox.patch.root.const.BASE_DIR", tmp_path),
patch("ltbox.patch.root.const.FN_INIT_BOOT", "init_boot.img"),
patch("ltbox.patch.root.const.FN_INIT_BOOT_ROOT", "init_boot_patched.img"),
patch("ltbox.patch.root.utils.MagiskBootWrapper", FakeWrapper),
patch("ltbox.patch.root.utils.const.TOOLS_DIR", helper_path.parent),
patch("ltbox.patch.root.utils.const.TOOLS_DIR", tools_dir),
):
from ltbox import utils

Expand All @@ -520,7 +519,6 @@ def run(self, *args, **kwargs):

assert result == tmp_path / "init_boot_patched.img"
assert captured_env is not None
assert captured_env["MAGISKBOOT_RUST_XZ_HELPER"] == str(helper_path)
assert captured_env["KEEPVERITY"] == "true"
assert captured_env["KEEPFORCEENCRYPT"] == "true"

Expand Down
Loading
Loading