From 7318eb0ba0a2f082fac267ed3c3ef385e1b26410 Mon Sep 17 00:00:00 2001 From: Swen Kooij Date: Thu, 1 Feb 2018 23:47:24 +0200 Subject: [PATCH 1/2] Remove hard-coded references to /app --- bin/compile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/compile b/bin/compile index fc376f8..1809539 100755 --- a/bin/compile +++ b/bin/compile @@ -97,7 +97,7 @@ for dir in $VENDORED_GEOS $VENDORED_GDAL $VENDORED_PROJ; do done # App directories -APP_VENDOR="/app/$TARGET_VENDOR_DIR" +APP_VENDOR="$BUILD_DIR/$TARGET_VENDOR_DIR" # Setup environment variables set-env GEOS_LIBRARY_PATH "$APP_VENDOR/lib" From 31509b3dd9a665f645cf4b36f94c47a5476c9ecd Mon Sep 17 00:00:00 2001 From: Swen Kooij Date: Fri, 2 Feb 2018 13:17:21 +0200 Subject: [PATCH 2/2] Export env variables into exports so next buildpack can use it --- bin/compile | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/bin/compile b/bin/compile index 1809539..19f7715 100755 --- a/bin/compile +++ b/bin/compile @@ -22,6 +22,9 @@ BP_DIR=$(cd $(dirname ${0:-}); cd ..; pwd) 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/^/ /' @@ -53,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") @@ -97,21 +104,28 @@ 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" - - -# Export env var for next build -echo "BUNDLE_BUILD__RGEO=\"--with-opt-dir=$BUILD_DIR/$TARGET_VENDOR_DIR --with-geos-config=$BUILD_DIR/$TARGET_VENDOR_DIR/bin/geos-config\"" >> $BP_DIR/export -set-default-env BUNDLE_BUILD__RGEO "--with-opt-dir=$TARGET_VENDOR_DIR --with-geos-config=$TARGET_VENDOR_DIR/bin/geos-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" +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" + +# 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:\$PATH" echo "-----> Vendoring geo libraries done"