File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,8 +148,19 @@ detect_arch() {
148148 esac
149149}
150150
151+ is_android () {
152+ [ " $( uname -o 2> /dev/null || true) " = " Android" ] \
153+ || [ -n " ${TERMUX_VERSION:- } " ] \
154+ || [[ " ${PREFIX:- } " == /data/data/com.termux/* ]]
155+ }
156+
151157OS=$( detect_os)
152158ARCH=$( detect_arch)
159+ if [ " $OS " = " linux" ] && is_android; then
160+ echo ' error: Android/Termux cannot run the Linux portable binary (static glibc; Android kills it with "Bad system call").' >&2
161+ echo " Building from source in Termux may work but is not a supported platform yet - see issue #1202." >&2
162+ exit 1
163+ fi
153164
154165echo " codebase-memory-mcp installer"
155166echo " os: $OS "
Original file line number Diff line number Diff line change @@ -364,6 +364,9 @@ bash "$ROOT/tests/test_language_count_contract.sh"
364364echo " === Step 0x: packaging version-metadata contract ==="
365365bash " $ROOT /tests/test_version_metadata_contract.sh"
366366
367+ echo " === Step 0x2: installer Android/Termux guard contract (#1202) ==="
368+ bash " $ROOT /tests/test_install_android_guard.sh"
369+
367370# Step 0y: the Windows leg must not decide its verdict from an exit status that
368371# the ssh/msys2_shell chain can mangle — a channel that turns 0 into 1 can turn
369372# 1 into 0, and that direction reports a RED Windows leg as green. Runs
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ ROOT=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd)
5+ WORK=$( mktemp -d)
6+ trap ' rm -rf "$WORK"' EXIT
7+
8+ mkdir -p " $WORK /bin" " $WORK /home"
9+ cat > " $WORK /bin/uname" << 'EOF '
10+ #!/usr/bin/env bash
11+ case "$1" in
12+ -s) printf '%s\n' Linux ;;
13+ -m) printf '%s\n' aarch64 ;;
14+ -o) printf '%s\n' Android ;;
15+ *) exit 1 ;;
16+ esac
17+ EOF
18+ cat > " $WORK /bin/curl" << 'EOF '
19+ #!/usr/bin/env bash
20+ printf 'curl must not run for Android/Termux\n' >&2
21+ exit 99
22+ EOF
23+ chmod +x " $WORK /bin/uname" " $WORK /bin/curl"
24+
25+ # The stubs must be what install.sh sees, or this test proves nothing.
26+ if [ " $( PATH=" $WORK /bin:$PATH " uname -o) " != " Android" ]; then
27+ printf ' FAIL: the uname stub is not picked up from PATH\n' >&2
28+ exit 1
29+ fi
30+
31+ set +e
32+ output=$( PATH=" $WORK /bin:$PATH " HOME=" $WORK /home" \
33+ CBM_DOWNLOAD_URL=" http://127.0.0.1:9/cbm-android-guard-test" \
34+ bash " $ROOT /install.sh" --skip-config 2>&1 )
35+ rc=$?
36+ set -e
37+
38+ if [ " $rc " -eq 0 ]; then
39+ printf ' FAIL: installer accepted Android/Termux\n' >&2
40+ exit 1
41+ fi
42+ if ! grep -Fq ' Android/Termux' <<< " $output" ; then
43+ printf ' FAIL: missing Android/Termux guidance\n%s\n' " $output " >&2
44+ exit 1
45+ fi
46+ if grep -Fq ' curl must not run' <<< " $output" ; then
47+ printf ' FAIL: installer downloaded before rejecting Android/Termux\n' >&2
48+ exit 1
49+ fi
50+
51+ printf ' PASS: Android/Termux is rejected before download\n'
You can’t perform that action at this time.
0 commit comments