Skip to content

Instantly share code, notes, and snippets.

@seancribbs
Last active December 21, 2015 00:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seancribbs/6223390 to your computer and use it in GitHub Desktop.
Save seancribbs/6223390 to your computer and use it in GitHub Desktop.
export PATH="$HOME/erlang/current/bin:$PATH"
erlcur() {
DIR=`ls -lr $HOME/erlang | awk '/current/ { print $NF }'`
echo -n ${DIR##*/}
}
erlsw() {
TARGET=`find $HOME/erlang -depth 1 -type d -name "*$1*" | head -1`
if [ -z "$TARGET" ]; then
echo "No release matching $1\!"
if [ -e $HOME/erlang/current ]; then
echo Using `erlcur`
fi
return
fi
ln -nfs $TARGET $HOME/erlang/current
echo Using `erlcur`
}
_erlbuild() {
set -e
RELNAME=$1
shift
EXTRACONFIGS=$@
ORIGDIR=`pwd`
TARBALL="otp_src_$RELNAME.tar.gz"
BUILDDIR="otp_src_$RELNAME"
PREFIX="$HOME/erlang/$RELNAME"
if [[ ! -d "$PREFIX" ]]; then
mkdir -p $HOME/erlang/_builds
cd $HOME/erlang/_builds
if [[ ! -f "$TARBALL" ]]; then
echo -n "Downloading $RELNAME: "
wget --progress=dot:mega https://packages.erlang-solutions.com/erlang/esl-erlang-src/$TARBALL
fi
if [[ ! -d $BUILDDIR ]]; then
echo "Unpacking $RELNAME..."
tar xzf $TARBALL
fi
cd $BUILDDIR
echo "Configuring $RELNAME..."
./configure --prefix=$PREFIX --enable-darwin-64-bit --with-dynamic-trace=dtrace --disable-hipe $EXTRACONFIGS > /dev/null 2>&1
touch lib/wx/SKIP
echo "Building and installing $RELNAME into $PREFIX..."
make all docs install install-docs > /dev/null 2>&1
cd $ORIGDIR
else
echo "$RELNAME is already installed in $PREFIX"
exit 1
fi
}
erlbuild() {
echo "_erlbuild $@" | $SHELL -l
}
erlclean() {
RELNAME=$1
echo "Removing build artifacts for $RELNAME:"
rm -rvf $HOME/erlang/_builds/*$RELNAME*
}
@russelldb
Copy link

Does this pre-suppose a directory set up of ~/elrang/$VERSION? where there is a directory for each version you want to switch to?

@seancribbs
Copy link
Author

Yes.

@dizzyd
Copy link

dizzyd commented Sep 25, 2013

Y no kerl? :)

@seancribbs
Copy link
Author

@dizzyd kerl has caused so many hours of pain and annoyance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment