A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.
Bump to v1.0.9 with Pixel compatibility updates
ExTv782d61cd063d
diff --git a/Dockerfile.qemu b/Dockerfile.qemuindex 9498388..6d35437 100644--- a/Dockerfile.qemu+++ b/Dockerfile.qemu@@ -1,14 +1,21 @@# ─────────────────────────────────────────────────────────────────────────────-# Podroid — QEMU 11.0.0-rc2 Android ARM64 builder+# Podroid — QEMU 10.2.1 Android ARM64 builder## Produces:# libqemu-system-aarch64.so — QEMU executable (PIE, packaged as .so)-# libslirp.so — SLIRP user-mode networking library# efi-virtio.rom — VirtIO EFI ROM# keymaps/ — QEMU keymap files## Features enabled:-# TCG, KVM, QMP, SLIRP user networking, virtio-9p (virtfs) for Downloads sharing+# TCG, KVM, QMP, SLIRP user networking (bundled), virtio-9p (virtfs) for+# Downloads sharing+#+# QEMU version pinned to 10.2.1.+# Android 15+ on Pixel (Tensor) uses PAC (Pointer Authentication). QEMU's default+# sigaltstack coroutine backend calls siglongjmp across alternate signal stacks,+# which fails PAC validation and raises SIGILL (ESR PAC Exception).+# Fix: --with-coroutine=ucontext uses swapcontext instead of siglongjmp, which+# saves/restores the full register context correctly under PAC.# ─────────────────────────────────────────────────────────────────────────────FROM debian:bookworm AS builder@@ -51,9 +58,10 @@ ENV SYSROOT="${LLVM}/sysroot"ENV PREFIX=/opt/depsENV PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"-ENV CFLAGS="--sysroot=${SYSROOT} -target ${TARGET}${API} -I${PREFIX}/include -fPIC -O2 -Wno-implicit-function-declaration"-ENV CXXFLAGS="--sysroot=${SYSROOT} -target ${TARGET}${API} -I${PREFIX}/include -fPIC -O2"-ENV LDFLAGS="--sysroot=${SYSROOT} -target ${TARGET}${API} -L${PREFIX}/lib"+# -march=armv8-a: disables SVE/SVE2 JIT paths that trip up on Pixel 10 (Tensor G5, ARMv9.2)+ENV CFLAGS="--sysroot=${SYSROOT} -target ${TARGET}${API} -I${PREFIX}/include -fPIC -O2 -march=armv8-a -Wno-implicit-function-declaration"+ENV CXXFLAGS="--sysroot=${SYSROOT} -target ${TARGET}${API} -I${PREFIX}/include -fPIC -O2 -march=armv8-a"+ENV LDFLAGS="--sysroot=${SYSROOT} -target ${TARGET}${API} -L${PREFIX}/lib -Wl,-z,max-page-size=16384"RUN mkdir -p ${PREFIX}/{lib,include,lib/pkgconfig}@@ -85,19 +93,21 @@ c_args = ['--sysroot=/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroo'-I/opt/deps/include','-I/opt/deps/include/glib-2.0','-I/opt/deps/lib/glib-2.0/include',- '-fPIC', '-O2']+ '-fPIC', '-O2', '-march=armv8-a']cpp_args = ['--sysroot=/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot','-target', 'aarch64-linux-android34','-I/opt/deps/include','-I/opt/deps/include/glib-2.0','-I/opt/deps/lib/glib-2.0/include',- '-fPIC', '-O2']+ '-fPIC', '-O2', '-march=armv8-a']c_link_args = ['--sysroot=/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot','-target', 'aarch64-linux-android34',- '-L/opt/deps/lib']+ '-L/opt/deps/lib',+ '-Wl,-z,max-page-size=16384']cpp_link_args = ['--sysroot=/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot','-target', 'aarch64-linux-android34',- '-L/opt/deps/lib']+ '-L/opt/deps/lib',+ '-Wl,-z,max-page-size=16384'][host_machine]system = 'linux'@@ -172,52 +182,7 @@ RUN wget -q https://www.cairographics.org/releases/pixman-0.42.2.tar.gz \&& make -j$(nproc) install \&& cd / && rm -rf pixman-0.42.2*-# ── libslirp (shared — dynamic dep, matches how current binary links) ─────────-RUN wget -q https://gitlab.freedesktop.org/slirp/libslirp/-/archive/v4.8.0/libslirp-v4.8.0.tar.gz \- && tar xf libslirp-v4.8.0.tar.gz && cd libslirp-v4.8.0 \- && PKG_CONFIG_LIBDIR=${PKG_CONFIG_PATH} \- PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \- meson setup _build \- --cross-file /opt/cross-android-aarch64.ini \- --prefix ${PREFIX} \- --default-library shared \- --buildtype release \- && ninja -C _build -j$(nproc) && ninja -C _build install \- && cd / && rm -rf libslirp-v4.8.0* \- && patchelf --set-soname libslirp.so ${PREFIX}/lib/libslirp.so.0--# ── Android stubs ──────────────────────────────────────────────────────────────-# shm_open/shm_unlink are NOT exported by the NDK's libc stubs. QEMU's configure-# detects them via the header declaration and compiles qemu_shm_alloc() with-# shm_open() calls, then the linker fails with --no-undefined.-# Fix: implement shm_open/shm_unlink via memfd_create (bionic API 26+). QEMU's-# qemu_shm_alloc() creates a name, immediately shm_unlink()s it, then ftruncates-# the fd — the exact semantics memfd_create provides.-RUN cat > /tmp/shm_android.c << 'CEOF'-/*- * Android shim: shm_open/shm_unlink -> memfd_create- *- * shm_open/shm_unlink are not exported by NDK libc stubs. QEMU's- * qemu_shm_alloc() creates a named shm object, immediately shm_unlink()s it,- * then ftruncates the fd — exactly what memfd_create provides (API 26+).- */-#include <sys/syscall.h>-#include <sys/mman.h>-#include <sys/stat.h>-#include <unistd.h>-#ifndef MFD_CLOEXEC-#define MFD_CLOEXEC 0x0001U-#endif-int shm_open(const char *name, int oflag, mode_t mode) {- return (int)syscall(__NR_memfd_create, name ? name : "shm", MFD_CLOEXEC);-}-int shm_unlink(const char *name) { (void)name; return 0; }-CEOF-RUN ${CC} ${CFLAGS} -c /tmp/shm_android.c -o /tmp/shm_android.o \- && ${AR} rcs ${PREFIX}/lib/librt.a /tmp/shm_android.o--# ── libattr (xattr functions live in Android libc, but QEMU requires this lib) ─-# Build attr-2.5.2 from source (tiny library, ~30 seconds)+# ── libattr (static — xattr support for virtfs/9p) ───────────────────────────RUN wget -q https://download.savannah.gnu.org/releases/attr/attr-2.5.2.tar.gz \&& tar xf attr-2.5.2.tar.gz && cd attr-2.5.2 \&& ./configure \@@ -236,30 +201,106 @@ RUN wget -q https://download.savannah.gnu.org/releases/attr/attr-2.5.2.tar.gz \&& cp ${PREFIX}/lib/libattr.a \${SYSROOT}/usr/lib/aarch64-linux-android/34/libattr.a-# ── QEMU 11.0.0-rc2 ──────────────────────────────────────────────────────────-RUN wget -q https://download.qemu.org/qemu-11.0.0-rc2.tar.xz \- && tar xf qemu-11.0.0-rc2.tar.xz+# ── QEMU 10.2.1 ──────────────────────────────────────────────────────────────+RUN wget -q https://download.qemu.org/qemu-10.2.1.tar.xz \+ && tar xf qemu-10.2.1.tar.xz++# Patch 1 (VirtuDroid android-no-librt): make librt optional.+# Android Bionic does not have a separate librt; the functions are in libc.+RUN sed -i "s/rt = cc.find_library('rt', required: true)/rt = cc.find_library('rt', required: false)/" \+ qemu-10.2.1/meson.build++# Patch 2 (VirtuDroid android-no-shm-open): use memfd_create instead of shm_open on Android.+# shm_open is not exported by Android's NDK libc stubs; memfd_create (API 26+) gives+# the same anonymous-shared-memory semantics that qemu_shm_alloc() needs.+RUN python3 - << 'PYEOF'+import re, sys+path = 'qemu-10.2.1/util/oslib-posix.c'+src = open(path).read()+android_impl = r'''#ifdef __ANDROID__+#include <sys/syscall.h>+int qemu_shm_alloc(size_t size, Error **errp)+{+ int fd;++ fd = syscall(__NR_memfd_create, "qemu-shm", 0U);+ if (fd < 0) {+ error_setg_errno(errp, errno, "memfd_create failed");+ return -1;+ }+ if (ftruncate(fd, size) == -1) {+ error_setg_errno(errp, errno,+ "failed to resize shared memory to %zu", size);+ close(fd);+ return -1;+ }+ return fd;+}+#else+'''+target = 'int qemu_shm_alloc(size_t size, Error **errp)'+if android_impl.split('#else\n')[1].strip().startswith(target) and target in src:+ sys.exit(0) # already patched+idx = src.find(target)+if idx < 0:+ print("ERROR: qemu_shm_alloc not found in oslib-posix.c", file=sys.stderr)+ sys.exit(1)+# Find end of function — match closing brace at column 0+end_match = re.search(r'\n\}', src[idx:])+if not end_match:+ print("ERROR: could not find end of qemu_shm_alloc", file=sys.stderr)+ sys.exit(1)+end_pos = idx + end_match.end()+new_src = src[:idx] + android_impl + src[idx:end_pos] + '\n#endif /* __ANDROID__ */' + src[end_pos:]+open(path, 'w').write(new_src)+print("Patched oslib-posix.c with Android memfd_create shm implementation")+PYEOF++# Patch meson.build: declare libattr as a found dependency without pkg-config lookup.+# Android provides xattr functions in libc; virtfs/9p can use them without a+# separate libattr-devel. We override the dependency check to unblock configure.+RUN python3 - << 'PYEOF'+import re+path = 'qemu-10.2.1/meson.build'+src = open(path).read()++# QEMU 11.x pattern+new = src.replace(+ "libattr = not_found\nhave_old_libattr = false",+ "libattr = declare_dependency()\nhave_old_libattr = false"+)+if new != src:+ print("Patched libattr (11.x pattern)")+else:+ # QEMU 10.x: libattr detection via dependency()+ new, n = re.subn(+ r"(libattr\s*=\s*)dependency\('libattr'[^)]*\)",+ r"\1declare_dependency()",+ src+ )+ if n:+ print(f"Patched libattr (10.x pattern, {n} substitution(s))")+ else:+ print("WARNING: could not find libattr pattern in meson.build — virtfs may fail")-# Patch meson.build: force libattr find_library to use our cross-compiled prefix-# Android: xattr functions live in libc. Force libattr = declare_dependency()-# so QEMU compiles virtfs without needing an external -lattr.-RUN python3 -c "c=open('qemu-11.0.0-rc2/meson.build').read(); old='libattr = not_found\nhave_old_libattr = false'; new='libattr = declare_dependency()\nhave_old_libattr = false'; c2=c.replace(old,new,1); open('qemu-11.0.0-rc2/meson.build','w').write(c2); print('patched' if c!=c2 else 'ERROR:no change')"+open(path, 'w').write(new)+PYEOF-# Android sys/stat.h defines st_atime_nsec etc. as macros which break QEMU's-# 9p struct field declarations. Undefine them at the top of the header.+# Android sys/stat.h defines st_atime_nsec etc. as macros which clash with+# QEMU's 9p struct field declarations. Undefine them before the header.RUN printf '#undef st_atime_nsec\n#undef st_mtime_nsec\n#undef st_ctime_nsec\n' \- | cat - qemu-11.0.0-rc2/fsdev/9p-marshal.h > /tmp/9p-marshal.h \- && mv /tmp/9p-marshal.h qemu-11.0.0-rc2/fsdev/9p-marshal.h+ | cat - qemu-10.2.1/fsdev/9p-marshal.h > /tmp/9p-marshal.h \+ && mv /tmp/9p-marshal.h qemu-10.2.1/fsdev/9p-marshal.h-RUN cd qemu-11.0.0-rc2 \+RUN cd qemu-10.2.1 \&& PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \./configure \--cc="${CC}" \--cxx="${CXX}" \--host-cc="gcc" \--cross-prefix="${LLVM}/bin/llvm-" \- --extra-cflags="${CFLAGS} -Wno-error=implicit-function-declaration -UCONFIG_POSIX_SHM" \- --extra-ldflags="${LDFLAGS} -L${SYSROOT}/usr/lib/aarch64-linux-android/${API} -Wl,-rpath-link,${PREFIX}/lib" \+ --extra-cflags="-fPIC -DANDROID -march=armv8-a -I${PREFIX}/include -I${PREFIX}/include/glib-2.0 -I${PREFIX}/lib/glib-2.0/include -Wno-error=implicit-function-declaration" \+ --extra-ldflags="-L${PREFIX}/lib -L${SYSROOT}/usr/lib/aarch64-linux-android/${API} -Wl,-rpath-link,${PREFIX}/lib -Wl,-z,max-page-size=16384" \--prefix=/opt/qemu-out \--target-list=aarch64-softmmu \--without-default-features \@@ -269,14 +310,13 @@ RUN cd qemu-11.0.0-rc2 \--enable-slirp \--enable-virtfs \--enable-pie \+ --disable-werror \--disable-docs \--disable-gtk \--disable-sdl \--disable-opengl \--disable-vnc \--disable-capstone \- --disable-bpf \- --disable-cap-ng \--disable-seccomp \--disable-libiscsi \--disable-libnfs \@@ -285,18 +325,28 @@ RUN cd qemu-11.0.0-rc2 \--disable-spice \--disable-vde \--disable-linux-io-uring \+ --with-coroutine=ucontext \&& make -j$(nproc) \&& make install-# ── Rename binary to .so for Android packaging ────────────────────────────────+# ── Rename binary to .so; fix libslirp soname for Android APK packaging ───────+# Android APK packaging only extracts files matching lib*.so (no version suffix).+# QEMU was compiled with libslirp.so.0 as the soname. We rename the library to+# libslirp.so, update its soname, and update QEMU's NEEDED entry to match.RUN cp /opt/qemu-out/bin/qemu-system-aarch64 \/opt/qemu-out/libqemu-system-aarch64.so \+ && cp /opt/qemu-out/lib/libslirp.so.0 \+ /opt/qemu-out/libslirp.so \+ && patchelf --set-soname libslirp.so /opt/qemu-out/libslirp.so \+ && patchelf --replace-needed libslirp.so.0 libslirp.so \+ /opt/qemu-out/libqemu-system-aarch64.so \&& ${STRIP} /opt/qemu-out/libqemu-system-aarch64.so \- && cp ${PREFIX}/lib/libslirp.so.0 /opt/qemu-out/libslirp.so \&& ${STRIP} /opt/qemu-out/libslirp.so# ── Final image with just the artifacts ───────────────────────────────────────FROM debian:bookworm-slim AS artifacts+RUN apt-get update && apt-get install -y --no-install-recommends patchelf && rm -rf /var/lib/apt/lists/*+RUN mkdir -p /out/qemu/keymapsCOPY --from=builder /opt/qemu-out/libqemu-system-aarch64.so /out/COPY --from=builder /opt/qemu-out/libslirp.so /out/COPY --from=builder /opt/qemu-out/share/qemu/efi-virtio.rom /out/qemu/diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex bc2ea86..cdd39f8 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -23,8 +23,8 @@ android {applicationId = "com.excp.podroid"minSdk = 26targetSdk = 36- versionCode = 11- versionName = "1.0.8"+ versionCode = 12+ versionName = "1.0.9"testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"@@ -80,6 +80,9 @@ android {// It must be extracted to disk so ProcessBuilder can execute it.jniLibs {useLegacyPackaging = true+ // libtermux.so is rebuilt locally with 16KB page alignment (see build-termux-android.sh).+ // pickFirsts makes Gradle prefer src/main/jniLibs/ over the copy inside the Termux AAR.+ pickFirsts += "lib/arm64-v8a/libtermux.so"}}}diff --git a/app/src/main/jniLibs/arm64-v8a/libqemu-system-aarch64.so b/app/src/main/jniLibs/arm64-v8a/libqemu-system-aarch64.soindex f99039d..eeae199 100755Binary files a/app/src/main/jniLibs/arm64-v8a/libqemu-system-aarch64.so and b/app/src/main/jniLibs/arm64-v8a/libqemu-system-aarch64.so differdiff --git a/app/src/main/jniLibs/arm64-v8a/libslirp.so b/app/src/main/jniLibs/arm64-v8a/libslirp.soindex a50a17e..ea99cdf 100755Binary files a/app/src/main/jniLibs/arm64-v8a/libslirp.so and b/app/src/main/jniLibs/arm64-v8a/libslirp.so differdiff --git a/app/src/main/jniLibs/arm64-v8a/libtermux.so b/app/src/main/jniLibs/arm64-v8a/libtermux.sonew file mode 100755index 0000000..44ef735Binary files /dev/null and b/app/src/main/jniLibs/arm64-v8a/libtermux.so differdiff --git a/build-qemu-android.sh b/build-qemu-android.shindex a818798..62546c5 100755--- a/build-qemu-android.sh+++ b/build-qemu-android.sh@@ -1,7 +1,7 @@#!/bin/bash# ─────────────────────────────────────────────────────────────────────────────# build-qemu-android.sh-# Builds QEMU 11.0.0-rc2 for Android ARM64 with virtfs support.+# Builds QEMU 10.2.1 for Android ARM64 with virtfs support.# Replaces app/src/main/jniLibs/arm64-v8a/libqemu-system-aarch64.so# ─────────────────────────────────────────────────────────────────────────────set -euo pipefail@@ -10,7 +10,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"IMAGE="podroid-qemu-builder"CONTAINER="podroid-qemu-extract"-echo "=== [1/4] Building QEMU 11.0.0-rc2 for Android ARM64 ==="+echo "=== [1/4] Building QEMU 10.2.1 for Android ARM64 ==="echo " This will take 20-40 minutes on first run."echo ""diff --git a/build-termux-android.sh b/build-termux-android.shnew file mode 100755index 0000000..75d1a2f--- /dev/null+++ b/build-termux-android.sh@@ -0,0 +1,100 @@+#!/bin/bash+# ─────────────────────────────────────────────────────────────────────────────+# build-termux-android.sh+# Rebuilds libtermux.so from Termux v0.118.1 source with 16KB page alignment.+# Replaces app/src/main/jniLibs/arm64-v8a/libtermux.so+#+# Required: Android NDK (auto-detected via $ANDROID_HOME or ~/Android/Sdk)+# ─────────────────────────────────────────────────────────────────────────────+set -euo pipefail++SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+TERMUX_TAG="v0.118.1"+TERMUX_REPO="https://github.com/termux/termux-app.git"+BUILD_DIR="/tmp/termux-jni-build"+OUT_DIR="${SCRIPT_DIR}/app/src/main/jniLibs/arm64-v8a"++# ── Locate NDK ────────────────────────────────────────────────────────────────+if [ -n "${ANDROID_NDK_ROOT:-}" ] && [ -d "$ANDROID_NDK_ROOT" ]; then+ NDK="$ANDROID_NDK_ROOT"+elif [ -n "${ANDROID_HOME:-}" ] && [ -d "${ANDROID_HOME}/ndk" ]; then+ NDK=$(ls -d "${ANDROID_HOME}/ndk/"* 2>/dev/null | sort -V | tail -1)+elif [ -d "$HOME/Android/Sdk/ndk" ]; then+ NDK=$(ls -d "$HOME/Android/Sdk/ndk/"* 2>/dev/null | sort -V | tail -1)+else+ echo "ERROR: Could not find Android NDK. Set ANDROID_NDK_ROOT or ANDROID_HOME." >&2+ exit 1+fi+echo "=== Using NDK: $NDK"++LLVM="$NDK/toolchains/llvm/prebuilt/linux-x86_64"+CC="$LLVM/bin/aarch64-linux-android26-clang"+if [ ! -f "$CC" ]; then+ echo "ERROR: NDK clang not found at $CC" >&2+ exit 1+fi++# ── Clone Termux source ───────────────────────────────────────────────────────+echo ""+echo "=== [1/3] Fetching Termux $TERMUX_TAG source ==="++rm -rf "$BUILD_DIR"+git clone --depth=1 --branch "$TERMUX_TAG" "$TERMUX_REPO" "$BUILD_DIR"++JNI_DIR="$BUILD_DIR/terminal-emulator/src/main/jni"+if [ ! -f "$JNI_DIR/termux.c" ]; then+ echo "ERROR: Expected JNI source at $JNI_DIR/termux.c — repo structure may have changed." >&2+ exit 1+fi++# ── Compile directly with NDK clang ──────────────────────────────────────────+echo ""+echo "=== [2/3] Building libtermux.so with 16KB page alignment ==="++SYSROOT="$LLVM/sysroot"++"$CC" \+ --sysroot="$SYSROOT" \+ -O2 \+ -fPIC \+ -fvisibility=hidden \+ -shared \+ -o "$BUILD_DIR/libtermux.so" \+ "$JNI_DIR/termux.c" \+ -Wl,-soname,libtermux.so \+ -Wl,-z,max-page-size=16384 \+ -llog \+ -landroid++# ── Verify and install ────────────────────────────────────────────────────────+echo ""+echo "=== [3/3] Verifying and installing ==="++python3 - "$BUILD_DIR/libtermux.so" << 'EOF'+import struct, sys+path = sys.argv[1]+with open(path, 'rb') as f:+ data = f.read()+e_phoff = struct.unpack_from('<Q', data, 32)[0]+e_phentsize = struct.unpack_from('<H', data, 54)[0]+e_phnum = struct.unpack_from('<H', data, 56)[0]+aligns = []+for i in range(e_phnum):+ off = e_phoff + i * e_phentsize+ if struct.unpack_from('<I', data, off)[0] == 1:+ aligns.append(struct.unpack_from('<Q', data, off + 48)[0])+ok = all(a >= 16384 for a in aligns)+print(f" Alignment check: {'PASS' if ok else 'FAIL'} LOAD aligns={[hex(a) for a in aligns]}")+if not ok:+ sys.exit(1)+EOF++mkdir -p "$OUT_DIR"+cp "$BUILD_DIR/libtermux.so" "$OUT_DIR/libtermux.so"++SIZE=$(du -sh "$OUT_DIR/libtermux.so" | cut -f1)+echo " Size: $SIZE"+echo " libtermux.so → $OUT_DIR/"+echo ""+echo "=== Done! Now run: ./gradlew assembleDebug"+echo ""diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex c29487b..d4268a9 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -10,7 +10,7 @@ lifecycleRuntimeKtx = "2.9.0"lifecycleViewmodelCompose = "2.9.0"# Compose-composeBom = "2025.05.00"+composeBom = "2026.03.01"# NavigationnavCompose = "2.9.7"@@ -26,7 +26,7 @@ hiltNavCompose = "1.3.0"coroutines = "1.9.0"# DataStore-datastore = "1.1.4"+datastore = "1.2.1"# Termux terminaltermux = "v0.118.1"diff --git a/test-deploy.sh b/test-deploy.shnew file mode 100755index 0000000..8360da6--- /dev/null+++ b/test-deploy.sh@@ -0,0 +1,155 @@+#!/bin/bash+# Podroid automated build → install → reset → boot test+# Usage: ./test-deploy.sh [--rebuild-initramfs]+set -e++PKG="com.excp.podroid.debug"+ACTIVITY="com.excp.podroid.MainActivity"+LOG_CMD="run-as $PKG cat files/console.log"+BOOT_TIMEOUT=60+SETTLE_TIME=5++RED='\033[0;31m'+GREEN='\033[0;32m'+YELLOW='\033[0;33m'+CYAN='\033[0;36m'+NC='\033[0m'++log() { echo -e "${CYAN}[$(date +%H:%M:%S)]${NC} $1"; }+ok() { echo -e "${GREEN}[OK]${NC} $1"; }+warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }+fail() { echo -e "${RED}[FAIL]${NC} $1"; }++# ── Step 0: Check ADB ──+if ! adb devices 2>/dev/null | grep -q 'device$'; then+ fail "No device connected via ADB"+ exit 1+fi+ok "Device connected"++# ── Step 1: Rebuild initramfs (optional) ──+if [ "$1" = "--rebuild-initramfs" ] || [ "$1" = "-r" ]; then+ log "Rebuilding initramfs..."+ ./docker-build-initramfs.sh 2>&1 | tail -3+ ok "Initramfs rebuilt"+fi++# ── Step 2: Build APK ──+log "Building debug APK..."+./gradlew assembleDebug 2>&1 | tail -3+ok "APK built"++# ── Step 3: Install ──+log "Installing APK..."+adb install -r app/build/outputs/apk/debug/app-debug.apk 2>&1+ok "APK installed"++# ── Step 4: Force stop app (clean state) ──+log "Stopping app..."+adb shell am force-stop "$PKG" 2>/dev/null || true+sleep 1++# ── Step 5: Reset VM (delete storage.img) ──+log "Resetting VM storage..."+adb shell run-as "$PKG" rm -f files/storage.img 2>/dev/null || true+adb shell run-as "$PKG" rm -f files/console.log 2>/dev/null || true+ok "VM reset"++# ── Step 6: Launch app ──+log "Launching app..."+adb shell am start -n "$PKG/$ACTIVITY" >/dev/null 2>&1+sleep 2+ok "App launched"++# ── Step 7: Wait for user to start VM ──+echo ""+echo -e "${YELLOW}>>> Press 'Start Podman' in the app, then press Enter here <<<${NC}"+read -r+echo ""++# ── Step 8: Wait for boot ──+log "Waiting for VM to boot (timeout: ${BOOT_TIMEOUT}s)..."+BOOT_OK=false+for i in $(seq 1 "$BOOT_TIMEOUT"); do+ CONSOLE=$(adb shell run-as "$PKG" cat files/console.log 2>/dev/null || echo "")+ if echo "$CONSOLE" | grep -q "Ready!"; then+ BOOT_OK=true+ break+ fi+ if echo "$CONSOLE" | grep -q "Internet:"; then+ BOOT_OK=true+ break+ fi+ printf "."+ sleep 1+done+echo ""++if [ "$BOOT_OK" = true ]; then+ ok "VM booted successfully"+else+ fail "VM failed to boot within ${BOOT_TIMEOUT}s"+ echo ""+ echo "=== Console log ==="+ adb shell run-as "$PKG" cat files/console.log 2>/dev/null | tail -20+ exit 1+fi++# ── Step 9: Let VM settle ──+log "Letting VM settle for ${SETTLE_TIME}s..."+sleep "$SETTLE_TIME"++# ── Step 10: Show console log ──+echo ""+echo "════════════════════════════════════════"+echo " Console Output"+echo "════════════════════════════════════════"+adb shell run-as "$PKG" cat files/console.log 2>/dev/null+echo ""+echo "════════════════════════════════════════"++# ── Step 11: Verify boot output ──+CONSOLE=$(adb shell run-as "$PKG" cat files/console.log 2>/dev/null || echo "")+ERRORS=0++check() {+ if echo "$CONSOLE" | grep -q "$1"; then+ ok "$2"+ else+ fail "$2"+ ERRORS=$((ERRORS + 1))+ fi+}++echo ""+echo "=== Boot Checks ==="+check "Podroid - Alpine Linux" "Banner displayed"+check "IP:" "IP address shown"+check "Persistent: yes" "Persistent storage active"+check "Internet:" "Internet check ran"+check "Ready!" "Boot completed"+check "Loading kernel modules" "Kernel modules loaded"+check "Found:" "Network interface found"++# Check for errors+if echo "$CONSOLE" | grep -qi "panic\|oops\|segfault"; then+ fail "Kernel panic or crash detected!"+ ERRORS=$((ERRORS + 1))+fi++echo ""+if [ "$ERRORS" -eq 0 ]; then+ ok "All checks passed!"+ echo ""+ echo "VM is running. Open the terminal in the app to test:"+ echo " - Press SYNC to set terminal size"+ echo " - apk add neovim btop"+ echo " - nvim"+ echo " - btop"+else+ fail "$ERRORS check(s) failed"+fi++echo ""+echo "To view live log: adb shell run-as $PKG cat files/console.log"+echo "To take screenshot: adb exec-out screencap -p > screenshot.png"