diff --git a/bin/compile b/bin/compile index 429b507..f361cda 100755 --- a/bin/compile +++ b/bin/compile @@ -21,3 +21,6 @@ source $bp_dir/bin/common.sh # Install node first, as a dependency, then install meteor & build app $bp_dir/bin/compile_node "$1" "$2" $bp_dir/bin/compile_meteor "$1" "$2" + +# Install phantomjs +$bp_dir/bin/install_phantomjs "$1" "$2" \ No newline at end of file diff --git a/bin/compile_meteor b/bin/compile_meteor index f5ae0fb..606b7fe 100755 --- a/bin/compile_meteor +++ b/bin/compile_meteor @@ -41,6 +41,7 @@ fetch_meteor() { head "Unpacking Meteor $METEOR_VERSION" tar -xzf "$PACKAGE" -C "$BUILD_DIR" mv "$BUILD_DIR/.meteor" "$METEOR_HOME" + ln -s "${METEOR_HOME}" "${HOME}/.meteor" # bomb out if it didn't work, eg no net [ ! -x "${METEOR_HOME}/meteor" ] && error "Install failed: No meteor bin found." info "Meteor $METEOR_VERSION is installed" diff --git a/bin/install_phantomjs b/bin/install_phantomjs new file mode 100755 index 0000000..5fac767 --- /dev/null +++ b/bin/install_phantomjs @@ -0,0 +1,34 @@ +#!/bin/sh + +# based on https://github.com/stomita/heroku-buildpack-phantomjs/blob/master/bin/compile + +set -e + +BUILD_DIR=$1 +CACHE_DIR=$2 + +# config +VERSION="1.9.8" + +# Buildpack URL +ARCHIVE_NAME=phantomjs-${VERSION}-linux-x86_64 +FILE_NAME=${ARCHIVE_NAME}.tar.bz2 +BUILDPACK_PHANTOMJS_PACKAGE=https://bitbucket.org/ariya/phantomjs/downloads/${FILE_NAME} + +mkdir -p $CACHE_DIR +if ! [ -e $CACHE_DIR/$FILE_NAME ]; then + echo "-----> Fetching PhantomJS ${VERSION} binaries at ${BUILDPACK_PHANTOMJS_PACKAGE}" + curl $BUILDPACK_PHANTOMJS_PACKAGE -L -s -o $CACHE_DIR/$FILE_NAME +fi + +echo "-----> Extracting PhantomJS ${VERSION} binaries to ${BUILD_DIR}/vendor/phantomjs" +mkdir -p $CACHE_DIR/$ARCHIVE_NAME +mkdir -p $BUILD_DIR/vendor +tar jxf $CACHE_DIR/$FILE_NAME -C $CACHE_DIR +mv $CACHE_DIR/$ARCHIVE_NAME $BUILD_DIR/vendor/phantomjs + +echo "-----> exporting PATH and LIBRARY_PATH" +PROFILE_PATH="$BUILD_DIR/.profile.d/phantomjs.sh" +mkdir -p $(dirname $PROFILE_PATH) +echo 'export PATH="$PATH:$HOME/vendor/phantomjs/bin"' >> $PROFILE_PATH +echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:vendor/phantomjs/lib"' >> $PROFILE_PATH \ No newline at end of file