couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [16/37] couchdb commit: updated refs/heads/master to 1ef7182
Date Wed, 24 Jun 2015 21:33:24 GMT
New ./configure script!

This work will handle GNU ./configure style configuration of target
directories for installation of the various bits of CouchDB.

Includes a test script(!) for ./configure


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4dc3eafe
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4dc3eafe
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4dc3eafe

Branch: refs/heads/master
Commit: 4dc3eafed5bcfa7cce91283e83d458ccfd7c1e8a
Parents: f29c023
Author: Jan Lehnardt <jan@apache.org>
Authored: Fri Jun 19 18:05:32 2015 +0200
Committer: Jan Lehnardt <jan@apache.org>
Committed: Wed Jun 24 23:06:58 2015 +0200

----------------------------------------------------------------------
 Makefile                     |  28 +++
 configure                    | 439 +++++++++++++++++++++++++++++++++-----
 test/build/test-configure.sh | 298 ++++++++++++++++++++++++++
 3 files changed, 715 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/4dc3eafe/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
index 326403c..0e4bd2c 100644
--- a/Makefile
+++ b/Makefile
@@ -88,19 +88,47 @@ install: all
 	@echo "Installing CouchDB into $(DESTDIR)/$(install_dir)..." | sed -e 's,///,/,'
 	@rm -rf rel/couchdb
 	@rebar generate # make full erlang release
+
 	@mkdir -p $(DESTDIR)/$(install_dir)
 	@cp -R rel/couchdb/* $(DESTDIR)/$(install_dir)
+
 	@mkdir -p $(DESTDIR)/$(data_dir)
 	@chown $(user) $(DESTDIR)/$(data_dir)
+
 	@mkdir -p $(DESTDIR)/$(view_index_dir)
 	@chown $(user) $(DESTDIR)/$(view_index_dir)
+
 	@mkdir -p $(DESTDIR)/`dirname $(log_file)`
 	@touch $(DESTDIR)/$(log_file)
 	@chown $(user) $(DESTDIR)/$(log_file)
+
+	@mkdir -p $(DESTDIR)/$(bin_dir)
+	@cp rel/couchdb/bin/couchdb $(DESTDIR)/$(bin_dir)
+
+	@mkdir -p $(DESTDIR)/$(libexec_dir)
+	@cp rel/couchdb/bin/couchjs $(DESTDIR)/$(libexec_dir)
+
+	@mkdir -p $(DESTDIR)/$(sysconf_dir)
+	@mkdir -p $(DESTDIR)/$(sysconf_dir)/default.d
+	@mkdir -p $(DESTDIR)/$(sysconf_dir)/local.d
+	@cp rel/overlay/etc/default.ini rel/overlay/etc/local.ini $(DESTDIR)/$(sysconf_dir)
+
+	@mkdir -p $(DESTDIR)/$(data_dir)
+	@cp -R share/server share/www $(DESTDIR)/$(data_dir)
+
+	# TODO: copy over man, pdf, info etc. files
+	#       after including them in the release tarball in `make release`
+	#@mkdir -p $(DESTDIR)/$(doc_dir)
+	#@cp -R
+
 	@echo "...done"
 
 uninstall:
 	@rm -rf $(DESTDIR)/$(install_dir)
+	@rm -f $(DESTDIR)/$(bin_dir)/couchdb
+	@rm -f $(DESTDIR)/$(libexec_dir)
+	@rm -rf $(DESTDIR)/$(sysconf_dir)
+	@rm -rf $(DESTDIR)/$(data_dir)
 
 install.mk:
 # ignore install.mk missing if we are running

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4dc3eafe/configure
----------------------------------------------------------------------
diff --git a/configure b/configure
index c122bf3..43d2e9d 100755
--- a/configure
+++ b/configure
@@ -11,15 +11,29 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
-PREFIX="/usr/local"
-PACKAGE_AUTHOR_NAME="The Apache Software Foundation"
-COUCHDB_USER=`whoami`
-WITH_CURL="false"
-
 # cd into this script’s directory
 rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")"
 basename=`basename $0`
 
+TEST=0
+WITH_CURL="false"
+
+PREFIX=
+DEFAULT_PREFIX=/usr/local
+EXEC_PREFIX=
+BINDIR=
+LIBEXECDIR=
+SYSCONFDIR=
+DATAROOTDIR=
+DATADIR=
+LOCALSTATEDIR=
+RUNSTATEDIR=
+DOCDIR=
+LIBDIR=
+
+DATABASEDIR=
+VIEWDIR=
+LOGDIR=
 
 display_help () {
     cat << EOF
@@ -30,66 +44,383 @@ system for Apache CouchDB.
 
 Options:
 
-  -h            display a short help message and exit
-  -u USER       set the username to run as (defaults to $COUCHDB_USER)
-  -p DIRECTORY  set the prefix for installation (defaults to $PREFIX)
-  -d DIRECTORY  specify the data directory (defaults to /var/lib/couchdb)
-  -v DIRECTORY  specify the view directory (defaults to /var/lib/couchdb)
-  -l FILE       specify the log file (defaults to /var/log/couchdb.log)
-  -c            request that couchjs is linked to cURL (default false)
+  -h | --help                 display a short help message and exit
+  # -u USER       set the username to run as (defaults to $COUCHDB_USER)
+  --prefix=DIRECTORY          set the installation prefix (defaults to $DEFAIULT_PREFIX)
+  --databasedir DIRECTORY     specify the data directory (defaults to /var/lib/couchdb)
+  --viewindexdir DIRECTORY         specify the view directory (defaults to /var/lib/couchdb)
+  --logdir DIRECTORY          specify the log file (defaults to /var/log/couchdb.log)
+  -c | --with-curl            request that couchjs is linked to cURL (default false)
+
+  Installation directories:
+    --prefix=PREFIX         install architecture-independent files in PREFIX
+                            [/usr/local]
+    --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                            [PREFIX]
 
+  Fine tuning of the installation directories:
+    --bindir=DIR            user executables [EPREFIX/bin]
+    --libexecdir=DIR        program executables [EPREFIX/libexec]
+    --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+    --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+    --libdir=DIR            object code libraries [EPREFIX/lib]
+    --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+    --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+    # --infodir=DIR           info documentation [DATAROOTDIR/info]
+    # --mandir=DIR            man documentation [DATAROOTDIR/man]
+    # --docdir=DIR            documentation root [DATAROOTDIR/doc/apache-couchdb]
+    # --htmldir=DIR           html documentation [DOCDIR]
+    # --dvidir=DIR            dvi documentation [DOCDIR]
+    # --pdfdir=DIR            pdf documentation [DOCDIR]
+    # --psdir=DIR             ps documentation [DOCDIR]
 EOF
 }
 
+parse_opts() {
+    while :; do
+        case $1 in
+            -h|--help)
+                display_help
+                exit
+                ;;
 
-display_error () {
-    if test -n "$1"; then
-        echo $1 >&2
-    fi
-    echo >&2
-    echo "Try \"$basename -h\" for more information." >&2
-    false
-}
+            --test)
+                TEST=1
+                shift 1
+                continue
+                ;;
 
+            --with-curl|-c)
+                WITH_CURL="true"
+                shift 1
+                continue
+                ;;
 
-parse_opts () {
-    set +e
-    options=`getopt hu:p:d:v:l:c $@`
-    if test ! $? -eq 0; then
-        display_error
-    fi
-    set -e
-    eval set -- $options
-    while [ $# -gt 0 ]; do
-        case "$1" in
-            -h) shift; display_help; exit;;
-            -u) shift; COUCHDB_USER=$1; shift;;
-            -p) shift; PREFIX=$1; shift;;
-            -d) shift; DATA_DIR=$1; shift;;
-            -v) shift; VIEW_DIR=$1; shift;;
-            -l) shift; LOG_FILE=$1; shift;;
-            -c) shift; WITH_CURL="true";;
-            --) shift; break;;
-            *) display_error "Unknown option: $1" >&2;;
+            --prefix)
+                if [ -n "$2" ]; then
+                    PREFIX=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--prefix" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --prefix=?*)
+                PREFIX=${1#*=}
+                ;;
+            --prefix=)
+                printf 'ERROR: "--prefix" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --exec-prefix)
+                if [ -n "$2" ]; then
+                    EXEC_PREFIX=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--exec-prefix" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --exec-prefix=?*)
+                EXEC_PREFIX=${1#*=}
+                ;;
+            --exec-prefix=)
+                printf 'ERROR: "--exec-prefix" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --bindir)
+                if [ -n "$2" ]; then
+                    BINDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--bindir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --bindir=?*)
+                BINDIR=${1#*=}
+                ;;
+            --bindir=)
+                printf 'ERROR: "--bindir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --libexecdir)
+                if [ -n "$2" ]; then
+                    LIBEXECDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--libexecdir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --libexecdir=?*)
+                LIBEXECDIR=${1#*=}
+                ;;
+            --libexecdir=)
+                printf 'ERROR: "--libexecdir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --sysconfdir)
+                if [ -n "$2" ]; then
+                    SYSCONFDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--sysconfdir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --sysconfdir=?*)
+                SYSCONFDIR=${1#*=}
+                ;;
+            --sysconfdir=)
+                printf 'ERROR: "--sysconfdir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --datarootdir)
+                if [ -n "$2" ]; then
+                    DATAROOTDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--datarootdir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --datarootdir=?*)
+                DATAROOTDIR=${1#*=}
+                ;;
+            --datarootdir=)
+                printf 'ERROR: "--datarootdir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --datadir)
+                if [ -n "$2" ]; then
+                    DATADIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--datadir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --datadir=?*)
+                DATADIR=${1#*=}
+                ;;
+            --datadir=)
+                printf 'ERROR: "--datadir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --localstatedir)
+                if [ -n "$2" ]; then
+                    LOCALSTATEDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--localstatedir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --localstatedir=?*)
+                LOCALSTATEDIR=${1#*=}
+                ;;
+            --localstatedir=)
+                printf 'ERROR: "--localstatedir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --runstatedir)
+                if [ -n "$2" ]; then
+                    RUNSTATEDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--runstatedir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --runstatedir=?*)
+                RUNSTATEDIR=${1#*=}
+                ;;
+            --runstatedir=)
+                printf 'ERROR: "--runstatedir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --docdir)
+                if [ -n "$2" ]; then
+                    DOCDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--docdir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --docdir=?*)
+                DOCDIR=${1#*=}
+                ;;
+            --docdir=)
+                printf 'ERROR: "--docdir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --libdir)
+                if [ -n "$2" ]; then
+                    LIBDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--libdir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --libdir=?*)
+                LIBDIR=${1#*=}
+                ;;
+            --libdir=)
+                printf 'ERROR: "--libdir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --databasedir)
+                if [ -n "$2" ]; then
+                    DATABASEDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--databasedir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --databasedir=?*)
+                DATABASEDIR=${1#*=}
+                ;;
+            --databasedir=)
+                printf 'ERROR: "--databasedir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --viewindexdir)
+                if [ -n "$2" ]; then
+                    VIEWDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--viewindexdir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --viewindexdir=?*)
+                VIEWDIR=${1#*=}
+                ;;
+            --viewindexdir=)
+                printf 'ERROR: "--viewindexdir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --logdir)
+                if [ -n "$2" ]; then
+                    LOGDIR=$2
+                    shift 2
+                    continue
+                else
+                    printf 'ERROR: "--logdir" requires a non-empty argument.\n' >&2
+                    exit 1
+                fi
+                ;;
+            --logdir=?*)
+                LOGDIR=${1#*=}
+                ;;
+            --logdir=)
+                printf 'ERROR: "--logdir" requires a non-empty argument.\n' >&2
+                exit 1
+                ;;
+
+            --) # End of options
+                shift
+                break
+                ;;
+            *) # Done
+                break
         esac
+        shift
     done
 
     # defaults
-    if test -z "$DATA_DIR"; then
-        DATA_DIR="/var/lib/couchdb";
+    if test -z "$PREFIX"; then
+        PREFIX="$DEFAULT_PREFIX";
+    fi
+    if test -z "$EXEC_PREFIX"; then
+        EXEC_PREFIX="$PREFIX";
+    fi
+    if test -z "$BINDIR"; then
+        BINDIR="$EXEC_PREFIX/bin";
+    fi
+    if test -z "$LIBEXECDIR"; then
+        LIBEXECDIR="$EXEC_PREFIX/libexec";
+    fi
+    if test -z "$SYSCONFDIR"; then
+        SYSCONFDIR="$PREFIX/etc";
+    fi
+    if test -z "$DATAROOTDIR"; then
+        DATAROOTDIR="$PREFIX/share";
+    fi
+    if test -z "$DATADIR"; then
+        DATADIR="$DATAROOTDIR";
+    fi
+    if test -z "$LOCALSTATEDIR"; then
+        LOCALSTATEDIR="$PREFIX/var";
+    fi
+    if test -z "$RUNSTATEDIR"; then
+        RUNSTATEDIR="$LOCALSTATEDIR/run";
+    fi
+    if test -z "$DOCDIR"; then
+        DOCDIR="$DATAROOTDIR/doc";
     fi
-    if test -z "$VIEW_DIR"; then
-        VIEW_DIR="/var/lib/couchdb";
+    if test -z "$LIBDIR"; then
+        LIBDIR="$EXEC_PREFIX/lib";
     fi
-    if test -z "$LOG_FILE"; then
-        LOG_FILE="/var/log/couchdb.log";
+    if test -z "$DATABASEDIR"; then
+        DATABASEDIR="$LOCALSTATEDIR/lib";
+    fi
+    if test -z "$VIEWDIR"; then
+        VIEWDIR="$LOCALSTATEDIR/lib";
+    fi
+    if test -z "$LOGDIR"; then
+        LOGDIR="$LOCALSTATEDIR/log";
     fi
 }
 
-
 parse_opts $@
 
-INSTALL_DIR="$PREFIX/couchdb"
+# We use this for testing this script
+# The test script lives in test/build/test-configure.sh
+if [ "$TEST" = "1" ]; then
+    echo $PREFIX $EXEC_PREFIX $BINDIR $LIBEXECDIR $SYSCONFDIR $DATAROOTDIR \
+         $DATADIR $LOCALSTATEDIR $RUNSTATEDIR $DOCDIR $LIBDIR $DATABASEDIR \
+         $VIEWDIR $LOGDIR
+    exit 0
+fi
+
+# Translate ./configure variables to CouchDB variables
+
+INSTALL_DIR=$LIBDIR/couchdb
+LOG_FILE=$LOGDIR/couch.log
+
+DATBASE_DIR=$DATABASE_DIR/couchdb
+VIEW_DIR=$VIEW_DIR/couchdb
 
 
 echo "==> configuring couchdb in rel/couchdb.config"
@@ -109,8 +440,8 @@ cat > rel/couchdb.config << EOF
 % The contents of this file are auto-generated by configure
 %
 {package_author_name, "$PACKAGE_AUTHOR_NAME"}.
-{prefix, "INSTALLDIR"}.
-{data_dir, "$DATA_DIR"}.
+{prefix, "$INSTALL_DIR"}.
+{data_dir, "$DATABASE_DIR"}.
 {view_index_dir, "$VIEW_DIR"}.
 {log_file, "$LOG_FILE"}.
 {user, "$COUCHDB_USER"}.
@@ -136,7 +467,14 @@ cat > install.mk << EOF
 #
 package_author_name = $PACKAGE_AUTHOR_NAME
 install_dir = $INSTALL_DIR
-data_dir = $DATA_DIR
+
+bin_dir = $BINDIR
+libexec_dir = $LIBEXECDIR/couchdb
+doc_dir = $DOCDIR/couchdb
+sysconf_dir = $SYSCONFDIR/couchdb
+data_dir = $DATADIR/couchdb
+
+database_dir = $DATABASE_DIR
 view_index_dir = $VIEW_DIR
 log_file = $LOG_FILE
 user = $COUCHDB_USER
@@ -146,6 +484,7 @@ cat > $rootdir/config.erl << EOF
 {with_curl, $WITH_CURL}.
 EOF
 
+
 # only update dependencies, when we are not in a release tarball
 if [ -d .git ]; then
   echo "==> updating dependencies"

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4dc3eafe/test/build/test-configure.sh
----------------------------------------------------------------------
diff --git a/test/build/test-configure.sh b/test/build/test-configure.sh
new file mode 100755
index 0000000..ae7565c
--- /dev/null
+++ b/test/build/test-configure.sh
@@ -0,0 +1,298 @@
+#!/bin/sh
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+# requires shunit2 to be in $PATH
+# http://shunit2.googlecode.com/
+
+SHUNIT2=`which shunit2`
+
+if [ -z "$SHUNIT2" -o ! -x "$SHUNIT2" ]; then
+    echo
+    echo "Error: This test script requires the shunit2 script to be in \$PATH".
+    echo "You can download shunit2 from http://shunit2.googlecode.com or via"
+    echo "your preferred package manager."
+    echo
+    exit 1
+fi
+
+CMD="./configure2 --test "
+
+test_defaults() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /usr/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+    RESULT=`$CMD`
+    assertEquals "test defaults" "$EXPECT" "$RESULT"
+}
+
+test_prefix() {
+    EXPECT="/opt/local /opt/local /opt/local/bin /opt/local/libexec /opt/local/etc /opt/local/share
/opt/local/share /opt/local/var /opt/local/var/run /opt/local/share/doc /opt/local/lib /opt/local/var/lib
/opt/local/var/lib /opt/local/var/log"
+
+    RESULT=`$CMD --prefix=/opt/local`
+    assertEquals "test prefix" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --prefix /opt/local`
+    assertEquals "test prefix" "$EXPECT" "$RESULT"
+}
+
+test_prefix_error() {
+    EXPECT='ERROR: "--prefix" requires a non-empty argument.'
+
+    RESULT=`$CMD --prefix= 2>&1`
+    assertEquals "test prefix error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --prefix 2>&1`
+    assertEquals "test prefix error" "$EXPECT" "$RESULT"
+}
+
+
+test_exec_prefix() {
+    EXPECT="/usr/local /opt/local /opt/local/bin /opt/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /opt/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --exec-prefix=/opt/local`
+    assertEquals "test exec_prefix" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --exec-prefix /opt/local`
+    assertEquals "test exec_prefix" "$EXPECT" "$RESULT"
+}
+
+test_exec_prefix_error() {
+    EXPECT='ERROR: "--exec-prefix" requires a non-empty argument.'
+
+    RESULT=`$CMD --exec-prefix= 2>&1`
+    assertEquals "test exec_prefix error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --exec-prefix 2>&1`
+    assertEquals "test exec_prefix error" "$EXPECT" "$RESULT"
+}
+
+test_bindir() {
+    EXPECT="/usr/local /usr/local /my/funky/bindir /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /usr/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --bindir=/my/funky/bindir`
+    assertEquals "test bindir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --bindir /my/funky/bindir`
+    assertEquals "test bindir" "$EXPECT" "$RESULT"
+}
+
+test_bindir_error() {
+    EXPECT='ERROR: "--bindir" requires a non-empty argument.'
+
+    RESULT=`$CMD --bindir= 2>&1`
+    assertEquals "test bindir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --bindir 2>&1`
+    assertEquals "test bindir error" "$EXPECT" "$RESULT"
+}
+
+test_libexecdir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /opt/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /usr/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --libexecdir=/opt/local/libexec`
+    assertEquals "test libexecdir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --libexecdir /opt/local/libexec`
+    assertEquals "test libexecdir" "$EXPECT" "$RESULT"
+}
+
+test_libexecdir_error() {
+    EXPECT='ERROR: "--libexecdir" requires a non-empty argument.'
+
+    RESULT=`$CMD --libexecdir= 2>&1`
+    assertEquals "test libexecdir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --libexecdir 2>&1`
+    assertEquals "test libexecdir error" "$EXPECT" "$RESULT"
+}
+
+test_sysconfdir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /opt/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /usr/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --sysconfdir=/opt/local/etc`
+    assertEquals "test sysconfdir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --sysconfdir /opt/local/etc`
+    assertEquals "test sysconfdir" "$EXPECT" "$RESULT"
+}
+
+test_sysconfdir_error() {
+    EXPECT='ERROR: "--sysconfdir" requires a non-empty argument.'
+
+    RESULT=`$CMD --sysconfdir= 2>&1`
+    assertEquals "test sysconfdir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --sysconfdir 2>&1`
+    assertEquals "test sysconfdir error" "$EXPECT" "$RESULT"
+}
+
+test_datarootdir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /opt/local/share
/opt/local/share /usr/local/var /usr/local/var/run /opt/local/share/doc /usr/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --datarootdir=/opt/local/share`
+    assertEquals "test datarootdir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --datarootdir /opt/local/share`
+    assertEquals "test datarootdir" "$EXPECT" "$RESULT"
+}
+
+test_datarootdir_error() {
+    EXPECT='ERROR: "--datarootdir" requires a non-empty argument.'
+
+    RESULT=`$CMD --datarootdir= 2>&1`
+    assertEquals "test datarootdir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --datarootdir 2>&1`
+    assertEquals "test datarootdir error" "$EXPECT" "$RESULT"
+}
+
+test_localstatedir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /horse/local/var /horse/local/var/run /usr/local/share/doc /usr/local/lib
/horse/local/var/lib /horse/local/var/lib /horse/local/var/log"
+
+    RESULT=`$CMD --localstatedir=/horse/local/var`
+    assertEquals "test localstatedir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --localstatedir /horse/local/var`
+    assertEquals "test localstatedir" "$EXPECT" "$RESULT"
+}
+
+test_localstatedir_error() {
+    EXPECT='ERROR: "--localstatedir" requires a non-empty argument.'
+
+    RESULT=`$CMD --localstatedir= 2>&1`
+    assertEquals "test localstatedir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --localstatedir 2>&1`
+    assertEquals "test localstatedir error" "$EXPECT" "$RESULT"
+}
+
+test_runstatedir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /horse/local/var/run /usr/local/share/doc /usr/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --runstatedir=/horse/local/var/run`
+    assertEquals "test runstatedir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --runstatedir /horse/local/var/run`
+    assertEquals "test runstatedir" "$EXPECT" "$RESULT"
+}
+
+test_runstatedir_error() {
+    EXPECT='ERROR: "--runstatedir" requires a non-empty argument.'
+
+    RESULT=`$CMD --runstatedir= 2>&1`
+    assertEquals "test runstatedir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --runstatedir 2>&1`
+    assertEquals "test runstatedir error" "$EXPECT" "$RESULT"
+}
+
+test_docdir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /horse/local/share/doc /usr/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --docdir=/horse/local/share/doc`
+    assertEquals "test docdir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --docdir /horse/local/share/doc`
+    assertEquals "test docdir" "$EXPECT" "$RESULT"
+}
+
+test_docdir_error() {
+    EXPECT='ERROR: "--docdir" requires a non-empty argument.'
+
+    RESULT=`$CMD --docdir= 2>&1`
+    assertEquals "test docdir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --docdir 2>&1`
+    assertEquals "test docdir error" "$EXPECT" "$RESULT"
+}
+
+test_libdir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /horse/local/lib /usr/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --libdir=/horse/local/lib`
+    assertEquals "test libdir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --libdir /horse/local/lib`
+    assertEquals "test libdir" "$EXPECT" "$RESULT"
+}
+
+test_libdir_error() {
+    EXPECT='ERROR: "--libdir" requires a non-empty argument.'
+
+    RESULT=`$CMD --libdir= 2>&1`
+    assertEquals "test libdir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --libdir 2>&1`
+    assertEquals "test libdir error" "$EXPECT" "$RESULT"
+}
+
+test_database_dir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /usr/local/lib /horse/local/var/lib
/usr/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --databasedir=/horse/local/var/lib`
+    assertEquals "test database_dir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --databasedir /horse/local/var/lib`
+    assertEquals "test database_dir" "$EXPECT" "$RESULT"
+}
+
+test_database_dir_error() {
+    EXPECT='ERROR: "--databasedir" requires a non-empty argument.'
+
+    RESULT=`$CMD --databasedir= 2>&1`
+    assertEquals "test database_dir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --databasedir 2>&1`
+    assertEquals "test database_dir error" "$EXPECT" "$RESULT"
+}
+
+test_view_dir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /usr/local/lib /usr/local/var/lib
/horse/local/var/lib /usr/local/var/log"
+
+    RESULT=`$CMD --viewindexdir=/horse/local/var/lib`
+    assertEquals "test view_dir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --viewindexdir /horse/local/var/lib`
+    assertEquals "test view_dir" "$EXPECT" "$RESULT"
+}
+
+test_view_dir_error() {
+    EXPECT='ERROR: "--viewindexdir" requires a non-empty argument.'
+
+    RESULT=`$CMD --viewindexdir= 2>&1`
+    assertEquals "test view_dir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --viewindexdir 2>&1`
+    assertEquals "test view_dir error" "$EXPECT" "$RESULT"
+}
+
+test_log_dir() {
+    EXPECT="/usr/local /usr/local /usr/local/bin /usr/local/libexec /usr/local/etc /usr/local/share
/usr/local/share /usr/local/var /usr/local/var/run /usr/local/share/doc /usr/local/lib /usr/local/var/lib
/usr/local/var/lib /horse/log"
+
+    RESULT=`$CMD --logdir=/horse/log`
+    assertEquals "test log_dir" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --logdir /horse/log`
+    assertEquals "test log_dir" "$EXPECT" "$RESULT"
+}
+
+test_log_dir_error() {
+    EXPECT='ERROR: "--logdir" requires a non-empty argument.'
+
+    RESULT=`$CMD --logdir= 2>&1`
+    assertEquals "test log_dir error" "$EXPECT" "$RESULT"
+
+    RESULT=`$CMD --logdir 2>&1`
+    assertEquals "test log_dir error" "$EXPECT" "$RESULT"
+}
+
+# source the shunit2
+. $SHUNIT2


Mime
View raw message