Repository: asdf-vm/asdf-erlang Branch: master Commit: 7d76f6bed86d Files: 13 Total size: 26.2 KB Directory structure: gitextract_43m9n7ar/ ├── .editorconfig ├── .github/ │ └── workflows/ │ └── ci.yml ├── .gitignore ├── .tool-versions ├── .travis.yml ├── LICENSE ├── README.md ├── bin/ │ ├── install │ ├── list-all │ └── uninstall ├── lib/ │ └── utils.sh └── scripts/ ├── shellcheck.bash └── shfmt.bash ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] indent_style = space indent_size = 4 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true ================================================ FILE: .github/workflows/ci.yml ================================================ name: CI on: pull_request: types: - opened - synchronize - reopened paths-ignore: - "**.md" push: branches: - master paths-ignore: - "**.md" jobs: test: name: Test asdf-erlang plugin strategy: matrix: os: - ubuntu-latest - macos-latest runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v2 - name: Install system packages on Ubuntu if: ${{ runner.os == 'Linux' }} run: sudo apt-get update; sudo apt-get -y install build-essential autoconf m4 libwxgtk3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev xsltproc fop libxml2-utils libncurses-dev - name: Install system packages on macOS if: ${{ runner.os == 'macOS' }} run: brew install autoconf openssl@1.1 - name: Test plugin uses: asdf-vm/actions/plugin-test@v1 with: command: erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(re:replace(Version, "(^\\s+)|(\\s+$)", "", [global,{return,list}])), halt().' -noshell lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Run ShellCheck run: scripts/shellcheck.bash format: runs-on: macos-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Install shfmt run: brew install shfmt - name: Run shfmt run: scripts/shfmt.bash ================================================ FILE: .gitignore ================================================ kerl kerl-home ================================================ FILE: .tool-versions ================================================ shellcheck 0.7.1 shfmt 3.3.0 ================================================ FILE: .travis.yml ================================================ language: c script: |- travis_wait 40 asdf plugin-test erlang . --asdf-plugin-gitref $TRAVIS_COMMIT erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(re:replace(Version, "(^\\s+)|(\\s+$)", "", [global,{return,list}])), halt().' -noshell before_script: - git clone https://github.com/asdf-vm/asdf.git - . asdf/asdf.sh os: - linux - osx install: - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -y xsltproc fop; fi ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017 asdf version manager Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # asdf-erlang Erlang plugin for [asdf](https://github.com/asdf-vm/asdf) version manager that relies on [kerl](https://github.com/kerl/kerl) for builds. This plugin aims to combine the best of both worlds by using kerl. kerl's compatibility and build scripts, together with asdf's easy version switching and support for the .tool-versions file. You do not need to have kerl already installed to use this. The plugin will install it's own version of kerl automatically. ## Install ``` asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git ``` **Important**: Make sure to read the [Before asdf install](#before-asdf-install) section below to install dependencies! ## Use Check [asdf](https://github.com/asdf-vm/asdf) readme for instructions on how to install & manage versions of Erlang. To specify custom options you [can set environment variables just as you would when using kerl](https://github.com/kerl/kerl#kerl_base_dir). For example, to skip the Java dependency during installation use: ``` export KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac" asdf install erlang ``` You can also install Erlang from git, or provide the url to a fork and build from git. ``` asdf install erlang ref:master export OTP_GITHUB_URL="https://github.com/basho/otp" asdf install erlang ref:basho ``` See [kerl](https://github.com/kerl/kerl) for the complete list of customization options. Note that the `KERL_BASE_DIR` and `KERL_CONFIG` environment variables are set by the plugin when it runs kerl so it will not be possible to customize them. ## Before `asdf install` ### Ubuntu and Debian Note that if you are using a previous version of Linux, you may need a different version of one of the below libraries. #### Ubuntu 16.04 LTS "Xenial Xerus" Install the build tools (dpkg-dev g++ gcc libc6-dev make debianutils m4 perl) `apt-get -y install build-essential autoconf` Needed for HiPE (native code) support, but already installed by autoconf `apt-get -y install m4` Needed for terminal handling (libc-dev libncurses5 libtinfo-dev libtinfo5 ncurses-bin) `apt-get -y install libncurses5-dev` For building with wxWidgets (start observer or debugger!). Note that you may need to select the right `wx-config` before installing Erlang. `apt-get -y install libwxgtk3.0-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev` For building ssl (libssh-4 libssl-dev zlib1g-dev) `apt-get -y install libssh-dev` ODBC support (libltdl3-dev odbcinst1debian2 unixodbc) `apt-get -y install unixodbc-dev` For building documentation: `apt-get install xsltproc fop` If you want to install all the above: `apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop` #### Ubuntu 20.04 LTS If you need to use `wxWebView` in Erlang you'll want to install a library for it: `apt-get -y install libwxgtk-webview3.0-gtk3-dev` If you want to install all the above: `apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk` #### Ubuntu 24.04 LTS If you want to install all the above: `apt-get -y install build-essential autoconf m4 libwxgtk3.2-dev libwxgtk-webview3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk` #### Debian 12 (bookworm) To install the whole dependency suite: `apt-get -y install build-essential autoconf m4 libncurses-dev libwxgtk3.2-dev libwxgtk-webview3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils openjdk-17-jdk` #### Debian 13 (trixie) To install the whole dependency suite: `apt-get -y install build-essential autoconf m4 libncurses-dev libwxgtk3.2-dev libwxgtk-webview3.2-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils openjdk-21-jdk` ### Arch Linux Provides most of the needed build tools. `pacman -S --needed base-devel` Needed for terminal handling `pacman -S ncurses` For building with wxWidgets (start observer or debugger!). Make sure `wx-config --selected-config` prints `gtk3-unicode-...` before installing Erlang. Older OTP builds may require wxgtk2, in that case install `wxgtk2-dev` from AUR. `pacman -S glu mesa wxwidgets-gtk3 libpng` For building ssl `pacman -S libssh` ODBC support `sudo pacman -S unixodbc` For building documentation and elixir reference builds: `sudo pacman -S libxslt fop` #### Dealing with ODBC issues on arch You may encounter an ODBC error with an output along these lines: ``` error: ld returned 1 exit status [x86_64-pc-linux-gnu/Makefile:112: ../priv/bin/x86_64-pc-linux-gnu/odbcserver] Error 1 or * odbc : ODBC library - link check failed ``` This issue has been discussed [here](https://github.com/asdf-vm/asdf-erlang/issues/286) and also appears on kerl. There are a link error on Kerl auto configure. If you see this, add a export flag `--with-odbc` to KERL-CONFIGURE. Here is an example that skips the java dependency and also sets a specific (and existing) path for unixodbc installed via pacman: ``` export KERL_CONFIGURE_OPTIONS="--without-javac --with-odbc=/var/lib/pacman/local/unixodbc-$(pacman -Q unixodbc | cut -d' ' -f2)" asdf install erlang ``` ### OSX Note, for MacOS 10.15.4 and newer, 22.3.1 is the earliest version that can be installed through `kerl` (and, therefore, `asdf`). Earlier versions will fail to compile. See [this issue](https://github.com/kerl/kerl/issues/335#issuecomment-605487028) for details. Install the build tools `brew install autoconf` Install OpenSSL `brew install openssl@1.1` _Erlang 24.1 and older require OpenSSL 1.1, [read more here](https://github.com/erlang/otp/issues/4577#issuecomment-925962048)_ Note, Erlang 25.1 and newer [support OpenSSL 3.0, even for production use.](https://github.com/erlang/otp/releases/tag/OTP-25.1) If you want to build Erlang with openssl@3.0, install it by `brew install openssl` For building with wxWidgets (start observer or debugger!). Note that you may need to select the right `wx-config` before installing Erlang. `brew install wxwidgets` For building documentation and elixir reference builds: `brew install libxslt fop` #### Dealing with OpenSSL issues on macOS You may encounter an SSL error with an output along these lines: ``` crypto : No usable OpenSSL found ssh : No usable OpenSSL found ssl : No usable OpenSSL found ``` This issue has been documented [on `kerl`](https://github.com/kerl/kerl/issues/320). If you see this error, you can use the [`--with-ssl`](https://github.com/asdf-vm/asdf-erlang/issues/82#issuecomment-415930974) flag with a path before installing Erlang. Here is an example that skips the java dependency and also sets a specific (and existing) path for [OpenSSL](https://github.com/kerl/kerl#kerl-and-openssl) installed via brew on macOS. ``` export KERL_CONFIGURE_OPTIONS="--without-javac --with-ssl=$(brew --prefix openssl@1.1)" asdf install erlang ``` ### CentOS & Fedora These steps assume a most recent build of CentOS (currently tested on CentOS 7.5 x64 & Fedora 28 x64) Install the build tools `sudo yum install -y git gcc g++ automake autoconf` Needed for terminal handling `sudo yum install -y ncurses-devel` For building with wxWidgets (start observer or debugger!). Note that you may need to select the right `wx-config` before installing Erlang. `sudo yum install -y wxGTK-devel wxBase` For building ssl `sudo yum install -y openssl-devel` For jinterface `sudo yum install -y java-1.8.0-openjdk-devel` ODBC support `sudo yum install -y libiodbc unixODBC-devel.x86_64 erlang-odbc.x86_64` For the documentation to be built `sudo yum install -y libxslt fop` ### Solus Install the build tools ```bash sudo eopkg it -c system.devel ``` For building with wxWidgets (start observer or debugger!). Note that you may need to select the right `wx-config` before installing Erlang. ```bash sudo eopkg install wxwidgets-devel libx11-devel mesalib-devel libglu-devel fop ``` For ODBC support ```bash sudo eopkg install unixodbc-devel ``` For jinterface ```bash sudo eopkg install openjdk-8 openjdk-8-devel ``` If you want to install all of the above ```bash # Install build tools sudo eopkg it -c system.devel sudo eopkg install wxwidgets-devel libx11-devel mesalib-devel libglu-devel fop unixodbc-devel openjdk-8 openjdk-8-devel ``` #### OpenJDK issues on Solus I ran into an issue where `javac` wasn't a recognized command in the terminal despite having installed `openjdk-8` and `openjdk-8-devel`. Turns out it wasn't added to `PATH` by default. So simply add it to `PATH` like so: ```bash # In ~/.bashrc add these to add Java to PATH JAVA_HOME=/usr/lib64/openjdk-8 PATH=$PATH:$JAVA_HOME/bin # In terminal source ~/.bashrc ``` ### openSUSE Tumbleweed Even after you have installed the dependencies below, the Erlang installer will warn that g++ and openssl-devel appear missing. This is safe to ignore. The basic stuff to get Erlang to compile: ``` sudo zypper install unzip make automake autoconf gcc-c++ ncurses-devel ``` For crypto, ssh, and others (you probably want this): ``` sudo zypper install libssh-devel libopenssl-devel ``` For wx GUIs (observer, debugger, etc): ``` sudo zypper install wxGTK3-3_2-devel ``` To build documentation: ``` sudo zypper install fop libxml2-tools libxslt-tools ``` For ODBC support: ``` sudo zypper install unixODBC-devel ``` For jinterface: ``` sudo zypper install java-1_8_0-openjdk-devel ``` ## Getting Erlang documentation Erlang may come with documentation included (as man pages, pdfs and html files, or even embedded documentation (via `c:h` function)). For man pages this allows typing `erl -man ets` to get info on `ets` module. For embedded documentation (on [OTP 23\+](https://www.erlang.org/downloads/23)): - In Erlang's `erl`: via [`c:h/1,2,3`](https://erlang.org/doc/man/c.html#h/1) and [`c:ht/1,2,3`](https://erlang.org/doc/man/c.html#ht/1) for types - In Elixir's `iex` (Elixir 1.7+): via [`h/1`](https://hexdocs.pm/iex/IEx.Helpers.html#h/1) and [`t/1`](https://hexdocs.pm/iex/IEx.Helpers.html#t/1) for types `asdf-erlang` uses kerl for builds, and [kerl](https://github.com/kerl/kerl) is capable of building the docs for specified version of Erlang in required formats. For kerl to be able to build Erlang documentation two requirements have to be met: 1. `KERL_BUILD_DOCS` environment variable has to be set to value `yes` 2. Additional dependencies have to be installed. For detailed list of dependencies for your OS please refer to the specific section above Additionally, HTML and Man formats can be ignored entirely: - `KERL_INSTALL_HTMLDOCS` set to `no` to not install HTML docs - `KERL_INSTALL_MANPAGES` set to `no` to skip Man pages. By default, docs in both of these formats are installed if `KERL_BUILD_DOCS` is set. *It may be a good idea to disable those formats to **save space***, since **docs can easily take around 200MB** in addition to 100MB of base installation, yet to *still have docs inside shell*. **Note:** Environment variable has to be set before `asdf install erlang ` is executed, to take effect. ### Setting the environment variable in bash Type: `export KERL_BUILD_DOCS=yes` to create `KERL_BUILD_DOCS` environment variable and set it to `true`. Repeat the same for `KERL_INSTALL_HTMLDOCS` `KERL_INSTALL_MANPAGES` if required (see above). This line could be added to your `.bashrc` in case you want `KERL_BUILD_DOCS` to be set for future (future installations of Erlang). To remove environment variable: `unset KERL_BUILD_DOCS`. ### Setting the environment variable in fish shell Type: `set -xg KERL_BUILD_DOCS yes` to set environment variable. Repeat the same for `KERL_INSTALL_HTMLDOCS` `KERL_INSTALL_MANPAGES` if required (see above). In case you want it to be persisted between sessions (machine reboots - for example for future installations) type `set -xU KERL_BUILD_DOCS yes`. To remove environment variable type: `set -e KERL_BUILD_DOCS`. ### Use a specific version of kerl Overriding the default kerl version shouldn't ever be necessary, but if you want to you a specific version of kerl you can set: ```shell export ASDF_KERL_VERSION="2.1.1" ``` ================================================ FILE: bin/install ================================================ #!/usr/bin/env bash # Unoffical Bash "strict mode" # http://redsymbol.net/articles/unofficial-bash-strict-mode/ set -euo pipefail #ORIGINAL_IFS=$IFS IFS=$'\t\n' # Stricter IFS settings # shellcheck source=lib/utils.sh source "$(dirname "$0")/../lib/utils.sh" install_erlang() { ensure_kerl_setup local build_name install_dependency_checks ensure_kerl_config_opts set_unixodbc_opt set_ssl_opt add_openjdk_to_path ensure_ulimit echo "[asdf-erlang] 📦 Building with $(env | grep KERL_CONFIGURE_OPTIONS)" build_name="asdf_$ASDF_INSTALL_VERSION" export MAKEFLAGS="-j$ASDF_CONCURRENCY" if $(kerl_path) list installations | grep -q "$build_name"; then echo "[asdf-erlang] 🧹 Cleanup kerl installation $build_name" $(kerl_path) delete installation "$build_name" || true else echo "[asdf-erlang] ❄️ No kerl installation to cleanup for $build_name" fi if $(kerl_path) list builds | grep -q "$build_name"; then echo "[asdf-erlang] 🧹 Cleanup kerl build $build_name" $(kerl_path) delete build "$build_name" || true else echo "[asdf-erlang] ❄️ No kerl build to cleanup for $build_name" fi if [ "$ASDF_INSTALL_TYPE" = "ref" ]; then $(kerl_path) build git "${OTP_GITHUB_URL:-https://github.com/erlang/otp.git}" "$ASDF_INSTALL_VERSION" "$build_name" else $(kerl_path) build "$ASDF_INSTALL_VERSION" "$build_name" fi # We hide all output from this command so the # "You can activate this installation running the following command:" # that doesn't apply is hidden echo "👷🏼 kerl install $build_name $ASDF_INSTALL_PATH" $(kerl_path) install "$build_name" "$ASDF_INSTALL_PATH" >/dev/null 2>&1 echo "🧹 Cleanup kerl build $build_name" $(kerl_path) cleanup "$build_name" echo "🔗 Linking app executables $ASDF_INSTALL_PATH" link_app_executables "$ASDF_INSTALL_PATH" cleanup_custom_env_vars echo "👍 Installed erlang ${ASDF_INSTALL_VERSION}" } link_app_executables() { local install_path=$1 # Link other executables to the bin directory so that asdf shims are created for them cd "$install_path/bin" # ln call may fail if multiple executables are found with the same name, so # we loop over all files matching these patterns, and symlink only if # file with same name does not already exist in "$install_path/bin" for file in ../lib/*/bin/* ../lib/*/priv/bin/*; do bin_name="$(basename "$file")" if [ ! -e "./$bin_name" ]; then ln -s "$file" . fi done } install_dependency_checks() { if [[ "$OSTYPE" == "darwin"* ]]; then installed_packages=() for package in fop openssl unixodbc openjdk wxmac; do if brew list --versions "$package" >/dev/null 2>&1; then installed_packages+=("$package") else if [ "$package" = "wxmac" ]; then echo "[asdf-erlang] ⚠️ Warning: $package is optional and not installed. You can install it using 'brew install --build-from-source wxmac'." echo "[asdf-erlang] ⚠️ Note: wxmac is required for building Erlang/OTP with a working :observer" else echo "[asdf-erlang] ⚠️ Warning: $package is optional and not installed. Please install it using 'brew install $package'." fi fi done fi } ensure_kerl_config_opts() { if [[ -z "${KERL_CONFIGURE_OPTIONS:-}" ]]; then export KERL_CONFIGURE_OPTIONS="" fi } set_unixodbc_opt() { if [[ "$OSTYPE" == "darwin"* ]]; then # If no unixodbc is installed, then skip. if ! brew --prefix unixodbc >/dev/null 2>&1; then return fi if [[ ! "$KERL_CONFIGURE_OPTIONS" =~ unixodbc ]]; then local kerl_unixodbc_opt kerl_unixodbc_opt=" --with-odbc=$(brew --prefix unixodbc)" export KERL_CONFIGURE_OPTIONS+=" $kerl_unixodbc_opt" echo "[asdf-erlang] 🛟 Added unixodbc to KERL_CONFIGURE_OPTIONS: $kerl_unixodbc_opt" fi # If CC not set, then set CC. # ELSE add the unixodbc include path to CC. if [ -z "${CC:-}" ]; then CC="/usr/bin/clang -I$(brew --prefix unixodbc)/include" export CC echo "[asdf-erlang] 🛟 No CC found. Setting CC to: $CC" CC_SET_BY_ASDF_ERLANG=1 # so that we can clear it later. elif [[ "$CC" != *unixodbc* ]]; then CC+=" -I$(brew --prefix unixodbc)/include" export CC echo "[asdf-erlang] 🛟 Added unixodbc include path to CC: $CC" fi # If LDFLAGS not set, then set LDFLAGS. # ELSE add the unixodbc library path to LDFLAGS. if [ -z "${LDFLAGS:-}" ]; then LDFLAGS="-L$(brew --prefix unixodbc)/lib" export LDFLAGS echo "[asdf-erlang] 🛟 No LDFLAGS found. Setting LDFLAGS to: $LDFLAGS" LDFLAGS_SET_BY_ASDF_ERLANG=1 # so that we can clear it later. elif [[ "$LDFLAGS" != *unixodbc* ]]; then local unixodbc_lib_path unixodbc_lib_path="$(brew --prefix unixodbc)/lib" export LDFLAGS+=" -L$unixodbc_lib_path" echo "[asdf-erlang] 🛟 Added $unixodbc_lib_path to LDFLAGS env var" fi fi } add_openjdk_to_path() { if [[ "$OSTYPE" == "darwin"* ]]; then if ! brew --prefix openjdk >/dev/null 2>&1; then return fi local openjdk_path openjdk_path="$(brew --prefix openjdk)" if [[ ":$PATH:" != *":$openjdk_path/bin:"* ]]; then export PATH="$openjdk_path/bin:$PATH" echo "[asdf-erlang] 🛟 OpenJDK has been added to PATH for this terminal session: $openjdk_path/bin" echo "[asdf-erlang] Please ensure this is included in your shell's dot files (.zshrc, .bashrc, etc.)" fi fi } ensure_ulimit() { if [ "$(ulimit -n)" -lt 1000 ]; then ulimit -n 65536 echo "[asdf-erlang] 🛟 ulimit was low. It has been set to 65536 for this terminal session" fi } set_ssl_opt() { if [[ "$OSTYPE" == "darwin"* ]]; then # If this is a ref install, then we don't need to set the ssl option. # Reason: Don't want to handle that for now. if [[ "$ASDF_INSTALL_TYPE" == "ref" ]]; then echo "[asdf-erlang] ⚠️ Skipping setting --with-ssl in KERL_CONFIGURE_OPTIONS for ref install" return fi otp_major=$(echo "$ASDF_INSTALL_VERSION" | cut -d. -f1) otp_minor=$(echo "$ASDF_INSTALL_VERSION" | cut -d. -f2) # Copied IF condition check from the kerl binary to match their version check. # We only have to fix/handle newer erlang+openssl versions because of kerl looking for openssl@3.0 instead of openssl#3. # The erlang version that use openssl 1.1 should be fine (or as is). if [ "$otp_major" = 'git' ] || [ "$otp_major" -lt 25 ] || { [ "$otp_major" -eq 25 ] && [ "$otp_minor" -lt 1 ]; }; then echo "[asdf-erlang] ⚠️ Skipping setting --with-ssl in KERL_CONFIGURE_OPTIONS. This erlang version uses openssl v1.x" return fi # Only set the ssl option for newer erlang versions that use openssl@3. if ! brew --prefix openssl@3 >/dev/null 2>&1; then echo "[asdf-erlang] ⚠️ Skipping setting --with-ssl in KERL_CONFIGURE_OPTIONS. brew prefix path for openssl@3 not found." return fi # If openssl is not already in KERL_CONFIGURE_OPTIONS, then add it. if [[ ! "$KERL_CONFIGURE_OPTIONS" =~ openssl ]]; then local kerl_ssl_opt kerl_ssl_opt=" --with-ssl=$(brew --prefix openssl@3)" export KERL_CONFIGURE_OPTIONS+=" $kerl_ssl_opt" echo "[asdf-erlang] 🛟 Added openssl to KERL_CONFIGURE_OPTIONS: $kerl_ssl_opt" fi fi } cleanup_custom_env_vars() { if [[ "${LDFLAGS_SET_BY_ASDF_ERLANG:-}" == "1" ]]; then unset LDFLAGS fi if [[ "${CC_SET_BY_ASDF_ERLANG:-}" == "1" ]]; then unset CC fi } install_erlang ================================================ FILE: bin/list-all ================================================ #!/usr/bin/env bash # Unoffical Bash "strict mode" # http://redsymbol.net/articles/unofficial-bash-strict-mode/ set -euo pipefail #ORIGINAL_IFS=$IFS IFS=$'\t\n' # Stricter IFS settings # shellcheck source=lib/utils.sh source "$(dirname "$0")/../lib/utils.sh" list_all() { ensure_kerl_setup "$(kerl_path)" list releases all | tr '\n' ' ' } list_all ================================================ FILE: bin/uninstall ================================================ #!/usr/bin/env bash # Unoffical Bash "strict mode" # http://redsymbol.net/articles/unofficial-bash-strict-mode/ set -euo pipefail #ORIGINAL_IFS=$IFS IFS=$'\t\n' # Stricter IFS settings # shellcheck source=lib/utils.sh source "$(dirname "$0")/../lib/utils.sh" ensure_kerl_setup if [ "$ASDF_INSTALL_VERSION" == "" ]; then echo "Please provide the version you want to uninstall" exit 1 fi # Remove the installation and build if the installation was done by kerl if $(kerl_path) list installations | grep "$ASDF_INSTALL_PATH"; then $(kerl_path) delete build "asdf_$ASDF_INSTALL_VERSION" || true $(kerl_path) delete installation "$ASDF_INSTALL_PATH" || true fi # Finally make sure the directory is actually removed regardless of what the # previous kerl commands did rm -rf "$ASDF_INSTALL_PATH" || true ================================================ FILE: lib/utils.sh ================================================ export KERL_VERSION="${ASDF_KERL_VERSION:-4.4.0}" handle_failure() { function=$1 error_message=$2 $function && exit_code=$? || exit_code=$? if [ "$exit_code" -ne 0 ]; then printf "%s\\n" "$error_message" 1>&2 fi return "$exit_code" } ensure_kerl_setup() { handle_failure set_kerl_env 'Failed to set kerl environment' handle_failure ensure_kerl_installed 'Failed to install kerl' handle_failure update_available_versions 'Failed to update available versions' } ensure_kerl_installed() { if [ ! -f "$(kerl_path)" ]; then download_kerl elif [ "$("$(kerl_path)" version)" != "$KERL_VERSION" ]; then # If the kerl file already exists and the version does not match, remove # it and download the correct version rm "$(kerl_path)" download_kerl fi } download_kerl() { # Print to stderr so asdf doesn't assume this string is a list of versions printf "Downloading kerl...\\n" >&2 local kerl_url="https://raw.githubusercontent.com/kerl/kerl/${KERL_VERSION}/kerl" curl -Lo "$(kerl_path)" "$kerl_url" chmod +x "$(kerl_path)" } kerl_path() { printf "%s\\n" "$(dirname "$(dirname "$0")")/kerl" } set_kerl_env() { local kerl_home kerl_home="$(dirname "$(dirname "$0")")/kerl-home" mkdir -p "$kerl_home" export KERL_BASE_DIR="$kerl_home" export KERL_BUILD_BACKEND="git" export KERL_CONFIG="$kerl_home/.kerlrc" export KERL_DOWNLOAD_DIR="${ASDF_DOWNLOAD_PATH:-}" } update_available_versions() { "$(kerl_path)" update releases >/dev/null } ================================================ FILE: scripts/shellcheck.bash ================================================ #!/usr/bin/env bash exec shellcheck -s bash -x bin/* -x lib/* ================================================ FILE: scripts/shfmt.bash ================================================ #!/usr/bin/env bash exec shfmt -d bin/* lib/*