~ salmonella-environment-setup (master) 13954aaa9554fe3172ba1a8755d284d05c0b8064


commit 13954aaa9554fe3172ba1a8755d284d05c0b8064
Author:     Mario Domenech Goulart <mario@parenteses.org>
AuthorDate: Sat Jul 20 15:45:23 2019 +0200
Commit:     Mario Domenech Goulart <mario@parenteses.org>
CommitDate: Sat Jul 20 15:52:58 2019 +0200

    run-salmonella: read config files from ~/.salmonella-run-publish
    
    These are supposed to be local-specific configuration files (i.e.,
    local tweaks that are not supposed to be merged into this repository).
    
    The local config files are loaded _after_ the config files in this
    repository.

diff --git a/run-salmonella.sh b/run-salmonella.sh
index 4b37a6d..9cb65af 100755
--- a/run-salmonella.sh
+++ b/run-salmonella.sh
@@ -1,18 +1,26 @@
 #! /bin/sh
 
+SRC_CONF_DIR=$(readlink -f "$(dirname "$0")")/conf
+LOCAL_CONF_DIR=$HOME/.salmonella-run-publish
+WORK_DIR=$HOME/salmonella/build
+LOG_DIR=$HOME/salmonella
+
 usage() {
     cat <<EOF
 Usage: $(basename "$0") <confs>
 
 <confs>: configuration filenames without the ".conf" extension.  E.g.,
          if you have chicken-5.conf, use "chicken-5" as argument.
+
+Configuration files will be read from:
+
+* $SRC_CONF_DIR
+* $LOCAL_CONF_DIR
+
+in that order.
 EOF
 }
 
-SRC_DIR=$(readlink -f "$(dirname "$0")")
-WORK_DIR=$HOME/salmonella/build
-LOG_DIR=$HOME/salmonella
-
 # Conf files use these environment variables
 export CHICKEN_4_PREFIX=$HOME/local/chicken
 export CHICKEN_5_PREFIX=$HOME/local/chicken-5
@@ -24,8 +32,10 @@ ARCH=$($CHICKEN_4_PREFIX/bin/csi -p '(machine-type)')
 
 # FIXME: make it an array
 settings_files="\
-    $SRC_DIR/conf/shell-settings/${OS}/settings.sh
-    $SRC_DIR/conf/shell-settings/${OS}-${ARCH}/settings.sh
+    $SRC_CONF_DIR/shell-settings/${OS}/settings.sh
+    $SRC_CONF_DIR/shell-settings/${OS}-${ARCH}/settings.sh
+    $LOCAL_CONF_DIR/shell-settings/${OS}/settings.sh
+    $LOCAL_CONF_DIR/shell-settings/${OS}-${ARCH}/settings.sh
 "
 
 for settings_file in $settings_files; do
@@ -41,7 +51,7 @@ main() {
 
     # Check if all conf files exist
     for conf in $confs; do
-        if [ ! -e "$SRC_DIR/conf/${conf}.conf" ]; then
+        if [ ! -e "$SRC_CONF_DIR/${conf}.conf" ]; then
             echo "No configuration file found for '$conf'.  Aborting." >&2
             exit 1
         fi
@@ -79,8 +89,16 @@ main() {
             debugbuild=
         fi
 
-        conf_path=$SRC_DIR/conf/${conf}.conf
-        DEBUGBUILD=$debugbuild "$CHICKEN_4_PREFIX/bin/salmonella-run-publish" "$conf_path"
+        conf_path=$SRC_CONF_DIR/${conf}.conf
+        local_conf_path=$LOCAL_CONF_DIR/${conf}.conf
+        if [ -e "$local_conf_path" ]; then
+            echo "Loading $conf_path"
+            echo "Loading $local_conf_path"
+            DEBUGBUILD=$debugbuild "$CHICKEN_4_PREFIX/bin/salmonella-run-publish" "$conf_path" "$local_conf_path"
+        else
+            echo "Loading $conf_path"
+            DEBUGBUILD=$debugbuild "$CHICKEN_4_PREFIX/bin/salmonella-run-publish" "$conf_path"
+        fi
         mv salmonella-run-publish "salmonella-$conf"
     done
 }
Trap