Skip to content

Commit 0ca8711

Browse files
lexfreiclaude
andcommitted
fix(install): Respect TARGETARCH env var for cross-compilation
The install script now checks for TARGETARCH (set by Docker buildx) or ARCH environment variables before falling back to `uname -m`. This fixes cross-compilation scenarios where `uname -m` returns the build host architecture instead of the target architecture, causing the wrong binary to be downloaded. Example usage in Dockerfile: ```dockerfile ARG TARGETARCH RUN wget -O- .../install.sh | sh ``` Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
1 parent 12ed7c8 commit 0ca8711

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

hack/install.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ Usage: $0 [OPTIONS]
1818
Options:
1919
-v, --version VERSION Install specific release (e.g. 1.4.0 or v1.4.0).
2020
-h, --help Show this help and exit.
21+
22+
Environment variables:
23+
TARGETARCH Override architecture detection (e.g. amd64, arm64).
24+
Useful for Docker buildx cross-compilation.
25+
ARCH Alternative to TARGETARCH for architecture override.
2126
EOF
2227
}
2328

@@ -89,7 +94,16 @@ else
8994
fi
9095

9196
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
92-
ARCH=$(uname -m)
97+
98+
# Detect architecture: respect TARGETARCH (Docker buildx) or ARCH env vars, fallback to uname -m
99+
if [ -n "$TARGETARCH" ]; then
100+
ARCH="$TARGETARCH"
101+
elif [ -n "$ARCH" ]; then
102+
# ARCH already set by environment
103+
:
104+
else
105+
ARCH=$(uname -m)
106+
fi
93107

94108
case "$ARCH" in
95109
x86_64|amd64) ARCH="amd64" ;;

0 commit comments

Comments
 (0)