#!/bin/bash
set -euo pipefail

BUILD_DIR=$1
CACHE_DIR=$2
export BUILDPACK_DIR=`dirname $(readlink -f ${BASH_SOURCE%/*})`
export DEPS_DIR="$BUILD_DIR/.cloudfoundry"
mkdir -p "$DEPS_DIR/0"
mkdir -p "$BUILD_DIR/.profile.d"
echo "export DEPS_DIR=\$HOME/.cloudfoundry" > "$BUILD_DIR/.profile.d/0000_set-deps-dir.sh"

$BUILDPACK_DIR/bin/supply "$BUILD_DIR" "$CACHE_DIR" "$DEPS_DIR" 0
$BUILDPACK_DIR/bin/finalize "$BUILD_DIR" "$CACHE_DIR" "$DEPS_DIR" 0
