Skip to content
Draft
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
68 changes: 9 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ jobs:
"build-tools;34.0.0" \
"ndk;$ANDROID_NDK_VERSION" >/dev/null
set -o pipefail
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$ANDROID_NDK_VERSION" \
>> "$GITHUB_ENV"

- name: Resolve version and variant
id: metadata
Expand Down Expand Up @@ -132,79 +130,31 @@ jobs:
echo "DAWNSHELL_RELEASE_KEY_PASSWORD=$KEY_PASSWORD"
} >> "$GITHUB_ENV"

- name: Build bootstrap runtime from pinned source
- name: Lint shell scripts
shell: bash
run: |
set -euo pipefail
"$DAWNSHELL_SHELLCHECK" --version
"$DAWNSHELL_SHELLCHECK" scripts/*.sh app/src/main/assets/bfu/*.sh
# Report which script failed. A bare list of commands collapses into
# one opaque step failure that hides the actual stage.
for stage in \
scripts/test-release-compliance.sh \
scripts/build-bootstrap-runtime.sh \
scripts/test-hardware-codec-bridge.sh \
scripts/test-ffmpeg-bridge-plan.sh \
scripts/test-kernel-quirk-guards.sh \
scripts/test-gpu-status-tool.sh \
scripts/test-live-codec-pipeline.sh \
scripts/test-host-reboot-isolation.sh \
scripts/test-compatibility-policy.sh \
scripts/test-dashboard-settings-ux.sh \
scripts/test-rootfs-path-resolution.sh \
scripts/test-lifecycle-control-policy.sh \
scripts/test-croc-compatibility-wrapper.sh \
scripts/test-documentation.sh ; do
echo "::group::$stage"
stage_log="$RUNNER_TEMP/$(basename "$stage").log"
if ! "./$stage" 2>&1 | tee "$stage_log"; then
echo "::endgroup::"
echo "::error::failing stage: $stage"
trace_log="$RUNNER_TEMP/$(basename "$stage").trace.log"
set +e
bash -x "./$stage" > "$trace_log" 2>&1
trace_status=$?
set -e
trace_tail="$(tail -n 40 "$trace_log" | tr '\n' ' ' | tr '\r' ' ')"
trace_tail="${trace_tail//'%'/'%25'}"
trace_tail="${trace_tail//$'\r'/'%0D'}"
trace_tail="${trace_tail//$'\n'/'%0A'}"
echo "::error::failure trace exit=$trace_status: $trace_tail"
# The job summary survives log-access restrictions, so record
# the failing stage there as well.
{
echo "failing stage: $stage"
echo "trace exit: $trace_status"
echo
echo '```text'
tail -n 240 "$trace_log"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
exit 1
fi
echo "::endgroup::"
done
"$DAWNSHELL_SHELLCHECK" scripts/*.sh scripts/tests/*/*.sh app/src/main/assets/bfu/*.sh

- name: Build and test Android application
- name: Build, verify and test Android application
id: apk
shell: bash
env:
VARIANT: ${{ steps.metadata.outputs.variant }}
run: |
set -euo pipefail
if [[ "$VARIANT" == release ]]; then
./gradlew --no-daemon clean \
:app:assembleRelease :app:lintRelease :app:testDebugUnitTest
else
./gradlew --no-daemon clean \
:app:assembleDebug :app:lintDebug :app:testDebugUnitTest
fi
# Gradle compiles the bundled native runtime from pinned source for
# every ABI, then runs the policy scripts, lint and unit tests.
task_variant="${VARIANT^}"
./gradlew --no-daemon --console=plain clean policyChecks \
":app:assemble$task_variant" ":app:lint$task_variant" :app:testDebugUnitTest
apk_path="$(find "app/build/outputs/apk/$VARIANT" \
-maxdepth 1 -type f -name '*.apk' -print -quit)"
[[ -n "$apk_path" && -s "$apk_path" ]]
"$ANDROID_HOME/build-tools/34.0.0/apksigner" \
verify --verbose --print-certs "$apk_path"
./scripts/test-release-compliance.sh "$apk_path"
./scripts/tests/host/test-release-compliance.sh "$apk_path"
echo "apk_path=$apk_path" >> "$GITHUB_OUTPUT"

- name: Package APK, corresponding source, licenses and checksums
Expand Down
9 changes: 5 additions & 4 deletions README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ PIN 입력 전에 사용할 데이터에는 재사용 auth key, API token, SSH
```sh
export JAVA_HOME=/path/to/jdk17
export ANDROID_HOME=/path/to/android-sdk
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/29.0.14206865"
./scripts/build-all.sh
./gradlew clean policyChecks :app:lintDebug :app:testDebugUnitTest :app:stageDebugApk
```

기본값은 `make -j"$(nproc)"`이며 `DAWNSHELL_BUILD_JOBS`로 병렬 작업 수를 제한할
수 있습니다. debug APK는 `dist/dawnshell-app_v<version>+debug.apk`에 생성됩니다.
Gradle이 내장 네이티브 런타임을 고정 소스에서 모든 ABI용으로 컴파일하며, SDK에
NDK `29.0.14206865`가 설치되어 있어야 합니다. 기본값은 `make -j"$(nproc)"`이며
`DAWNSHELL_BUILD_JOBS`로 병렬 작업 수를 제한할 수 있습니다. debug APK는
`dist/dawnshell-app_v<version>+debug.apk`에 생성됩니다.

필요 패키지, Windows/MSYS2, 개별 검사, 서명, CI와 Release 묶음은
[빌드와 배포](docs/building.ko.md)를 참고하세요. 공개 debug 키는 제품용 서명 키가
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ The short path is:
```sh
export JAVA_HOME=/path/to/jdk17
export ANDROID_HOME=/path/to/android-sdk
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/29.0.14206865"
./scripts/build-all.sh
./gradlew clean policyChecks :app:lintDebug :app:testDebugUnitTest :app:stageDebugApk
```

Compilation uses `make -j"$(nproc)"` by default. Set `DAWNSHELL_BUILD_JOBS` to
limit parallel jobs. The debug APK is written as
`dist/dawnshell-app_v<version>+debug.apk`.
Gradle compiles the bundled native runtime for every ABI from pinned source;
NDK `29.0.14206865` must be installed in the SDK. Compilation uses
`make -j"$(nproc)"` by default. Set `DAWNSHELL_BUILD_JOBS` to limit parallel
jobs. The debug APK is written as `dist/dawnshell-app_v<version>+debug.apk`.

See [Build and release](docs/building.md) for dependencies, Windows/MSYS2,
individual checks, signing, CI behavior, and release packaging. The public debug
Expand Down
60 changes: 51 additions & 9 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import com.android.build.api.variant.impl.VariantOutputImpl
import me.aroxu.dawnshell.gradle.BfuRuntimeAssetsTask
import me.aroxu.dawnshell.gradle.registerBfuRuntime
import java.util.Locale

plugins {
Expand Down Expand Up @@ -52,8 +54,11 @@ fun validateVersionName(versionName: String) {
}
}

val bfuNdkVersion = "29.0.14206865"

android {
namespace = "me.aroxu.dawnshell"
ndkVersion = bfuNdkVersion

compileSdk {
version = release(37) {
Expand Down Expand Up @@ -119,9 +124,18 @@ android {

}

val bfuRuntimeAssets = registerBfuRuntime(
ndkDirectory = androidComponents.sdkComponents.ndkDirectory,
ndkVersion = bfuNdkVersion,
androidApi = providers.gradleProperty("minSdkVersion").map { it.toInt() },
abiIds = providers.gradleProperty("dawnshellBfuAbis")
.orElse("armeabi-v7a,arm64-v8a,x86_64").get().split(","),
)

androidComponents {
onVariants { variant ->
variant.sources.assets?.addStaticSourceDirectory(generatedLicenseAssetsDir.get().asFile.path)
variant.sources.assets?.addGeneratedSourceDirectory(bfuRuntimeAssets, BfuRuntimeAssetsTask::outputDirectory)
val apkName = "dawnshell-app_" + apkVersionTag.ifEmpty { "v${android.defaultConfig.versionName}+${variant.buildType}" } + ".apk"
variant.outputs.forEach { (it as VariantOutputImpl).outputFileName.set(apkName) }
}
Expand Down Expand Up @@ -154,14 +168,7 @@ tasks.register("versionName") {
}
}

val bfuBootstrapAbis = listOf("armeabi-v7a", "arm64-v8a", "x86_64")
val bfuBootstrapExecutables = listOf(
"dawnshell-toolbox", "pkgdetails", "gpgv", "bfu-namespace-probe",
"dawnshell-fdguard",
"dawnshell-codec", "dawnshell-codec-worker")
val bfuBootstrapAssets = (bfuBootstrapAbis.flatMap { abi ->
bfuBootstrapExecutables.map { "bin/$abi/$it" } + "bin/$abi/runtime.properties"
} + listOf(
val bfuBootstrapAssets = listOf(
"bootstrap/debootstrap_1.0.141.tgz",
"bootstrap/debian-archive-keyring_2025.1_all.deb",
"bootstrap/SOURCES.lock",
Expand All @@ -179,7 +186,7 @@ val bfuBootstrapAssets = (bfuBootstrapAbis.flatMap { abi ->
"dawnshell-codec-long-run.sh",
"dawnshell-codec-concurrency-test.sh",
"dawnshell-codec-error-test.sh",
)).map { file("src/main/assets/bfu/$it") }
).map { file("src/main/assets/bfu/$it") }

val requiredLicenseFiles = listOf(
"README.md",
Expand Down Expand Up @@ -266,6 +273,41 @@ val verifyBfuBootstrapRuntime = tasks.register("verifyBfuBootstrapRuntime") {
}
}

val policyCheckTasks = fileTree(rootDir.resolve("scripts/tests/host")) { include("*.sh") }.files
.sortedBy { it.name }
.map { script ->
val taskName = "policyCheck" + script.nameWithoutExtension.removePrefix("test-")
.split("-").joinToString("") { it.replaceFirstChar(Char::uppercase) }
tasks.register<Exec>(taskName) {
group = "verification"
description = "Runs scripts/tests/host/${script.name}."
workingDir = rootDir
commandLine("bash", script.path)
// Scripts that inspect the built binaries declare it by reading the generated assets directory.
if (script.readText().contains("DAWNSHELL_BFU_ASSETS_DIR")) dependsOn(bfuRuntimeAssets)
doFirst {
environment("DAWNSHELL_BFU_ASSETS_DIR", bfuRuntimeAssets.get().outputDirectory.get().asFile.resolve("bfu").path)
}
}
}

val policyChecks = tasks.register("policyChecks") {
group = "verification"
description = "Runs every host-side policy and regression script in scripts/tests/host/."
dependsOn(policyCheckTasks)
}

tasks.named("check") {
dependsOn(policyChecks)
}

tasks.register<Copy>("stageDebugApk") {
description = "Copies the debug APK to dist/ for scripts/install.sh and the device tests."
dependsOn("assembleDebug")
from(layout.buildDirectory.dir("outputs/apk/debug")) { include("*.apk") }
into(rootProject.layout.projectDirectory.dir("dist"))
}

tasks.named("preBuild") {
dependsOn(verifyBfuBootstrapRuntime)
dependsOn(verifyOpenSourceLicenses)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/assets/bfu/bin/arm64-v8a/gpgv
Binary file not shown.
Binary file removed app/src/main/assets/bfu/bin/arm64-v8a/pkgdetails
Binary file not shown.
9 changes: 0 additions & 9 deletions app/src/main/assets/bfu/bin/arm64-v8a/runtime.properties

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/assets/bfu/bin/armeabi-v7a/gpgv
Binary file not shown.
Binary file removed app/src/main/assets/bfu/bin/armeabi-v7a/pkgdetails
Binary file not shown.
9 changes: 0 additions & 9 deletions app/src/main/assets/bfu/bin/armeabi-v7a/runtime.properties

This file was deleted.

Binary file not shown.
Binary file removed app/src/main/assets/bfu/bin/x86_64/dawnshell-codec
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/assets/bfu/bin/x86_64/dawnshell-fdguard
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/assets/bfu/bin/x86_64/gpgv
Binary file not shown.
Binary file removed app/src/main/assets/bfu/bin/x86_64/pkgdetails
Binary file not shown.
9 changes: 0 additions & 9 deletions app/src/main/assets/bfu/bin/x86_64/runtime.properties

This file was deleted.

5 changes: 3 additions & 2 deletions bfu-runtime/README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ ABI는 CPU에 맞는 네이티브 실행 파일 규칙입니다.
- 고정 소스와 SHA-256: `sources/SOURCES.lock`
- Android용 패치: `patches/`
- 최소 빌드 설정: `config/`
- 빌드 스크립트: `../scripts/build-bootstrap-runtime.sh`
- 빌드 태스크: `../buildSrc/` (`BfuRuntime.kt`가 등록)
- 서드파티 라이선스: [THIRD_PARTY_NOTICES.ko.md](THIRD_PARTY_NOTICES.ko.md)

일반 사용자는 이 디렉터리의 파일을 휴대전화에 직접 복사할 필요가 없습니다. 앱이
현재 ABI에 맞는 검증된 결과만 DE 저장소에 배치합니다. 소스를 바꿨다면 전체
`scripts/build-all.sh`를 실행해 세 ABI와 라이선스 검사를 함께 통과시키세요.
`./gradlew policyChecks :app:assembleDebug`를 실행해 세 ABI와 라이선스 검사를 함께
통과시키세요. 바이너리는 빌드할 때 생성되며 커밋하지 않습니다.

실제 기기의 키, PID(Process Identifier), 로그와 `authorized_keys`는 이 저장소에
커밋하지 않습니다. 앱의 DE(Device Encrypted) 저장소 또는 검토된 Debian
Expand Down
5 changes: 3 additions & 2 deletions bfu-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ installer preflight.
- Pinned sources and hashes: `sources/SOURCES.lock`
- Android patches: `patches/`
- Minimal build configuration: `config/`
- Build script: `../scripts/build-bootstrap-runtime.sh`
- Build tasks: `../buildSrc/` (`BfuRuntime.kt` registers them)
- Third-party licensing: [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)

Users do not copy these files to a phone manually. The app provisions only the
verified output matching the current ABI into DE storage. After any source
change, run `scripts/build-all.sh` so all ABI and license checks run together.
change, run `./gradlew policyChecks :app:assembleDebug` so all ABI and license checks run
together. The binaries are generated at build time and are not committed.

Never commit device keys, PIDs, logs, or `authorized_keys`. Runtime state belongs
only in app Device Encrypted storage or the reviewed Debian rootfs.
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package me.aroxu.dawnshell.gradle

import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction

/** Compiles one DawnShell-owned C program with the pinned NDK clang, strips it and validates the ELF. */
@CacheableTask
abstract class BfuCompileTask : BfuNativeTask() {
@get:InputFiles
@get:PathSensitive(PathSensitivity.NAME_ONLY)
abstract val sources: ConfigurableFileCollection

@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
abstract val headers: ConfigurableFileCollection

@get:Input
abstract val compilerArguments: ListProperty<String>

@get:Input
abstract val linkerArguments: ListProperty<String>

@get:Input
abstract val elfKind: Property<ElfKind>

@get:OutputFile
abstract val outputFile: RegularFileProperty

@TaskAction
fun compile() {
val tools = ndk
val output = outputFile.get().asFile
output.parentFile.mkdirs()
runner.run(
null,
*tools.clangArguments.toTypedArray(),
*compilerArguments.get().toTypedArray(),
*sources.files.map { it.path }.toTypedArray(),
*linkerArguments.get().toTypedArray(),
"-o", output.path,
)
runner.run(null, tools.strip.path, "--strip-unneeded", output.path)
makePrivateExecutable(output)
ElfValidator(runner, tools).validate(output, elfKind.get())
}
}
Loading