Files
roc-lang-tools/scripts/download-roc.sh
T

56 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROC_VERSION="${1:?Usage: $0 <roc-version> [target-arch]}"
TARGETARCH="${2:-amd64}"
# Map Docker buildx arch names to Roc tarball arch names
case "$TARGETARCH" in
amd64) ROC_ARCH="x86_64" ;;
arm64) ROC_ARCH="aarch64" ;;
*) echo "Unsupported architecture: $TARGETARCH" >&2; exit 1 ;;
esac
TARBALL="roc-linux_${ROC_ARCH}-${ROC_VERSION}.tar.gz"
URL="https://github.com/roc-lang/roc/releases/download/${ROC_VERSION}/${TARBALL}"
echo "Downloading Roc ${ROC_VERSION} for ${ROC_ARCH}..."
curl -fsSL "$URL" -o /tmp/roc.tar.gz
echo "Extracting..."
tar -xzf /tmp/roc.tar.gz -C /tmp/
# The tarball contains a single directory with an unpredictable nightly name
# e.g. roc_nightly-linux_x86_64-2025-09-09-d73ea109/
EXTRACTED_DIR=$(find /tmp -maxdepth 1 -type d -name "roc_*" | head -1)
if [ -z "$EXTRACTED_DIR" ]; then
echo "ERROR: Could not find extracted Roc directory in /tmp" >&2
exit 1
fi
echo "Installing to /opt/roc..."
mkdir -p /opt/roc/bin /opt/roc/lib
install -m 0755 "$EXTRACTED_DIR/roc" /opt/roc/bin/roc
# LSP may or may not be present in older releases; install if found
if [ -f "$EXTRACTED_DIR/roc_language_server" ]; then
install -m 0755 "$EXTRACTED_DIR/roc_language_server" /opt/roc/bin/roc_language_server
fi
# WASI libc is needed for some platforms
if [ -d "$EXTRACTED_DIR/lib" ]; then
cp -r "$EXTRACTED_DIR/lib/"* /opt/roc/lib/
fi
# License
if [ -f "$EXTRACTED_DIR/LICENSE" ]; then
cp "$EXTRACTED_DIR/LICENSE" /opt/roc/LICENSE
fi
# Cleanup
rm -rf /tmp/roc.tar.gz "$EXTRACTED_DIR"
echo "Roc ${ROC_VERSION} installed successfully."
/opt/roc/bin/roc --version