From ed23d1036479ea92235cea399171743d9dff1448 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 14 Nov 2013 16:21:40 +0100 Subject: [PATCH] Remember per-environment ./configure parameters This is to avoid breaking test.js configuration while switching between branches. --- .gitignore | 1 + Makefile | 8 +++++++- configure | 32 +++++++++++++++++++++++--------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 55d81916..a418e8c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules* +config.status* config/environments/*.js .idea tools/munin/windshaft.conf diff --git a/Makefile b/Makefile index 6ba8b587..6dd172f2 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,15 @@ all: clean: rm -rf node_modules/* -config/environments/test.js: config/environments/test.js.example Makefile +distclean: clean + rm config.status* + +config.status--test: ./configure --environment=test +config/environments/test.js: config.status--test + ./config.status--test + check-local: config/environments/test.js ./run_tests.sh ${RUNTESTFLAGS} \ test/unit/cartodb/redis_pool.test.js \ diff --git a/configure b/configure index 282fd63d..fef3bc71 100755 --- a/configure +++ b/configure @@ -17,11 +17,15 @@ # --strk(2012-07-23) # -PGPORT=5432 -SQLAPI_PORT=8080 +ENVDIR=config/environments + +PGPORT= +SQLAPI_PORT= MAPNIK_VERSION= ENVIRONMENT=development +STATUS="$0 $*" + usage() { echo "Usage: $0 [OPTION]" echo @@ -59,20 +63,30 @@ while test -n "$1"; do shift done +ENVEX=./${ENVDIR}/${ENVIRONMENT}.js.example + +if [ -z "$PGPORT" ]; then + PGPORT=`node -e "console.log(require('${ENVEX}').postgres.port)"` +fi +if [ -z "$SQLAPI_PORT" ]; then + SQLAPI_PORT=`node -e "console.log(require('${ENVEX}').sqlapi.port)"` +fi + echo "PGPORT: $PGPORT" echo "SQLAPI_PORT: $SQLAPI_PORT" echo "MAPNIK_VERSION: $MAPNIK_VERSION" echo "ENVIRONMENT: $ENVIRONMENT" -# TODO: allow specifying configuration settings ! -for f in config/environments/${ENVIRONMENT}.js.example; do - o=`dirname "$f"`/`basename "$f" .example` - echo "Writing $o" +o=`dirname "${ENVEX}"`/`basename "${ENVEX}" .example` +echo "Writing $o" - # See http://austinmatzko.com/2008/04/26/sed-multi-line-search-and-replace/ - sed -n "1h;1!H;\${;g;s/\(,postgres: {[^}]*port: *'\?\)[^',]*\('\?,\)/\1$PGPORT\2/;p;}" < "$f" \ +# See http://austinmatzko.com/2008/04/26/sed-multi-line-search-and-replace/ +sed -n "1h;1!H;\${;g;s/\(,postgres: {[^}]*port: *'\?\)[^',]*\('\?,\)/\1$PGPORT\2/;p;}" < "${ENVEX}" \ | sed "s/mapnik_version:.*/mapnik_version: '$MAPNIK_VERSION'/" \ | sed -n "1h;1!H;\${;g;s/\(,sqlapi: {[^}]*port: *'\?\)[^',]*\('\?,\)/\1$SQLAPI_PORT\2/;p;}" \ > "$o" -done +STATUSFILE=config.status--${ENVIRONMENT} +echo "Writing ${STATUSFILE}" +echo ${STATUS} > ${STATUSFILE} && chmod +x ${STATUSFILE} +