Skip to content

Commit ed78ff0

Browse files
committed
fix(install): reject Android portable binary
Signed-off-by: lorenzozanee <wyz0707@proton.me>
1 parent 45c45be commit ed78ff0

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎install.sh‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
151157
OS=$(detect_os)
152158
ARCH=$(detect_arch)
159+
if [ "$OS" = "linux" ] && is_android; then
160+
echo "error: Android/Termux is not supported by the Linux portable binary." >&2
161+
echo "Build from source with scripts/build.sh in Termux or use a supported Linux host." >&2
162+
exit 1
163+
fi
153164

154165
echo "codebase-memory-mcp installer"
155166
echo " os: $OS"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
case "$1" in
11+
-s) printf '%s\n' Linux ;;
12+
-m) printf '%s\n' aarch64 ;;
13+
-o) printf '%s\n' Android ;;
14+
*) exit 1 ;;
15+
esac
16+
EOF
17+
cat >"$WORK/bin/curl" <<'EOF'
18+
printf 'curl must not run for Android/Termux\n' >&2
19+
exit 99
20+
EOF
21+
chmod +x "$WORK/bin/uname" "$WORK/bin/curl"
22+
23+
set +e
24+
output=$(PATH="$WORK/bin:$PATH" HOME="$WORK/home" bash "$ROOT/install.sh" --skip-config 2>&1)
25+
rc=$?
26+
set -e
27+
28+
if [ "$rc" -eq 0 ]; then
29+
printf 'FAIL: installer accepted Android/Termux\n' >&2
30+
exit 1
31+
fi
32+
if ! grep -Fq 'Android/Termux' <<<"$output"; then
33+
printf 'FAIL: missing Android/Termux guidance\n%s\n' "$output" >&2
34+
exit 1
35+
fi
36+
if grep -Fq 'curl must not run' <<<"$output"; then
37+
printf 'FAIL: installer downloaded before rejecting Android/Termux\n' >&2
38+
exit 1
39+
fi
40+
41+
printf 'PASS: Android/Termux is rejected before download\n'

0 commit comments

Comments
 (0)