FIX: prefer linux in WSL and add INSTALL_OS override for CLI (#5215)
Signed-off-by: Carine Bruyndoncx <bruyndoncx@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0515c76e84
commit
bee1b46a4f
+38
-12
@@ -88,26 +88,52 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# --- 3) Detect OS/Architecture ---
|
# --- 3) Detect OS/Architecture ---
|
||||||
# Better OS detection for Windows environments
|
# Allow explicit override for automation or when auto-detection is wrong:
|
||||||
if [[ "${WINDIR:-}" ]] || [[ "${windir:-}" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
|
# INSTALL_OS=linux|windows|darwin
|
||||||
|
if [ -n "${INSTALL_OS:-}" ]; then
|
||||||
|
case "${INSTALL_OS}" in
|
||||||
|
linux|windows|darwin) OS="${INSTALL_OS}" ;;
|
||||||
|
*) echo "[error]: unsupported INSTALL_OS='${INSTALL_OS}' (expected: linux|windows|darwin)"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# Better OS detection for Windows environments, with safer WSL handling.
|
||||||
|
# If explicit Windows-like shells/variables are present (MSYS/Cygwin), treat as windows.
|
||||||
|
if [[ "${WINDIR:-}" ]] || [[ "${windir:-}" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
|
||||||
OS="windows"
|
OS="windows"
|
||||||
elif [[ -f "/proc/version" ]] && grep -q "Microsoft\|WSL" /proc/version 2>/dev/null; then
|
elif [[ -f "/proc/version" ]] && grep -q "Microsoft\|WSL" /proc/version 2>/dev/null; then
|
||||||
# WSL detection
|
# WSL detected. Prefer Linux unless there are clear signs we should install the Windows build:
|
||||||
|
# - running on a Windows-mounted path like /mnt/c/... OR
|
||||||
|
# - Windows executables are available AND we're on a Windows mount
|
||||||
|
if [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]]; then
|
||||||
|
OS="windows"
|
||||||
|
else
|
||||||
|
# If powershell/cmd exist, only treat as Windows when in a Windows mount
|
||||||
|
if command -v powershell.exe >/dev/null 2>&1 || command -v cmd.exe >/dev/null 2>&1; then
|
||||||
|
if [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]] || [[ -d "/c" || -d "/d" || -d "/e" ]]; then
|
||||||
|
OS="windows"
|
||||||
|
else
|
||||||
|
OS="linux"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# No strong Windows interop present — install Linux build inside WSL by default
|
||||||
|
OS="linux"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
elif [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]]; then
|
||||||
|
# WSL mount point detection (like /mnt/c/) outside of /proc/version check
|
||||||
OS="windows"
|
OS="windows"
|
||||||
elif [[ "$PWD" =~ ^/mnt/[a-zA-Z]/ ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
# WSL mount point detection (like /mnt/c/)
|
|
||||||
OS="windows"
|
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
OS="darwin"
|
OS="darwin"
|
||||||
elif command -v powershell.exe >/dev/null 2>&1 || command -v cmd.exe >/dev/null 2>&1; then
|
elif command -v powershell.exe >/dev/null 2>&1 || command -v cmd.exe >/dev/null 2>&1; then
|
||||||
# Check if Windows executables are available (another Windows indicator)
|
# Presence of Windows executables (likely a Windows environment)
|
||||||
OS="windows"
|
OS="windows"
|
||||||
elif [[ "$PWD" =~ ^/[a-zA-Z]/ ]] && [[ -d "/c" || -d "/d" || -d "/e" ]]; then
|
elif [[ "$PWD" =~ ^/[a-zA-Z]/ ]] && [[ -d "/c" || -d "/d" || -d "/e" ]]; then
|
||||||
# Check for Windows-style mount points (like in Git Bash)
|
# Check for Windows-style mount points (like in Git Bash)
|
||||||
OS="windows"
|
OS="windows"
|
||||||
else
|
else
|
||||||
# Fallback to uname for other systems
|
# Fallback to uname for other systems
|
||||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
|
|||||||
Reference in New Issue
Block a user