Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Commit

Permalink
Export env variables into exports so next buildpack can use it
Browse files Browse the repository at this point in the history
  • Loading branch information
Photonios committed Feb 3, 2018
1 parent f2ab8ac commit 632817e
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ S3_BUCKET=${HEROKU_GEO_BUILDBACK_S3_BUCKET:-"cyberdelia-geo-buildpack"}

# Parameters
BUILD_DIR=$1
BP_DIR=$(cd $(dirname ${0:-}); cd ..; pwd)
CACHE_DIR="${2}/${STACK}"

# Setup profile file
PROFILE_PATH="$BUILD_DIR/.profile.d/geo.sh"
mkdir -p $(dirname $PROFILE_PATH)

# Set up exports file
EXPORTS_PATH="$BP_DIR/export"

# Functions
function indent() {
c='s/^/ /'
Expand Down Expand Up @@ -52,6 +56,10 @@ function set-default-env (){
echo "export $1=\${$1:-$2}" >> $PROFILE_PATH
}

function set-export (){
echo "export $1=$2" >> $EXPORTS_PATH
}

# Retrieve versions
GEOS_VERSION=$(manifest_version "geos")
GDAL_VERSION=$(manifest_version "gdal")
Expand Down Expand Up @@ -96,13 +104,18 @@ for dir in $VENDORED_GEOS $VENDORED_GDAL $VENDORED_PROJ; do
done

# App directories
APP_VENDOR="$BUILD_DIR/$TARGET_VENDOR_DIR"

# Setup environment variables
set-env GEOS_LIBRARY_PATH "$APP_VENDOR/lib"
set-env GDAL_LIBRARY_PATH "$APP_VENDOR/lib"
set-env PROJ4_LIBRARY_PATH "$APP_VENDOR/lib"
set-env GDAL_DATA "$APP_VENDOR/share/gdal"
APP_VENDOR_RUNTIME="$\HOME/$TARGET_VENDOR_DIR"
APP_VENDOR_BUILD="$BUILD_DIR/$TARGET_VENDOR_DIR"

# Setup environment variables needed to run the app
set-env GEOS_LIBRARY_PATH "$APP_VENDOR_RUNTIME/lib"
set-env GDAL_LIBRARY_PATH "$APP_VENDOR_RUNTIME/lib"
set-env PROJ4_LIBRARY_PATH "$APP_VENDOR_RUNTIME/lib"
set-env GDAL_DATA "$APP_VENDOR_RUNTIME/share/gdal"
set-default-env LIBRARY_PATH "$APP_VENDOR_RUNTIME/lib"
set-default-env LD_LIBRARY_PATH "$APP_VENDOR_RUNTIME/lib"
set-default-env CPATH "$APP_VENDOR_RUNTIME/include"
set-default-env PATH "$APP_VENDOR_RUNTIME/bin"

# Bundle workaround
mkdir -p $BUILD_DIR/.bundle
Expand All @@ -118,9 +131,15 @@ BUNDLE_WITHOUT: development:test
BUNDLE_DISABLE_SHARED_GEMS: '1'
" > $BUILD_DIR/.bundle/config

set-default-env LIBRARY_PATH "$APP_VENDOR/lib"
set-default-env LD_LIBRARY_PATH "$APP_VENDOR/lib"
set-default-env CPATH "$APP_VENDOR/include"
set-default-env PATH "$APP_VENDOR/bin"
# Set up environment variables needed during the remainder of
# the build process.. These can be read by subsequent buildpacks
set-export GEOS_LIBRARY_PATH "$APP_VENDOR_BUILD/lib"
set-export GDAL_LIBRARY_PATH "$APP_VENDOR_BUILD/lib"
set-export PROJ4_LIBRARY_PATH "$APP_VENDOR_BUILD/lib"
set-export GDAL_DATA "$APP_VENDOR_BUILD/share/gdal"
set-export LIBRARY_PATH "$APP_VENDOR_BUILD/lib"
set-export LD_LIBRARY_PATH "$APP_VENDOR_BUILD/lib"
set-export CPATH "$APP_VENDOR_BUILD/include"
set-export PATH "$APP_VENDOR_BUILD/bin"

echo "-----> Vendoring geo libraries done"

0 comments on commit 632817e

Please sign in to comment.