#!/bin/sh # See latest version at: # https://github.com/elixir-lang/elixir-lang.github.com/blob/main/install.sh set -eu otp_version= elixir_version= force=false usage() { cat<&2 exit 1 ;; esac done if [ -z "${elixir_version}" ]; then usage echo "error: missing elixir@VERSION argument" exit 1 fi if [ -z "${otp_version}" ]; then usage echo "error: missing otp@VERSION argument" exit 1 fi root_dir="$HOME/.elixir-install" tmp_dir="$root_dir/tmp" mkdir -p "$tmp_dir" if [ "${otp_version}" = latest ]; then url=$(curl -fsS --head https://github.com/erlef/otp_builds/releases/latest | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n') tag=$(basename "$url") otp_version="${tag#OTP-}" fi if [ "${elixir_version}" = latest ]; then url=$(curl -fsS --head https://github.com/elixir-lang/elixir/releases/latest | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n') tag=$(basename "$url") elixir_version="${tag#v}" fi case "${otp_version}" in master|maint*) branch_version=$(curl -fsS https://raw.githubusercontent.com/erlang/otp/refs/heads/${otp_version}/OTP_VERSION | tr -d '\n') elixir_otp_release="${branch_version%%.*}" ;; *) elixir_otp_release="${otp_version%%.*}" ;; esac case "$elixir_version" in 1.14.*) [ "${elixir_otp_release}" -ge 25 ] && elixir_otp_release=25 ;; 1.15.*|1.16.*) [ "${elixir_otp_release}" -ge 26 ] && elixir_otp_release=26 ;; 1.17.*|1.18.*) [ "${elixir_otp_release}" -ge 27 ] && elixir_otp_release=27 ;; 1.19.*) [ "${elixir_otp_release}" -ge 28 ] && elixir_otp_release=28 ;; *) [ "${elixir_otp_release}" -ge 28 ] && elixir_otp_release=28 ;; esac otp_dir="$root_dir/installs/otp/$otp_version" elixir_dir="${root_dir}/installs/elixir/${elixir_version}-otp-${elixir_otp_release}" if unzip_available; then install_otp & pid_otp=$! install_elixir & pid_elixir=$! wait $pid_otp wait $pid_elixir else # if unzip is missing (e.g. official docker ubuntu image), install otp and elixir # serially because we unzip elixir using OTP zip:extract/2. install_otp install_elixir fi printf "checking OTP... " export PATH="$otp_dir/bin:$PATH" erl -noshell -eval 'io:put_chars(erlang:system_info(otp_release) ++ " ok\n"), halt().' printf "checking Elixir... " "$elixir_dir/bin/elixir" -e 'IO.puts(System.version() <> " ok")' export PATH="$elixir_dir/bin:$PATH" cat</dev/null 2>&1 } main "$@"