Skip to content

Instantly share code, notes, and snippets.

@maxlapshin
Last active December 17, 2015 00:09
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save maxlapshin/5518458 to your computer and use it in GitHub Desktop.
Save maxlapshin/5518458 to your computer and use it in GitHub Desktop.
Build and clean small server erlang distribution without useless libraries
#!/bin/bash
[ -f /usr/bin/gcc ] || (apt-get update && apt-get install -y build-essential libncurses-dev libssl-dev chrpath)
#wget http://www.hpl.hp.com/research/linux/atomic_ops/download/libatomic_ops-7.2d.tar.gz
#tar zxf libatomic_ops-7.2d.tar.gz
#cd libatomic_ops-7.2/
#./configure --prefix=/opt/flussonic
#make install
#cd ..
[ -f /var/cache/apt/archives/otp_src_R16B.tar.gz ] || (cd /var/cache/apt/archives/ && wget http://www.erlang.org/download/otp_src_R16B.tar.gz)
if [ ! -f otp_src_R16B/bin/*/beam.smp ] ; then
tar zxf /var/cache/apt/archives/otp_src_R16B.tar.gz
cd otp_src_R16B/
./configure --prefix=/opt/flussonic --enable-smp-support --enable-kernel-poll --disable-hipe --with-ssl #--with-libatomic_ops=/opt/flussonic
make install
else
cd otp_src_R16B/
make install
fi
cd /opt/flussonic
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
cd lib/erlang
rm -rf erts-*/lib erts-*/include erts-*/doc erts-*/man erts-*/src
rm -rf Install usr misc bin/typer bin/ct_run bin/dialyzer
(cd erts-*/bin; rm beam ct_run dialyzer typer; strip *)
cd lib
rm -rf wx-* tv-* snmp-* orber-* observer-* megaco-* ic-* gs-* diameter-* asn1-* common_test-* cos* dialyzer-*
rm -rf et-* reltool-* edoc-* erl_docgen-* appmon-* toolbar-* typer-* eldap-* test_server-* erl_interface-*
rm -rf mnesia-* hipe-* ssh-* debugger-* pman-* parsetools-* percept-* runtime_tools-* 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*
rm -f inets-*/ebin/ftp* inets-*/ebin/http* inets-*/ebin/mod* inets-*/ebin/tftp*
if [ -f /usr/lib/libcrypto.so.0.9.8 ] ; then
cp /usr/lib/libcrypto.so.0.9.8 /opt/flussonic/lib/
chrpath -r /opt/flussonic/lib crypto-*/priv/lib/crypto.so
fi
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