From 21a3cb1ec052d888f8efe67c0481ee2c47df370c Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Fri, 20 Mar 2026 06:58:10 +0100 Subject: [PATCH] fix(build): restore customize.sh and build.gradle.kts with all native libs PR 157 wholesale replacement dropped libsupervisor.so and libcertgen.so from both the ZIP include filter and the customize.sh extraction. service.sh calls ./supervisor and App.kt loads libcertgen.so, so the module would fail on install. Restores our versions with the Rust build task, 4-lib include filter, and supervisor/certgen extraction. Adopts PR 157's nativeLibsDir simplification (always use stripped libs). --- app/build.gradle.kts | 39 ++++++++++++++++++++++++++++++++++----- module/customize.sh | 9 ++++++--- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cce73d4..f1686ab 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -71,6 +71,35 @@ dependencies { implementation(libs.bcpkix) } +// --- Rust native cert gen build task --- +val buildRustCertgen by tasks.registering(Exec::class) { + group = "TEESimulator-RS Native Build" + description = "Builds libcertgen.so via cargo-ndk for arm64-v8a." + + workingDir = rootProject.projectDir.resolve("native-certgen") + + commandLine( + "cargo", "ndk", + "-t", "arm64-v8a", + "-o", rootProject.projectDir.resolve("app/src/main/jniLibs").absolutePath, + "build", "--release" + ) + + inputs.dir(rootProject.projectDir.resolve("native-certgen/src")) + inputs.file(rootProject.projectDir.resolve("native-certgen/Cargo.toml")) + inputs.file(rootProject.projectDir.resolve("native-certgen/Cargo.lock")) + outputs.dir(rootProject.projectDir.resolve("app/src/main/jniLibs")) + + environment("ANDROID_NDK_HOME", android.ndkDirectory.absolutePath) +} + +// AGP auto-detects jniLibs/ as an input to mergeJniLibFolders — wire the dependency +tasks.configureEach { + if (name.endsWith("JniLibFolders") && name.startsWith("merge")) { + dependsOn(buildRustCertgen) + } +} + androidComponents { onVariants(selector().all()) { variant -> val capitalized = variant.name.replaceFirstChar { it.uppercase() } @@ -79,7 +108,7 @@ androidComponents { // --- Define output locations and file names --- // Stage all files in a temporary directory inside 'build' before zipping val tempModuleDir = project.layout.buildDirectory.dir("module/${variant.name}") - val zipFileName = "TEESimulator-RS-$verName-$gitCommitCount-$gitCommitHash-$capitalized.zip" + val zipFileName = "TEESimulator-RS-$verName-$gitCommitCount-$capitalized.zip" // Task 1: Prepare all module files in the temporary build directory. // Using Sync ensures that stale files from previous runs are removed. @@ -94,6 +123,7 @@ androidComponents { dependsOn("minify${capitalized}WithR8") } dependsOn("strip${capitalized}DebugSymbols") + dependsOn(buildRustCertgen) if (isDebug) { from(variant.artifacts.get(SingleArtifact.APK)) { @@ -115,8 +145,8 @@ androidComponents { "intermediates/stripped_native_libs/${variant.name}/strip${capitalized}DebugSymbols/out/lib" ) ) { - into("lib") // Place them in the 'lib' subfolder of the staging directory. - include("**/libinject.so", "**/libTEESimulator.so") + into("lib") + include("**/libinject.so", "**/libTEESimulator.so", "**/libsupervisor.so", "**/libcertgen.so") } // Now, copy and process the files from 'module' directory. @@ -131,8 +161,7 @@ androidComponents { // Use expand() for simple key-value replacement. expand( "REPLACEMEVERCODE" to gitCommitCount.toString(), - "REPLACEMEVER" to - "$verName ($gitCommitCount-$gitCommitHash-${variant.name})", + "REPLACEMEVER" to "$verName-$gitCommitCount", ) } diff --git a/module/customize.sh b/module/customize.sh index 7d6d62f..a4ce5a5 100644 --- a/module/customize.sh +++ b/module/customize.sh @@ -15,7 +15,7 @@ fi # --- Version Info --- VERSION=$(grep_prop version "${TMPDIR}/module.prop") -ui_print "- Installing TEESimulator $VERSION" +ui_print "- Installing TEESimulator-RS $VERSION" ui_print "" # --- Architecture Handling --- @@ -48,7 +48,7 @@ install_file() { # --- Installation --- ui_print "- Extracting module files" -for file in customize.sh module.prop service.sh sepolicy.rule daemon; do +for file in customize.sh module.prop service.sh sepolicy.rule daemon action.sh uninstall.sh; do install_file "$file" "$MODPATH" done @@ -67,10 +67,14 @@ ui_print "" ui_print "- Extracting $ARCH libraries" install_file "lib/$ABI_DIR/libTEESimulator.so" "$MODPATH" install_file "lib/$ABI_DIR/libinject.so" "$MODPATH" +install_file "lib/$ABI_DIR/libsupervisor.so" "$MODPATH" +install_file "lib/$ABI_DIR/libcertgen.so" "$MODPATH" ui_print "" mv "$MODPATH/libinject.so" "$MODPATH/inject" +mv "$MODPATH/libsupervisor.so" "$MODPATH/supervisor" chmod 755 "$MODPATH/inject" +chmod 755 "$MODPATH/supervisor" # --- Configuration Files --- if [ ! -d "$CONFIG_DIR" ]; then @@ -88,7 +92,6 @@ if [ ! -f "$CONFIG_DIR/target.txt" ]; then install_file "target.txt" "$CONFIG_DIR" fi -# Remove legacy TEE status file; TEE status is now determined at runtime. rm -f "$CONFIG_DIR/tee_status.txt" if [ ! -f "$CONFIG_DIR/hbk" ]; then