Skip to content

Commit

Permalink
install: Add fallback to OTP unzip (#1780)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach authored Nov 4, 2024
1 parent 697467a commit f04b8b0
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,16 @@ main() {
otp_dir="$root_dir/installs/otp/$otp_version"
elixir_dir="${root_dir}/installs/elixir/${elixir_version}-otp-${elixir_otp_release}"

install_otp &
install_elixir &
wait
if unzip_available; then
install_otp &
install_elixir &
wait
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"
Expand Down Expand Up @@ -253,7 +260,15 @@ install_elixir() {
echo "unpacking $elixir_zip to $elixir_dir..."
rm -rf "${elixir_dir}"
mkdir -p "${elixir_dir}"
unzip -q "${tmp_dir}/${elixir_zip}" -d "${elixir_dir}"

if unzip_available; then
unzip -q "${tmp_dir}/${elixir_zip}" -d "${elixir_dir}"
else
"${otp_dir}/bin/erl" -noshell -eval \
'[Zip,Dir] = init:get_plain_arguments(), {ok,_} = zip:unzip(Zip, [{cwd, Dir}]), halt().' \
-- "${tmp_dir}/${elixir_zip}" "${elixir_dir}"
fi

rm "${tmp_dir}/${elixir_zip}"
fi
}
Expand All @@ -265,4 +280,8 @@ download() {
curl --retry 3 -fsSLo "$output" "$url"
}

unzip_available() {
which unzip >/dev/null 2>&1
}

main "$@"

0 comments on commit f04b8b0

Please sign in to comment.