A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.
build: remove deprecated individual build scripts in favor of unified build-all.sh
ExTv7c88ce06a110
diff --git a/Dockerfile.qemu b/Dockerfile.qemudeleted file mode 100644index ac790f9..0000000--- a/Dockerfile.qemu+++ /dev/null@@ -1,404 +0,0 @@-# ─────────────────────────────────────────────────────────────────────────────-# Podroid — QEMU 11.0.0-rc2 Android ARM64 builder-#-# Produces:-# libqemu-system-aarch64.so — QEMU executable (PIE, packaged as .so)-# efi-virtio.rom — VirtIO EFI ROM-# keymaps/ — QEMU keymap files-#-# Features enabled:-# TCG, KVM, QMP, SLIRP user networking (bundled), virtio-9p (virtfs) for-# Downloads sharing-#-# QEMU version pinned via build arg.-# 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--ARG QEMU_VERSION=11.0.0-rc2-ENV QEMU_VERSION=${QEMU_VERSION}-ENV QEMU_DIR=qemu-${QEMU_VERSION}--ENV DEBIAN_FRONTEND=noninteractive--RUN apt-get update && apt-get install -y --no-install-recommends \- wget curl unzip xz-utils ca-certificates git bzip2 \- ninja-build python3 python3-pip \- pkg-config flex bison \- make cmake autoconf automake libtool \- libglib2.0-dev libglib2.0-bin \- gettext libintl-perl \- binutils-aarch64-linux-gnu \- patchelf \- && rm -rf /var/lib/apt/lists/*--# Meson — use pip to get a recent version regardless of distro-RUN pip3 install --break-system-packages meson 2>/dev/null || pip3 install meson--# ── Android NDK r27c ──────────────────────────────────────────────────────────-ENV NDK_VER=r27c-RUN wget -q https://dl.google.com/android/repository/android-ndk-${NDK_VER}-linux.zip \- -O /tmp/ndk.zip \- && unzip -q /tmp/ndk.zip -d /opt \- && mv /opt/android-ndk-${NDK_VER} /opt/ndk \- && rm /tmp/ndk.zip--ENV NDK=/opt/ndk-ENV API=28-ENV TARGET=aarch64-linux-android-ENV LLVM=${NDK}/toolchains/llvm/prebuilt/linux-x86_64-ENV CC="${LLVM}/bin/${TARGET}${API}-clang"-ENV CXX="${LLVM}/bin/${TARGET}${API}-clang++"-ENV AR="${LLVM}/bin/llvm-ar"-ENV RANLIB="${LLVM}/bin/llvm-ranlib"-ENV STRIP="${LLVM}/bin/llvm-strip"-ENV NM="${LLVM}/bin/llvm-nm"-ENV SYSROOT="${LLVM}/sysroot"--ENV PREFIX=/opt/deps-ENV PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"-# -DHAVE_COPY_FILE_RANGE=0: Force QEMU to use its fallback copy_file_range stub-# instead of relying on the host C library. The stub uses syscall() directly,-# which works on older kernels (Android 12) as long as the syscall number exists.-# -U__NR_copy_file_range: Undefine the syscall check so the fallback is used-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}--# ── pkg-config wrapper for cross target ───────────────────────────────────────-# Meson cross builds need a dedicated pkg-config that only looks in our prefix.-# QEMU configure sets cross-prefix=llvm- so meson looks for llvm-pkg-config.-RUN printf '#!/bin/sh\nexport PKG_CONFIG_LIBDIR=/opt/deps/lib/pkgconfig\nexport PKG_CONFIG_PATH=\nexec pkg-config "$@"\n' \- > /usr/local/bin/aarch64-android-pkg-config \- && chmod +x /usr/local/bin/aarch64-android-pkg-config \- && ln -s /usr/local/bin/aarch64-android-pkg-config \- /opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-pkg-config--# ── Meson cross file ──────────────────────────────────────────────────────────-RUN cat > /opt/cross-android-aarch64.ini << 'EOF'-[binaries]-c = '/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang'-cpp = '/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++'-ar = '/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'-strip = '/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'-ranlib = '/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib'-nm = '/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-nm'-pkg-config = '/usr/local/bin/aarch64-android-pkg-config'--[properties]-sys_root = '/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot'-pkg_config_libdir = ['/opt/deps/lib/pkgconfig']-c_args = ['--sysroot=/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot',- '-target', 'aarch64-linux-android28',- '-I/opt/deps/include',- '-I/opt/deps/include/glib-2.0',- '-I/opt/deps/lib/glib-2.0/include',- '-fPIC', '-O2', '-march=armv8-a']-cpp_args = ['--sysroot=/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot',- '-target', 'aarch64-linux-android28',- '-I/opt/deps/include',- '-I/opt/deps/include/glib-2.0',- '-I/opt/deps/lib/glib-2.0/include',- '-fPIC', '-O2', '-march=armv8-a']-c_link_args = ['--sysroot=/opt/ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot',- '-target', 'aarch64-linux-android28',- '-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-android28',- '-L/opt/deps/lib',- '-Wl,-z,max-page-size=16384']--[host_machine]-system = 'linux'-cpu_family = 'aarch64'-cpu = 'aarch64'-endian = 'little'-EOF--# ── pcre2 (static — required by glib) ────────────────────────────────────────-RUN wget -q https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.44/pcre2-10.44.tar.gz \- && tar xf pcre2-10.44.tar.gz && cd pcre2-10.44 \- && ./configure \- --host=${TARGET} \- --prefix=${PREFIX} \- --enable-static \- --disable-shared \- --disable-pcre2grep-libz \- --disable-pcre2grep-libbz2 \- --disable-pcre2test-libreadline \- CC="${CC}" CFLAGS="${CFLAGS}" AR="${AR}" RANLIB="${RANLIB}" \- && make -j$(nproc) install \- && cd / && rm -rf pcre2-10.44*--# ── libffi (static — required by glib for GObject) ───────────────────────────-RUN wget -q https://github.com/libffi/libffi/releases/download/v3.4.6/libffi-3.4.6.tar.gz \- && tar xf libffi-3.4.6.tar.gz && cd libffi-3.4.6 \- && ./configure \- --host=${TARGET} \- --prefix=${PREFIX} \- --enable-static \- --disable-shared \- --disable-docs \- CC="${CC}" CFLAGS="${CFLAGS}" AR="${AR}" RANLIB="${RANLIB}" \- && make -j$(nproc) install \- && cd / && rm -rf libffi-3.4.6*--# ── glib (static — core QEMU dependency) ─────────────────────────────────────-RUN wget -q https://download.gnome.org/sources/glib/2.82/glib-2.82.5.tar.xz \- && tar xf glib-2.82.5.tar.xz && cd glib-2.82.5 \- && PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \- meson setup _build \- --cross-file /opt/cross-android-aarch64.ini \- --prefix ${PREFIX} \- --default-library static \- --buildtype release \- -Dselinux=disabled \- -Dlibmount=disabled \- -Dxattr=false \- -Dtests=false \- -Ddocumentation=false \- -Dman-pages=disabled \- -Dintrospection=disabled \- -Dnls=disabled \- && ninja -C _build -j$(nproc) && ninja -C _build install \- && cd / && rm -rf glib-2.82.5*--# ── pixman (static — required by QEMU even with -display none) ───────────────-# Newer pixman releases are meson-only. Disable aarch64 NEON asm for Android-# cross-builds; cairo's own CI carries the same workaround.-RUN wget -q https://cairographics.org/releases/pixman-0.44.2.tar.xz \- && tar xf pixman-0.44.2.tar.xz && cd pixman-0.44.2 \- && 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 static \- --buildtype release \- -Dtests=disabled \- -Dgtk=disabled \- -Dlibpng=disabled \- -Dopenmp=disabled \- -Da64-neon=disabled \- && ninja -C _build -j$(nproc) \- && ninja -C _build install \- && cd / && rm -rf pixman-0.44.2*--# ── 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 \- --host=${TARGET} \- --prefix=${PREFIX} \- --enable-static \- --disable-shared \- --disable-nls \- CC="${CC}" CFLAGS="${CFLAGS}" AR="${AR}" RANLIB="${RANLIB}" \- && make -j$(nproc) install \- && cd / && rm -rf attr-2.5.2* \- && cp ${PREFIX}/lib/libattr.a \- ${SYSROOT}/usr/lib/aarch64-linux-android/libattr.a \- && ln -sf ${PREFIX}/lib/pkgconfig/libattr.pc \- ${PREFIX}/lib/pkgconfig/attr.pc \- && cp ${PREFIX}/lib/libattr.a \- ${SYSROOT}/usr/lib/aarch64-linux-android/${API}/libattr.a--# ── libucontext (static — provides getcontext/swapcontext on Android) ────────-RUN git clone --depth=1 https://github.com/kaniini/libucontext.git /tmp/libucontext \- && make -C /tmp/libucontext \- ARCH=aarch64 \- CC="${CC}" \- AR="${AR}" \- RANLIB="${RANLIB}" \- CFLAGS="${CFLAGS}" \- LDFLAGS="${LDFLAGS}" \- BUILD_POSIX=no \- FREESTANDING=no \- EXPORT_UNPREFIXED=yes \- && install -Dm644 /tmp/libucontext/libucontext.a ${PREFIX}/lib/libucontext.a \- && install -Dm644 /tmp/libucontext/include/libucontext/libucontext.h ${PREFIX}/include/libucontext/libucontext.h \- && install -Dm644 /tmp/libucontext/arch/common/include/libucontext/bits.h ${PREFIX}/include/libucontext/bits.h \- && printf '%s\n' \- '#ifndef PODROID_UCONTEXT_SHIM_H' \- '#define PODROID_UCONTEXT_SHIM_H' \- '#include_next <ucontext.h>' \- '#include <libucontext/libucontext.h>' \- '#define getcontext libucontext_getcontext' \- '#define makecontext libucontext_makecontext' \- '#define setcontext libucontext_setcontext' \- '#define swapcontext libucontext_swapcontext' \- '#endif' \- > ${PREFIX}/include/ucontext.h \- && rm -rf /tmp/libucontext--# ── QEMU ─────────────────────────────────────────────────────────────────────-RUN wget -q https://download.qemu.org/${QEMU_DIR}.tar.xz \- && tar xf ${QEMU_DIR}.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_DIR}/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-import os-path = os.path.join(os.environ['QEMU_DIR'], '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-import os-path = os.path.join(os.environ['QEMU_DIR'], '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")--open(path, 'w').write(new)-PYEOF--# 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_DIR}/fsdev/9p-marshal.h > /tmp/9p-marshal.h \- && mv /tmp/9p-marshal.h ${QEMU_DIR}/fsdev/9p-marshal.h--RUN cd ${QEMU_DIR} \- && PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \- ./configure \- --cc="${CC}" \- --cxx="${CXX}" \- --host-cc="gcc" \- --cross-prefix="${LLVM}/bin/llvm-" \- --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}/lib/libucontext.a" \- --prefix=/opt/qemu-out \- --target-list=aarch64-softmmu \- --without-default-features \- --enable-tcg \- --enable-kvm \- --enable-system \- --enable-slirp \- --enable-virtfs \- --enable-pie \- --disable-werror \- --disable-docs \- --disable-gtk \- --disable-sdl \- --disable-opengl \- --disable-vnc \- --disable-capstone \- --disable-seccomp \- --disable-libiscsi \- --disable-libnfs \- --disable-libssh \- --disable-curl \- --disable-spice \- --disable-vde \- --disable-linux-io-uring \- --with-coroutine=ucontext \- && python3 -c "import json, pathlib; p = pathlib.Path('build/meson-info/intro-buildoptions.json'); opts = {e['name']: e.get('value') for e in json.loads(p.read_text())}; assert p.exists(), p; assert opts.get('virtfs') == 'enabled', opts.get('virtfs'); assert opts.get('slirp') == 'enabled', opts.get('slirp'); assert opts.get('coroutine_backend') == 'ucontext', opts.get('coroutine_backend')" \- && make -j$(nproc) \- && find build -path '*coroutine-ucontext*.o' -print -quit | grep -q . \- && ! find build -path '*coroutine-sigaltstack*.o' -print -quit | grep -q . \- && make install--# ── podroid-bridge — serial socket ↔ PTY relay with SIGWINCH→RESIZE ──────────-# Compiled as a PIE executable, renamed to .so so Android extracts it from APK.-COPY podroid-bridge.c /tmp/podroid-bridge.c-RUN ${CC} ${CFLAGS} -fPIE -pie \- ${LDFLAGS} \- /tmp/podroid-bridge.c \- -o /opt/qemu-out/podroid-bridge \- && cp /opt/qemu-out/podroid-bridge /opt/qemu-out/libpodroid-bridge.so--# ── 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--# ── 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/keymaps-COPY --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/libpodroid-bridge.so /out/-COPY --from=builder /opt/qemu-out/share/qemu/efi-virtio.rom /out/qemu/-COPY --from=builder /opt/qemu-out/share/qemu/keymaps/ /out/qemu/keymaps/diff --git a/build-qemu-android.sh b/build-qemu-android.shdeleted file mode 100755index 0eeab18..0000000--- a/build-qemu-android.sh+++ /dev/null@@ -1,107 +0,0 @@-#!/bin/bash-# ─────────────────────────────────────────────────────────────────────────────-# build-qemu-android.sh-# Builds the configured QEMU version for Android ARM64 with virtfs support.-# Replaces app/src/main/jniLibs/arm64-v8a/libqemu-system-aarch64.so-# ─────────────────────────────────────────────────────────────────────────────-set -euo pipefail--SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"-IMAGE="podroid-qemu-builder"-CONTAINER="podroid-qemu-extract"-QEMU_VERSION="$(grep -E '^podroidQemuVersion=' "${SCRIPT_DIR}/gradle.properties" | cut -d= -f2)"--if [ -z "${QEMU_VERSION}" ]; then- echo "ERROR: podroidQemuVersion is not set in gradle.properties" >&2- exit 1-fi--echo "=== [1/4] Building QEMU ${QEMU_VERSION} for Android ARM64 ==="-echo " This will take 20-40 minutes on first run."-echo ""--docker build --no-cache \- -f "${SCRIPT_DIR}/Dockerfile.qemu" \- --build-arg "QEMU_VERSION=${QEMU_VERSION}" \- -t "${IMAGE}" \- "${SCRIPT_DIR}"--echo ""-echo "=== [2/4] Extracting artifacts ==="--# Clean up any previous container-docker rm -f "${CONTAINER}" 2>/dev/null || true--# Create a temporary container from the artifacts stage-docker create --name "${CONTAINER}" "${IMAGE}"--JNILIBS="${SCRIPT_DIR}/app/src/main/jniLibs/arm64-v8a"-ASSETS="${SCRIPT_DIR}/app/src/main/assets"--# Extract binaries-docker cp "${CONTAINER}:/out/libqemu-system-aarch64.so" "${JNILIBS}/libqemu-system-aarch64.so"-docker cp "${CONTAINER}:/out/libslirp.so" "${JNILIBS}/libslirp.so"-docker cp "${CONTAINER}:/out/libpodroid-bridge.so" "${JNILIBS}/libpodroid-bridge.so"--# Extract ROM and keymaps-docker cp "${CONTAINER}:/out/qemu/efi-virtio.rom" "${ASSETS}/qemu/efi-virtio.rom"-docker cp "${CONTAINER}:/out/qemu/keymaps/." "${ASSETS}/qemu/keymaps/"--docker rm "${CONTAINER}"--echo ""-echo "=== [3/4] Verifying binary ==="-echo -n " Architecture: "-file "${JNILIBS}/libqemu-system-aarch64.so" | grep -oP 'ARM aarch64.*?(?=,)'--echo -n " Size: "-du -sh "${JNILIBS}/libqemu-system-aarch64.so" | cut -f1--echo -n " Linked libs: "-readelf -d "${JNILIBS}/libqemu-system-aarch64.so" 2>/dev/null \- | grep NEEDED | grep -oP '\[\K[^\]]+' | tr '\n' ' '-echo ""--echo -n " QEMU version: "-# QEMU uses calendar versioning - 11.0.0-rc2 source has VERSION=10.2.92-# Detect both old-style (10.x) and new-style (11.x release candidates)-VER=""-if VER=$(strings "${JNILIBS}/libqemu-system-aarch64.so" | grep -m1 -oP 'QEMU emulator version \K[0-9]+\.[0-9]+\.[0-9]+'); then- echo "${VER} (11.0.0-rc2 source)"-else- echo "unknown"-fi--echo -n " virtio-9p: "-strings "${JNILIBS}/libqemu-system-aarch64.so" | grep -c "virtio-9p" || echo "0"--echo -n " 16KB pages: "-python3 - "${JNILIBS}/libqemu-system-aarch64.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("PASS" if ok else "FAIL")-if not ok:- sys.exit(1)-EOF--echo ""-echo "=== [4/4] Done! ==="-echo ""-echo " libqemu-system-aarch64.so → ${JNILIBS}/"-echo " libslirp.so → ${JNILIBS}/"-echo " libpodroid-bridge.so → ${JNILIBS}/"-echo " ROM + keymaps → ${ASSETS}/qemu/"-echo ""-echo " Now run: ./gradlew assembleDebug"-echo ""diff --git a/build-termux-android.sh b/build-termux-android.shdeleted file mode 100755index 75d1a2f..0000000--- a/build-termux-android.sh+++ /dev/null@@ -1,100 +0,0 @@-#!/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/docker-build-initramfs.sh b/docker-build-initramfs.shdeleted file mode 100755index 2ee5eeb..0000000--- a/docker-build-initramfs.sh+++ /dev/null@@ -1,49 +0,0 @@-#!/bin/bash-# Podroid initramfs builder using Docker-# Builds a custom Alpine aarch64 initramfs with ttyd + podman-set -e--SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"-ASSETS_DIR="$SCRIPT_DIR/app/src/main/assets"-IMAGE_NAME="podroid-builder"-CONTAINER_NAME="podroid-extract"--echo "=== Podroid Docker Initramfs Builder ==="-echo ""--# Step 1: Build the Docker image-echo "[1/3] Building Docker image (this may take a few minutes)..."-echo " - Stage 1: Downloading Alpine aarch64 ISO + netboot"-echo " - Stage 2: Installing ttyd + podman in aarch64 rootfs (via qemu-user)"-echo " - Stage 3: Packing initramfs"-echo ""--docker build -t "$IMAGE_NAME" "$SCRIPT_DIR"--echo ""-echo "[2/3] Extracting artifacts..."--# Step 2: Extract files from the image-# Create a temporary container from the scratch-based final image-# (scratch images need a dummy command for docker create)-docker rm "$CONTAINER_NAME" 2>/dev/null || true-docker create --name "$CONTAINER_NAME" "$IMAGE_NAME" /bin/true--mkdir -p "$ASSETS_DIR"--# Copy out the kernel and initramfs-docker cp "$CONTAINER_NAME:/vmlinuz-virt" "$ASSETS_DIR/vmlinuz-virt"-docker cp "$CONTAINER_NAME:/initrd.img" "$ASSETS_DIR/initrd.img"--# Cleanup container-docker rm "$CONTAINER_NAME" >/dev/null--echo ""-echo "[3/3] Done!"-echo ""-echo "Output files:"-ls -lh "$ASSETS_DIR/vmlinuz-virt" "$ASSETS_DIR/initrd.img"-echo ""-echo "Assets directory: $ASSETS_DIR"-echo ""-echo "=== Build complete! ==="diff --git a/test-deploy.sh b/test-deploy.shdeleted file mode 100755index 8360da6..0000000--- a/test-deploy.sh+++ /dev/null@@ -1,155 +0,0 @@-#!/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"