[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Actually use CHUTNEY_TOR as a binary path, rather than just searching PATH



commit a5eae0b6d94d1e5bf3cf17ed721a9334bc3e85fb
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Wed Aug 8 12:17:55 2018 +1000

    Actually use CHUTNEY_TOR as a binary path, rather than just searching PATH
    
    Also:
    * Use CHUTNEY_TOR as a binary name, rather than just using the standard name
    * Do the same for CHUTNEY_TOR_GENCERT
    * Tell the user how chutney is trying to find tor binaries
    * Document chutney's binary search order better
    
    Fixes 27068.
---
 README                | 18 ++++++++++++------
 tools/test-network.sh | 26 +++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/README b/README
index d845e6b..23c6ed2 100644
--- a/README
+++ b/README
@@ -9,12 +9,18 @@ It is supposed to be a good tool for:
 
 Right now it only sorta does these things.
 
-You will need, at the moment:
-  - Tor installed somewhere in your path, or
-  - The location of the 'tor' and 'tor-gencert' binaries specified through the
-    environment variables CHUTNEY_TOR and CHUTNEY_TOR_GENCERT, respectively, or
-  - To run chutney's tools/test-network.sh from a tor build directory, and
-  - Python 2.7 or later (Python 3 support is an ongoing work)
+You will need:
+  - Python 2.7 or later (Python 3 support is an ongoing work), and
+  - Tor binaries.
+
+Chutney checks for Tor binaries in this order:
+  - If you run chutney's tools/test-network.sh from a tor build directory,
+    (or set the environment variable $TOR_DIR to a tor build directory,)
+    chutney will automatically detect the tor binaries, or
+  - If you put the location of the 'tor' and 'tor-gencert' binaries in the
+    environment variables $CHUTNEY_TOR and $CHUTNEY_TOR_GENCERT, respectively,
+    chutney will use those binaries, or
+  - You will need tor and tor-gencert installed somewhere in your path.
 
 Stuff to try:
 
diff --git a/tools/test-network.sh b/tools/test-network.sh
index 97a7374..b4448e2 100755
--- a/tools/test-network.sh
+++ b/tools/test-network.sh
@@ -185,7 +185,8 @@ fi
 # if it's not set:
 #  - set it to $BUILDDIR, or
 #  - if $PWD looks like a tor build directory, set it to $PWD, or
-#  - unset $TOR_DIR, and let chutney fall back to finding tor binaries in $PATH
+#  - unset $TOR_DIR, and let chutney fall back to finding tor binaries in
+#    $CHUTNEY_TOR and $CHUTNEY_TOR_GENCERT, or $PATH
 if [ ! -d "$TOR_DIR" ]; then
     if [ -d "$BUILDDIR/src/or" -a -d "$BUILDDIR/src/tools" ]; then
         # Choose the build directory
@@ -204,7 +205,7 @@ if [ ! -d "$TOR_DIR" ]; then
         $ECHO "$myname: \$TOR_DIR not set, trying \$PWD/../tor"
         export TOR_DIR="$PWD/../tor"
     else
-        $ECHO "$myname: no \$TOR_DIR, chutney will use \$PATH for tor binaries"
+        $ECHO "$myname: no \$TOR_DIR, chutney will use \$CHUTNEY_TOR and \$CHUTNEY_TOR_GENCERT as tor binary paths, or search \$PATH for tor binary names"
         unset TOR_DIR
     fi
 fi
@@ -264,14 +265,29 @@ fi
 # using $CHUTNEY_TOR and $CHUTNEY_TOR_GENCERT, and then falls back to
 # looking for tor and tor-gencert in $PATH
 if [ -d "$TOR_DIR" ]; then
+    $ECHO "$myname: Setting \$CHUTNEY_TOR and \$CHUTNEY_TOR_GENCERT based on TOR_DIR: '$TOR_DIR'"
     # TOR_DIR is absolute, so these are absolute paths
     export CHUTNEY_TOR="${TOR_DIR}/src/or/${tor_name}"
     export CHUTNEY_TOR_GENCERT="${TOR_DIR}/src/tools/${tor_gencert_name}"
 else
-    # these are binary names, they will be searched for in $PATH
-    export CHUTNEY_TOR="${tor_name}"
-    export CHUTNEY_TOR_GENCERT="${tor_gencert_name}"
+    if [ -x "$CHUTNEY_TOR" ]; then
+        $ECHO "$myname: Assuming \$CHUTNEY_TOR is a path to a binary"
+    elif [ ! -z "$CHUTNEY_TOR" ]; then
+        $ECHO "$myname: Assuming \$CHUTNEY_TOR is a binary name in PATH"
+    else
+        $ECHO "$myname: Setting \$CHUTNEY_TOR to the standard binary name in PATH"
+        export CHUTNEY_TOR="${tor_name}"
+    fi
+    if [ -x "$CHUTNEY_TOR_GENCERT" ]; then
+        $ECHO "$myname: Assuming \$CHUTNEY_TOR_GENCERT is a path to a binary"
+    elif [ ! -z "$CHUTNEY_TOR_GENCERT" ]; then
+        $ECHO "$myname: Assuming \$CHUTNEY_TOR_GENCERT is a binary name in PATH"
+    else
+        $ECHO "$myname: Setting \$CHUTNEY_TOR_GENCERT to the standard binary name in PATH"
+        export CHUTNEY_TOR_GENCERT="${tor_gencert_name}"
+    fi
 fi
+$ECHO "$myname: Using \$CHUTNEY_TOR: '$CHUTNEY_TOR' and \$CHUTNEY_TOR_GENCERT: '$CHUTNEY_TOR_GENCERT'"
 
 # Set the variables for the chutney network flavour
 export NETWORK_FLAVOUR=${NETWORK_FLAVOUR:-"bridges+hs"}



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits