Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 75 lines (59 sloc) 1.75 KB
#!/bin/bash
##
# usage: bin/compile <build-dir> <cache-dir>
bpdir=$(cd $(dirname $(dirname $0)); pwd)
mkdir -p "$1" "$2"
build=$(cd "$1/" && pwd)
test -z ${build} && exit
cache=$(cd "$2/" && pwd)
test -z ${cache} && exit
DEFAULT_OTP_VERSION="master"
if [ -f ${build}/.preferred_otp_version ]; then
OTP_VERSION=$(cat ${build}/.preferred_otp_version)
fi
ver=${OTP_VERSION:=${DEFAULT_OTP_VERSION}}
tarball=${ver}.tgz
OTP_TARBALL_URL="https://s3.amazonaws.com/heroku-buildpack-erlang/${tarball}"
MAKEFILE_URL="https://s3.amazonaws.com/heroku-buildpack-erlang-dialyzer/Makefile"
ERLROOT=${build}/otp
echo "-----> Using Erlang/OTP $ver"
(
set -e
# Already cached?
test -f ${cache}/${tarball} && exit
rm -rf ${cache}/* # be sure not to build up cruft
cd ${cache}
echo "-------> Fetching Erlang/OTP $ver"
curl -sO ${OTP_TARBALL_URL} || exit 1
)
echo "-------> Unpacking Erlang/OTP $ver"
mkdir -p ${ERLROOT}
tar zxf ${cache}/${tarball} -C ${ERLROOT} --strip-components=2
echo "-------> Installing Erlang/OTP $ver"
ln -s ${ERLROOT} /app/otp
${ERLROOT}/Install -minimal /app/otp
PATH=/app/otp/bin:$PATH
export PATH
cd $build
if [ ! -e "rebar" ]; then
echo "-----> Installing Rebar from buildpack"
cp ${bpdir}/opt/rebar ./
fi
if [ ! -e "Makefile" ]; then
echo "-----> Copying over Makefile"
cp ${bpdir}/opt/Makefile ./
fi
cp ${bpdir}/opt/Procfile ./
cp ${bpdir}/opt/serve.rb ./
cp ${bpdir}/opt/Gemfile ./
cp ${bpdir}/opt/Gemfile.lock ./
echo "-----> Building and running Dialyzer"
unset GIT_DIR
mkdir dialyzed
make 2>&1 | sed -u 's/^/ /'
echo "<html><body><pre>" > dialyzed/output.html
date >> dialyzed/output.html
make dialyzer >> dialyzed/output.html
echo "</pre></body></html>" >> dialyzed/output.html
echo "-----> Build succeeded"
exit 0