Repository navigation
fix(runtime): make the local runtime install on x86_64 (proot seccomp fork fix) - #17
Merged
Merged
Conversation
On x86_64 Android (e.g. the emulator) the local runtime never installed: `apk add` failed with "/bin/sh: can't fork: Function not implemented". Android's app seccomp policy only allows fork(2) on 32-bit ABIs, musl calls SYS_fork directly on x86_64, and PRoot's SIGSYS handler answers unknown syscalls with ENOSYS. arm64 has no fork(2) and is unaffected. Carry the PRoot change proposed upstream (termux/proot#415) as a termux-packages recipe patch that rewrites fork(2) into clone(SIGCHLD, 0, 0, 0, 0), and build the github release APKs from the source-built native payload too, so they ship the patched proot rather than the Termux mirror prebuilt. The release runtime-asset cache gets its own key so a mirror-derived payload is never restored there, and the native source build job checks that the patch reached the proot source. Verified on the Android 15 x86_64 emulator: with the patched proot the app's setup installs the runtime and `opencode serve` comes up.
… patch Source builds used the pinned termux-packages commit's proot recipe, 5.1.107.94, while the lock pins 5.1.107.96, so building the github APKs from source would have downgraded proot. Override the recipe with the mirrored 5.1.107.96 build.sh (the pinned commit can't be bumped: the .96 bump moved to NDK r30). Update the third-party notices, which said release binaries come from the mirror unmodified, to state the source build and the proot modification.
Keep proot.build.sh a verbatim mirror (the note now lives only in the build script).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On x86_64 Android (e.g. the emulator) the local runtime never installed:
apk addfailed with/bin/sh: can't fork: Function not implemented.Root cause: Android's app seccomp policy only allows
fork(2)on 32-bit ABIs (bionicSECCOMP_ALLOWLIST_APP.TXT:fork() lp32). musl callsSYS_forkdirectly on x86_64, and PRoot's SIGSYS handler answers unhandled syscalls withENOSYS. arm64 has nofork(2), so it is unaffected.fork(2)intoclone(SIGCHLD, 0, 0, 0, 0)) as a termux-packages recipe patch.-Pandcode.sourceNativeLibs=true), so published APKs ship the patched proot. The release runtime-asset cache gets a separate key.native-source-libs.ymlchecks that both architectures producedproot_5.1.107.96and that the patch was applied twice.Local and CI dev builds keep the mirror path. Until termux/proot#415 lands and the lock is bumped, x86_64 works only with release/source-built APKs.
Verification
can't fork: Function not implementedapk addof ~150 packages succeeds,opencode servelistens on 4098 and/global/healthanswers.LegalDisclosureComplianceTest19/19 pass.bash -nand YAML parse are OK for the edited script and workflows.native-source-libs.ymlcovers it in CI.Pre-PR review
判定: APPROVE
ブロッカー
なし
提案(非ブロッキング)
なし
チェック済み項目
09a331be、7e931f99、8e35031b)、10 ファイルです。worktree に未コミットの変更はありません。runtime_tools/termux-packaging-recipes/proot.build.sh:origin/mainとの差分は 0 行で、verbatim の写しに戻っています。ヘッダの "Mirrored verbatim" とも矛盾しません。上書きコピーの説明はbuild_android_runtime_native_debs.sh:138-144にだけ書かれています。.github/workflows/native-source-libs.yml:37-50を確認しました。set -o pipefailとteeの組み合わせなので、ビルドスクリプトが失敗すればステップも失敗します。TERMUX_PKG_REVISIONがないので、生成される deb の名前はproot_5.1.107.96_<arch>.debになります。glob の対象はレシピにある 2 arch の分だけで、件数は 2 になります。上書きが効かなかった場合は.94になり、件数が 0 になって失敗します。lsが失敗した場合もwc -lが 0 を返すので、testで落ちます。2a342d4bのtermux_step_patch_package.shは、パッチごとにecho "Applying patch: $(basename $patch)"を標準出力に出します。そのため arch ごとに 1 回、合計 2 回ログに出るはずで、grep -c ... -eq 2の想定と合います。.96に上書きしてパッチを当てる処理、ライセンス・サービス文書の同一性(index ハッシュが一致)と改変の告知、release.yml のソースビルドとキャッシュキー、パッチの中身と上流 seccomp: run fork(2) as clone(2) when the outer policy rejects it termux/proot#415 との一致です。