Last active
May 29, 2021 05:37
-
-
Save RudolfMan/f2fb20b068f2a3dc3150a6261dc9d05a to your computer and use it in GitHub Desktop.
Builds and installs erlang and elixir from sources for CentOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [[ -z $1 ]] || [[ -z $2 ]]; then | |
echo """ | |
Usage: ./build_elixir.sh ELIXIR_VERSION OTP_VERSION | |
""" | |
exit 1 | |
fi | |
set -xe | |
ELIXIR_VERSION="v$1" | |
OTP_VERSION="$2" | |
# install erlang | |
OTP_DOWNLOAD_URL="https://github.com/erlang/otp/archive/OTP-${OTP_VERSION}.tar.gz" | |
curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL" | |
buildDeps="gcc gcc-c++ make automake autoconf ncurses-devel unixODBC-devel openssl-devel kernel-devel" | |
# required to install pax-utils to use scanelf later | |
OS_VERSION=$(cat /etc/os-release | awk 'match($0, /^VERSION_ID/) {print substr($0, 13, 1)}') | |
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-${OS_VERSION}.noarch.rpm | |
yum -y update | |
yum -y install $buildDeps | |
export ERL_TOP="/usr/src/otp_src_${OTP_VERSION%%@*}" | |
mkdir -vp $ERL_TOP | |
tar -xzf otp-src.tar.gz -C $ERL_TOP --strip-components=1 | |
rm otp-src.tar.gz | |
pushd $ERL_TOP | |
./otp_build autoconf | |
./configure \ | |
--without-javac \ | |
--without-wx \ | |
--without-debugger \ | |
--without-observer \ | |
--without-jinterface \ | |
--without-cosEvent\ | |
--without-cosEventDomain \ | |
--without-cosFileTransfer \ | |
--without-cosNotification \ | |
--without-cosProperty \ | |
--without-cosTime \ | |
--without-cosTransactions \ | |
--without-et \ | |
--without-gs \ | |
--without-ic \ | |
--without-megaco \ | |
--without-orber \ | |
--without-percept \ | |
--without-typer \ | |
--with-ssl \ | |
--enable-threads \ | |
--enable-dirty-schedulers \ | |
--disable-hipe | |
make -j$(getconf _NPROCESSORS_ONLN) | |
make install | |
popd | |
rm -rf $ERL_TOP | |
find /usr/local -regex '/usr/local/lib/erlang/\(lib/\|erts-\).*/\(man\|doc\|obj\|c_src\|emacs\|info\|examples\)' | xargs rm -rf | |
find /usr/local -name src | xargs -r find | grep -v '\.hrl$' | xargs rm -v || true | |
find /usr/local -name src | xargs -r find | xargs rmdir -vp || true | |
scanelf --nobanner -E ET_EXEC -BF '%F' --recursive /usr/local | xargs -r strip --strip-all | |
scanelf --nobanner -E ET_DYN -BF '%F' --recursive /usr/local | xargs -r strip --strip-unneeded | |
runDeps="$( \ | |
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ | |
| tr ',' '\n' \ | |
| sort -u \ | |
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print $1 }' \ | |
)" | |
# install elixir | |
export LANG=C.UTF-8 | |
ELIXIR_DOWNLOAD_URL="https://github.com/elixir-lang/elixir/archive/${ELIXIR_VERSION}.tar.gz" | |
curl -fSL -o elixir-src.tar.gz $ELIXIR_DOWNLOAD_URL | |
mkdir -p /usr/local/src/elixir | |
tar -xzC /usr/local/src/elixir --strip-components=1 -f elixir-src.tar.gz | |
rm elixir-src.tar.gz | |
cd /usr/local/src/elixir | |
make install clean | |
yum -y remove $buildDeps | |
yum -y install $runDeps lksctp-tools openssh-clients git | |
rm -rf /var/cache/yum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment