Skip to content

Instantly share code, notes, and snippets.

@maxlapshin
Created March 21, 2015 09:28
Show Gist options
  • Save maxlapshin/903c9109c7f25b9890e3 to your computer and use it in GitHub Desktop.
Save maxlapshin/903c9109c7f25b9890e3 to your computer and use it in GitHub Desktop.
prepare_erlang.sh
#!/bin/bash
ERLANG=17.4
SQLITE=amalgamation-3071700
cd /root
[ -f /usr/bin/gcc ] || (apt-get update && apt-get install -y build-essential)
[ -f /usr/bin/chrpath ] || apt-get -y install chrpath
[ -f /usr/bin/unzip ] || apt-get -y install unzip
[ -f /usr/include/ncurses.h ] || apt-get install -y libncurses-dev
# [ -f /usr/include/openssl/ssl.h ] || apt-get install -y libssl-dev
# [ -f /usr/bin/stap ] || apt-get install -y systemtap
[ -f /var/cache/apt/archives/otp_src_${ERLANG}.tar.gz ] || (cd /var/cache/apt/archives/ && wget http://www.erlang.org/download/otp_src_${ERLANG}.tar.gz)
[ -f /var/cache/apt/archives/openssl-1.0.2.tar.gz ] || (cd /var/cache/apt/archives && wget https://www.openssl.org/source/openssl-1.0.2.tar.gz)
if [ ! -f /opt/flussonic/lib/libcrypto.so.1.0.0 ] ; then
if [ ! -f openssl-1.0.2/libssl.a ] ; then
tar zxf /var/cache/apt/archives/openssl-1.0.2.tar.gz
cd openssl-1.0.2/
./Configure --prefix=/opt/flussonic linux-x86_64 shared -fPIC
make -j 8
cd ..
fi
cd openssl-1.0.2/
make install
rm /opt/flussonic/lib/libcrypto.a /opt/flussonic/lib/libssl.a
rm -rf /opt/flussonic/ssl
cd ..
fi
if [ ! -f otp_src_${ERLANG}/bin/*/beam.smp ] ; then
tar zxf /var/cache/apt/archives/otp_src_${ERLANG}.tar.gz
cd otp_src_${ERLANG}/
CFLAGS=-I/opt/flussonic/include LDFLAGS=-L/opt/flussonic/lib ./configure --prefix=/opt/flussonic --enable-smp-support \
--enable-kernel-poll --disable-hipe --with-ssl=/opt/flussonic --with-ssl-incl=/opt/flussonic/include \
--with-ssl-rpath=/opt/flussonic/lib --without-java --enable-dirty-schedulers
#--with-dynamic-trace=systemtap
make install
cd ..
else
cd otp_src_${ERLANG}/
make install
cd ..
fi
if false && [ -f /vagrant/deps/sqlite3/rebar.config ]; then
[ -f /var/cache/apt/archives/sqlite-${SQLITE}.zip ] || (cd /var/cache/apt/archives && wget http://www.sqlite.org/2013/sqlite-${SQLITE}.zip )
if [ ! -d sqlite-${SQLITE} ] ; then
unzip /var/cache/apt/archives/sqlite-${SQLITE}.zip
fi
rm -rf sqlite3
cp -r /vagrant/deps/sqlite3 .
cp -f sqlite-${SQLITE}/sqlite3* sqlite3/c_src/
cd sqlite3
cat > rebar.config <<-EOF
{port_envs, [{"DRV_CFLAGS", "\$DRV_CFLAGS -Wall -Wextra -Wno-unused-parameter -Ic_src -I/opt/flussonic/lib/erlang/erts-6.3/include/"}]}.
EOF
export PATH=$PATH:/opt/flussonic/bin
./rebar clean
./rebar compile
strip priv/sqlite3_drv.so
mkdir -p /opt/flussonic/deps/sqlite3/priv
cp priv/sqlite3_drv.so /opt/flussonic/deps/sqlite3/priv/
cd ..
fi
cd /opt/flussonic || exit 1
rm -rf include
rm -rf bin/c_rehash bin/openssl
rm -rf lib/libssl.so lib/libssl.so.1.0.0 lib/engines
rm -rf lib/libatomic_ops_gpl.a lib/libatomic_ops.a share include
rm -rf lib/pkgconfig
mv lib/erlang/lib/erl_interface-*/bin/erl_call bin/
strip bin/erl_call
mv lib/erlang/usr/lib/lib* lib/
mv lib/erlang/usr/include/* include/
cd lib/erlang
rm -rf erts-*/lib erts-*/doc erts-*/man erts-*/src # erts-*/include/internal # erts-*/include
rm -rf Install usr misc bin/typer bin/ct_run bin/dialyzer
(cd erts-*/bin; rm beam ct_run dialyzer typer; strip *; ln -s beam.smp beam)
cd lib
rm -rf wx-* tv-* snmp-* orber-* megaco-* ic-* gs-* diameter-* common_test-* cos* dialyzer-*
rm -rf et-* reltool-* edoc-* erl_docgen-* appmon-* toolbar-* typer-* eldap-* test_server-*
rm -rf mnesia-* hipe-* ssh-* debugger-* pman-* parsetools-* percept-* webtool-* otp_mibs-*
#inets-*
rm -rf */src */examples
rm -rf public_key-*/asn1
rm -rf crypto-*/priv/obj
rm -rf inets-*/examples tools-*/emacs
rm -rf tools-*/bin tools-*/ebin/c* tools-*/ebin/xref*
cd observer-*
mkdir bkp
mv ebin/observer.app ebin/etop.beam ebin/etop_txt.beam bkp/
rm -rf priv include ebin
mv bkp ebin
cd ..
rm -rf tools-*/c_src
cd inets-*
mkdir bkp
mv ebin/http_util.beam ebin/httpd.beam ebin/httpd_util.beam ebin/http_uri.beam ebin/inets.app ebin/inets_regexp.beam \
ebin/ftp.beam ebin/ftp_progress.beam ebin/ftp_response.beam ebin/inets_trace.beam bkp/
rm -rf priv include ebin
mv bkp ebin
cd ..
rm -rf erl_interface*/lib
cd xmerl-*
mv ebin/xmerl.app ebin/xmerl_ucs.beam .
rm -rf ebin/*
mv xmerl* ebin/
cd ..
cd /opt/flussonic
tar zcf /vagrant/erlang_amd64.tgz *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment