Skip to content

Instantly share code, notes, and snippets.

@zacky1972
Last active December 2, 2024 09:37
Show Gist options
  • Save zacky1972/f5ff14bb3b4630f2f2e4e59329dd85a0 to your computer and use it in GitHub Desktop.
Save zacky1972/f5ff14bb3b4630f2f2e4e59329dd85a0 to your computer and use it in GitHub Desktop.
Erlang/OTP installer for macOS using the community-maintained pre-compiled Erlang/OTP
#!/bin/bash
dir="$HOME/.erl"
mkdir -p dir
if [ $# -lt 1 ]; then
echo "Usage: $0 [latest|version]"
exit 0
fi
if [ $(uname -s) != "Darwin" ]; then
echo "This machine is not Mac."
exit 1
fi
case $(uname -m) in
"arm64")
target="aarch64-apple-darwin";;
"x86_64")
target="x86_64-apple-darwin";;
*)
echo "This machine is not aarch64 nor x86_64."
exit 1;;
esac
if [ $1 = "latest" ]; then
version="$(curl -fsSL https://github.com/erlef/otp_builds/raw/main/builds/aarch64-apple-darwin.csv | grep -e "^OTP" | cut -d"," -f1 | cut -d"-" -f2 |sort -n | tail -1)"
else
version="$1"
fi
line=$(curl -fsSL https://github.com/erlef/otp_builds/raw/main/builds/$target.csv | grep OTP-$version,)
if [ -z $line ]; then
echo "Does not specified version"
exit 1
fi
checksum=$(echo $line | cut -d"," -f4)
mkdir -p $dir/$version
cd /tmp
curl -fLO https://github.com/erlef/otp_builds/releases/download/OTP-$version/otp-$target.tar.gz
sha256 otp-$target.tar.gz --check $checksum
if [ $? -ne 0 ]; then
echo "Does not match checksum."
exit 1
fi
cd $dir/$version
tar xfz /tmp/otp-$target.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment