-
-
Save dch/3bf488dd43c17e929e10 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
ERLANG=18.0 | |
SQLITE=amalgamation-3071700 | |
cd /root | |
SSLV=1.0.1o | |
[ -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-${SSLV}.tar.gz ] || (cd /var/cache/apt/archives && wget https://www.openssl.org/source/openssl-${SSLV}.tar.gz) | |
if [ ! -f /opt/flussonic/lib/libcrypto.so.1.0.0 ] ; then | |
if [ ! -f openssl-${SSLV}/libssl.a ] ; then | |
SSL_ARCH=linux-x86_64 | |
if [ -n "`uname -a |grep arm`" ] ; then | |
SSL_ARCH=linux-armv4 | |
fi | |
tar zxf /var/cache/apt/archives/openssl-${SSLV}.tar.gz | |
cd openssl-${SSLV}/ | |
./Configure --prefix=/opt/flussonic ${SSL_ARCH} shared -fPIC | |
make -j 8 | |
cd .. | |
fi | |
cd openssl-${SSLV}/ | |
make install_sw | |
rm /opt/flussonic/lib/libcrypto.a /opt/flussonic/lib/libssl.a | |
rm -rf /opt/flussonic/ssl | |
rm -rf /opt/flussonic/lib/engines | |
# strip /opt/flussonic/lib/lib* | |
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}/ | |
sed -i.bkp 's/pthread_setname_np/pthread_setname_none/' erts/configure | |
sed -i.bkp 's/pthread_setname_np/pthread_setname_none/' erts/lib_src/pthread/ethread.c | |
sed -i.bkp 's/pthread_setname_np/pthread_setname_none/' aclocal.m4 | |
sed -i.bkp 's/pthread_setname_np/pthread_setname_none/' erts/aclocal.m4 | |
CFLAGS="-I/opt/flussonic/include -O2" 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 | |
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 .. | |
ERL_ARCH=amd64 | |
if [ -n "`uname -a |grep arm`" ] ; then | |
ERL_ARCH=armhf | |
fi | |
cd /opt/flussonic | |
tar zcf /vagrant/erlang_${ERL_ARCH}.tgz * | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment