From ee76817d14dedd7918eb2b9123ab4431a177b9a1 Mon Sep 17 00:00:00 2001 From: Michael Reichert Date: Fri, 24 Nov 2023 13:46:29 +0100 Subject: [PATCH] Fix bugs in configure script The script expected that the shell supports arrays but only Z shell and Bash do so. Other shells return syntax errors. In addition, the script expected the mapnik-settings.env file to exist and crashed otherwise. --- configure | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/configure b/configure index c2cabf48a..39fd48c7d 100755 --- a/configure +++ b/configure @@ -1,20 +1,32 @@ -#! /bin/sh +#! /usr/bin/env bash set -eu : ${PYTHON:=python} +# Only some shells (Bash and Z shell) support arrays. Therefore, +# the following code provides an alternative for users calling the script +# with shells other than Bash or Z shell (e.g. Debian users using Dash). +THE_SHELL=$(basename $SHELL) +if [ "$THE_SHELL" != "bash" ] && [ "$THE_SHELL" != "zsh" ]; then + if [ -f mapnik-settings.env ]; then + echo "WARNING: Reading from mapnik-settings.env is supported with Bash or Z shell only." + fi + $PYTHON scons/scons.py --implicit-deps-changed configure "$@" + exit 0 +fi + # mapnik-settings.env is an optional file to store # environment variables that should be used before # running tests like PROJ_LIB, GDAL_DATA, and ICU_DATA # These do not normally need to be set except when # building against binary versions of dependencies like # done via bootstrap.sh +VARS=() if [ -f mapnik-settings.env ]; then echo "Inheriting from mapnik-settings.env" . ./mapnik-settings.env + VARS=( $(cat mapnik-settings.env) ) fi -VARS=( $(cat mapnik-settings.env) ) - $PYTHON scons/scons.py --implicit-deps-changed configure ${VARS[*]} "$@"