summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorMS <ms@taler.net>2020-07-22 14:53:45 +0200
committerMS <ms@taler.net>2020-07-22 14:53:45 +0200
commit2d97ecc2c1ac605ca49e8a866b309daaeb7a831c (patch)
tree173f7917c5d0af822d2d51ed491c3cf2d8eaf23f /configure
downloadtaler-merchant-demos-2d97ecc2c1ac605ca49e8a866b309daaeb7a831c.tar.gz
taler-merchant-demos-2d97ecc2c1ac605ca49e8a866b309daaeb7a831c.tar.bz2
taler-merchant-demos-2d97ecc2c1ac605ca49e8a866b309daaeb7a831c.zip
Installing the Blog
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure87
1 files changed, 87 insertions, 0 deletions
diff --git a/configure b/configure
new file mode 100755
index 0000000..469bad7
--- /dev/null
+++ b/configure
@@ -0,0 +1,87 @@
+#!/usr/bin/env bash
+
+set -eu
+
+usage() {
+ echo "Usage: ./configure [OPTION]"
+ echo
+ echo "Configuration:"
+ echo " -h, --help display this help and exit"
+ echo
+ echo "Installation directories:"
+ echo " --destination=[local|global] install Python package locally or globally"
+}
+
+
+# -allow a command to fail with !’s side effect on errexit
+# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
+! getopt --test > /dev/null
+if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
+ echo 'getopt not available'
+ exit 1
+fi
+
+LONGOPTS=destination:,help
+OPTIONS=h
+
+! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
+if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+ # e.g. return value is 1
+ # then getopt has complained about wrong arguments to stdout
+ exit 2
+fi
+
+# read getopt’s output this way to handle the quoting right:
+eval set -- "$PARSED"
+
+destination="local"
+
+while true; do
+ case "$1" in
+ --destination)
+ destination="$2"
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Programming error"
+ exit 3
+ ;;
+ esac
+done
+
+case "$destination" in
+ local)
+ install_global=false
+ ;;
+ global)
+ install_global=true
+ ;;
+ *)
+ echo "Destination (--destination) must be 'local' or 'global', paths are not allowed."
+ exit 3
+ ;;
+esac
+
+cat << EOF > config.mk
+# this file is autogenerated by ./configure
+install_global=$install_global
+EOF
+
+
+if ! python3 --version &>/dev/null; then
+ echo 'Error: python3 missing'
+ exit 1
+fi
+
+if ! pip3 --version &>/dev/null; then
+ echo 'Error: pip3 missing'
+ exit 1
+fi