diff --git a/bin/install b/bin/install index ceab873..6f81f91 100755 --- a/bin/install +++ b/bin/install @@ -25,30 +25,31 @@ install_rebar() { # Running this in a subshell because we don't to disturb the current # working directory. - ( - cd "$(dirname "$source_path")" || exit 1 - tar zxvf "$source_path" &>/dev/null || exit 1 - - cd "$(untar_path "$install_type" "$version" "$tmp_download_dir")" || exit 1 - - # Build rebar - ./bootstrap || exit 1 + if version_3x_or_greater "$version"; then + ( + cd "$(dirname "$source_path")" || exit 1 + + # Copy (executable) rebar3 into the bin directory inside the asdf install directory + chmod +x rebar3 || exit 1 + mkdir -p "$install_path/bin/" || exit 1 + cp rebar3 "$install_path/bin/" || exit 1 + ) + else + ( + cd "$(dirname "$source_path")" || exit 1 + tar zxvf "$source_path" &>/dev/null || exit 1 - # Copy rebar into the bin directory inside the asdf install directory - mkdir -p "$install_path/bin/" || exit 1 + cd "$(untar_path "$install_type" "$version" "$tmp_download_dir")" || exit 1 - if version_3x_or_greater "$version"; then - local rebar3_binary="_build/default/bin/rebar3" + # Build rebar + ./bootstrap || exit 1 - if [ ! -f $rebar3_binary ]; then - rebar3_binary="_build/prod/bin/rebar3" - fi + # Copy rebar into the bin directory inside the asdf install directory + mkdir -p "$install_path/bin/" || exit 1 - cp "$rebar3_binary" "$install_path/bin/" || exit 1 - else cp rebar "$install_path/bin/" || exit 1 - fi - ) + ) + fi } download_source() { @@ -72,6 +73,10 @@ get_download_file_path() { local pkg_name="${rebar_version}.tar.gz" + if version_3x_or_greater "$version"; then + pkg_name="rebar3" + fi + echo "$tmp_download_dir/$pkg_name" } @@ -100,7 +105,7 @@ get_download_url() { local version=$2 if version_3x_or_greater "$version"; then - echo "https://github.com/erlang/rebar3/archive/${version}.tar.gz" + echo "https://github.com/erlang/rebar3/releases/download/${version}/rebar3" else echo "https://github.com/rebar/rebar/archive/${version}.tar.gz" fi