From a259143c0bdd15d5d3aa8ae472b615e1d029cbd0 Mon Sep 17 00:00:00 2001
From: Ed Morley <emorley@mozilla.com>
Date: Mon, 1 Aug 2016 12:36:46 +0100
Subject: [PATCH] Avoid repetition of vendor library environment variable
 setting

Since we need to set it regardless of whether the vendored library
existed previously or not.
---
 bin/steps/cryptography | 8 +++-----
 bin/steps/gdal         | 8 +++-----
 bin/steps/geo-libs     | 8 +++-----
 bin/steps/pylibmc      | 8 +++-----
 4 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/bin/steps/cryptography b/bin/steps/cryptography
index f85d2d47..b82f3889 100755
--- a/bin/steps/cryptography
+++ b/bin/steps/cryptography
@@ -22,16 +22,14 @@ bpwatch start libffi_install
 # If a package using cffi exists within requirements, use vendored libffi.
 if (pip-grep -s requirements.txt bcrypt cffi cryptography django[bcrypt] Django[bcrypt] PyNaCl pyOpenSSL PyOpenSSL requests[security] misaka &> /dev/null) then
 
-  if [ -d ".heroku/vendor/lib/libffi-3.1.1" ]; then
-    export LIBFFI=$(pwd)/vendor
-  else
+  if [ ! -d ".heroku/vendor/lib/libffi-3.1.1" ]; then
     echo "-----> Noticed cffi. Bootstrapping libffi."
     mkdir -p .heroku/vendor
     # Download and extract libffi into target vendor directory.
     curl $VENDORED_LIBFFI -s | tar zxv -C .heroku/vendor &> /dev/null
-
-    export LIBFFI=$(pwd)/vendor
   fi
+
+  export LIBFFI=$(pwd)/vendor
 fi
 
 bpwatch stop libffi_install
diff --git a/bin/steps/gdal b/bin/steps/gdal
index 2ebe12ec..39f3bd35 100755
--- a/bin/steps/gdal
+++ b/bin/steps/gdal
@@ -22,16 +22,14 @@ bpwatch start gdal_install
 # If GDAL exists within requirements, use vendored gdal.
 if (pip-grep -s requirements.txt GDAL gdal pygdal &> /dev/null) then
 
-  if [ -f ".heroku/vendor/bin/gdalserver" ]; then
-    export GDAL=$(pwd)/vendor
-  else
+  if [ ! -f ".heroku/vendor/bin/gdalserver" ]; then
     echo "-----> Noticed GDAL. Bootstrapping gdal."
     mkdir -p .heroku/vendor
     # Download and extract cryptography into target vendor directory.
     curl $VENDORED_GDAL -s | tar zxv -C .heroku/vendor &> /dev/null
-
-    export GDAL=$(pwd)/vendor
   fi
+
+  export GDAL=$(pwd)/vendor
 fi
 
 bpwatch stop gdal_install
diff --git a/bin/steps/geo-libs b/bin/steps/geo-libs
index 4a1148f1..7c5fc3fc 100755
--- a/bin/steps/geo-libs
+++ b/bin/steps/geo-libs
@@ -24,18 +24,16 @@ bpwatch start geo_libs_install
 # If GDAL exists within requirements, use vendored gdal.
 if [[ "$BUILD_WITH_GEO_LIBRARIES" ]]; then
 
-  if [ -f ".heroku/vendor/bin/gdalserver" ]; then
-    export GDAL=$(pwd)/vendor
-  else
+  if [ ! -f ".heroku/vendor/bin/gdalserver" ]; then
     echo "-----> Bootstrapping gdal, geos, proj."
     mkdir -p .heroku/vendor
     # Download and extract cryptography into target vendor directory.
     curl $VENDORED_GDAL -s | tar zxv -C .heroku/vendor &> /dev/null
     curl $VENDORED_GEOS -s | tar zxv -C .heroku/vendor &> /dev/null
     curl $VENDORED_PROJ -s | tar zxv -C .heroku/vendor &> /dev/null
-
-    export GDAL=$(pwd)/vendor
   fi
+
+  export GDAL=$(pwd)/vendor
 fi
 
 bpwatch stop geo_libs_install
diff --git a/bin/steps/pylibmc b/bin/steps/pylibmc
index f3f13c60..1ae69145 100755
--- a/bin/steps/pylibmc
+++ b/bin/steps/pylibmc
@@ -21,16 +21,14 @@ bpwatch start pylibmc_install
 # If pylibmc exists within requirements, use vendored libmemcached.
 if (pip-grep -s requirements.txt pylibmc &> /dev/null) then
 
-  if [ -d ".heroku/vendor/lib/sasl2" ]; then
-    export LIBMEMCACHED=$(pwd)/vendor
-  else
+  if [ ! -d ".heroku/vendor/lib/sasl2" ]; then
     echo "-----> Noticed pylibmc. Bootstrapping libmemcached."
     mkdir -p .heroku/vendor
     # Download and extract libmemcached into target vendor directory.
     curl $VENDORED_MEMCACHED -s | tar zxv -C .heroku/vendor &> /dev/null
-
-    export LIBMEMCACHED=$(pwd)/vendor
   fi
+
+  export LIBMEMCACHED=$(pwd)/vendor
 fi
 
 bpwatch stop pylibmc_install
-- 
GitLab