-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathinstall
executable file
·54 lines (41 loc) · 1.66 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# Unoffical Bash "strict mode"
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\t\n' # Stricter IFS settings
asdf_bin_dir=$(dirname "$0")
# shellcheck source=../lib/utils.sh
source "$asdf_bin_dir/../lib/utils.sh"
install_erlang() {
ensure_kerl_setup
local build_name
build_name="asdf_$ASDF_INSTALL_VERSION"
export MAKEFLAGS="-j$ASDF_CONCURRENCY"
"$KERL_PATH" delete installation "$build_name" || true
"$KERL_PATH" delete build "$build_name" || true
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 filter the output of the install command to hide irrelevant messages:
# "You can activate/leave this installation running the following command"
"$KERL_PATH" install 2>&1 | grep -v 'activate|leave'
"$KERL_PATH" cleanup "$ASDF_INSTALL_VERSION"
link_app_executables "$ASDF_INSTALL_PATH"
}
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_erlang