diff --git a/src/usr/local/buildpack/tools/erlang.sh b/src/usr/local/buildpack/tools/erlang.sh index 5952146d57..81cb198fe8 100644 --- a/src/usr/local/buildpack/tools/erlang.sh +++ b/src/usr/local/buildpack/tools/erlang.sh @@ -2,12 +2,70 @@ set -e -require_root -curl -sSL https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb -o erlang.deb -dpkg -i erlang.deb -rm -f erlang.deb +SEMVER_REGEX="^(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))?(\.(0|[1-9][0-9]*))?(\.(0|[1-9][0-9]*))?(\+[0-9]+)?([a-z-].*)?$" -apt_install "esl-erlang=1:${TOOL_VERSION}*" +function check_semver () { + if [[ ! "${1}" =~ ${SEMVER_REGEX} ]]; then + echo Not a semver like version - aborting: "${1}" + exit 1 + fi + export MAJOR=${BASH_REMATCH[1]} + export MINOR=${BASH_REMATCH[3]} + export PATCH=${BASH_REMATCH[5]} + export BUILD=${BASH_REMATCH[7]} +} +check_semver "${TOOL_VERSION}" + + +if [[ ! "${MAJOR}" || ! "${MINOR}" || ! "${PATCH}" || ! "${BUILD}" ]]; then + echo Invalid version: "${TOOL_VERSION}" + exit 1 +fi + +tool_path=$(find_versioned_tool_path) + +if [[ -z "${tool_path}" ]]; then + INSTALL_DIR=$(get_install_dir) + base_path=${INSTALL_DIR}/${TOOL_NAME} + tool_path=${base_path}/${TOOL_VERSION} + + mkdir -p "${base_path}" + + file=/tmp/${TOOL_NAME}.tar.xz + + ARCH=$(uname -p) + BASE_URL="https://github.com/containerbase/${TOOL_NAME}-prebuild/releases/download" + + version_codename=$(get_distro) + + # TODO: extract to separate preparation tool + require_root + case "$version_codename" in + "bionic") apt_install \ + libodbc1 \ + libssl1.1 \ + libsctp1 \ + ;; + "focal") apt_install \ + libodbc1 \ + libssl1.1 \ + libsctp1 \ + ;; + esac + + curl -sSfLo "${file}" "${BASE_URL}/${TOOL_VERSION}/${TOOL_NAME}-${TOOL_VERSION}-${version_codename}-${ARCH}.tar.xz" + + if [[ -f ${file} ]]; then + echo "Using prebuild ${TOOL_NAME}" + tar -C "${base_path}" -xf "${file}" + rm "${file}" + else + echo "No prebuild ${TOOL_NAME} found" >&2 + exit 1 + fi +fi + +link_wrapper "erl" "${tool_path}/bin" erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell diff --git a/test/Dockerfile.bionic b/test/Dockerfile.bionic index f0e43ccb73..709b181dda 100644 --- a/test/Dockerfile.bionic +++ b/test/Dockerfile.bionic @@ -31,8 +31,8 @@ ARG APT_HTTP_PROXY # renovate: datasource=docker lookupName=mcr.microsoft.com/dotnet/sdk versioning=docker RUN install-tool dotnet 6.0.200 -#disable renovate: datasource=github-releases lookupName=erlang/otp versioning=loose -RUN install-tool erlang 22.3.2 +# renovate: datasource=github-releases lookupName=containerbase/erlang-prebuild versioning=docker +RUN install-tool erlang 22.3.4.24 # renovate: datasource=docker versioning=docker RUN install-tool elixir 1.13.3 diff --git a/test/erlang/Dockerfile b/test/erlang/Dockerfile index 03d13c4db3..7f6f828009 100644 --- a/test/erlang/Dockerfile +++ b/test/erlang/Dockerfile @@ -5,8 +5,8 @@ ARG APT_HTTP_PROXY # Erlang -#disable renovate: datasource=github-releases lookupName=erlang/otp versioning=loose -RUN install-tool erlang 22.3.2 +# renovate: datasource=github-releases lookupName=containerbase/erlang-prebuild versioning=docker +RUN install-tool erlang 22.3.4.24 # Elixir