Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,19 @@ detect_arch() {
esac
}

is_android() {
[ "$(uname -o 2>/dev/null || true)" = "Android" ] \
|| [ -n "${TERMUX_VERSION:-}" ] \
|| [[ "${PREFIX:-}" == /data/data/com.termux/* ]]
}

OS=$(detect_os)
ARCH=$(detect_arch)
if [ "$OS" = "linux" ] && is_android; then
echo "error: Android/Termux is not supported by the Linux portable binary." >&2
echo "Build from source with scripts/build.sh in Termux or use a supported Linux host." >&2
exit 1
fi

echo "codebase-memory-mcp installer"
echo " os: $OS"
Expand Down
41 changes: 41 additions & 0 deletions tests/test-install-android-guard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT

mkdir -p "$WORK/bin" "$WORK/home"
cat >"$WORK/bin/uname" <<'EOF'
case "$1" in
-s) printf '%s\n' Linux ;;
-m) printf '%s\n' aarch64 ;;
-o) printf '%s\n' Android ;;
*) exit 1 ;;
esac
EOF
cat >"$WORK/bin/curl" <<'EOF'
printf 'curl must not run for Android/Termux\n' >&2
exit 99
EOF
chmod +x "$WORK/bin/uname" "$WORK/bin/curl"

set +e
output=$(PATH="$WORK/bin:$PATH" HOME="$WORK/home" bash "$ROOT/install.sh" --skip-config 2>&1)
rc=$?
set -e

if [ "$rc" -eq 0 ]; then
printf 'FAIL: installer accepted Android/Termux\n' >&2
exit 1
fi
if ! grep -Fq 'Android/Termux' <<<"$output"; then
printf 'FAIL: missing Android/Termux guidance\n%s\n' "$output" >&2
exit 1
fi
if grep -Fq 'curl must not run' <<<"$output"; then
printf 'FAIL: installer downloaded before rejecting Android/Termux\n' >&2
exit 1
fi

printf 'PASS: Android/Termux is rejected before download\n'
Loading