From f2429555a812b61d41fbe5ad913e1d082f519b81 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Sun, 25 Feb 2018 15:20:03 +0000
Subject: [PATCH] Tidying cryptopp utils

---
 src/freedombone-utils-cryptopp | 42 ++++++++++++++++------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/src/freedombone-utils-cryptopp b/src/freedombone-utils-cryptopp
index 59f1ac2b9..4ead2b1c0 100755
--- a/src/freedombone-utils-cryptopp
+++ b/src/freedombone-utils-cryptopp
@@ -32,22 +32,22 @@ CRYPTOPP_REPO="https://github.com/weidai11/cryptopp"
 CRYPTOPP_COMMIT='65e91a8caa8c1846cb311bc83d8507e12699d6d3'
 
 function mesh_install_cryptopp {
-    if [ ! -d $rootdir$INSTALL_DIR ]; then
-        chroot "$rootdir" mkdir -p $INSTALL_DIR
+    # shellcheck disable=SC2154
+    if [ ! -d "$rootdir$INSTALL_DIR" ]; then
+        chroot "$rootdir" mkdir -p "$INSTALL_DIR"
     fi
 
     chroot "$rootdir" apt-get -yq install build-essential
 
-    git clone $CRYPTOPP_REPO $rootdir$INSTALL_DIR/cryptopp
-    cd $rootdir$INSTALL_DIR/cryptopp
+    git clone "$CRYPTOPP_REPO" "$rootdir$INSTALL_DIR/cryptopp"
+    cd "$rootdir$INSTALL_DIR/cryptopp" || exit 346873625
     git checkout $CRYPTOPP_COMMIT -b $CRYPTOPP_COMMIT
-    mkdir $rootdir$INSTALL_DIR/cryptopp/build
+    mkdir "$rootdir$INSTALL_DIR/cryptopp/build"
 
-    cat <<EOF > $rootdir/root/install_cryptopp
+    cat <<EOF > "$rootdir/root/install_cryptopp"
 cd $INSTALL_DIR/cryptopp/build
 cmake ..
-make
-if [ ! "$?" = "0" ]; then
+if ! make; then
     exit 62825
 fi
 make install
@@ -58,18 +58,17 @@ EOF
 }
 
 function install_cryptopp {
-    if [ $INSTALLING_MESH ]; then
+    if [ "$INSTALLING_MESH" ]; then
         mesh_install_cryptopp
         return
     fi
 
-    if [ -d $INSTALL_DIR/cryptopp ]; then
-        if ! grep -q "Crypto++ commit:$CRYPTOPP_COMMIT" $COMPLETION_FILE; then
-            set_repo_commit $INSTALL_DIR/cryptopp "Crypto++ commit" "$CRYPTOPP_COMMIT" $CRYPTOPP_REPO
+    if [ -d "$INSTALL_DIR/cryptopp" ]; then
+        if ! grep -q "Crypto++ commit:$CRYPTOPP_COMMIT" "$COMPLETION_FILE"; then
+            set_repo_commit "$INSTALL_DIR/cryptopp" "Crypto++ commit" "$CRYPTOPP_COMMIT" "$CRYPTOPP_REPO"
             cd $INSTALL_DIR/cryptopp/build
             cmake ..
-            make
-            if [ ! "$?" = "0" ]; then
+            if ! make; then
                 exit 72581
             fi
             make install
@@ -80,20 +79,19 @@ function install_cryptopp {
         return
     fi
 
-    if [ ! -d $INSTALL_DIR ]; then
-        mkdir -p $INSTALL_DIR
+    if [ ! -d "$INSTALL_DIR" ]; then
+        mkdir -p "$INSTALL_DIR"
     fi
 
     apt-get -yq install build-essential
 
-    git_clone $CRYPTOPP_REPO $INSTALL_DIR/cryptopp
-    cd $INSTALL_DIR/cryptopp
+    git_clone "$CRYPTOPP_REPO" "$INSTALL_DIR/cryptopp"
+    cd "$INSTALL_DIR/cryptopp" || exit 257478246
     git checkout $CRYPTOPP_COMMIT -b $CRYPTOPP_COMMIT
-    mkdir -p $INSTALL_DIR/cryptopp/build
-    cd $INSTALL_DIR/cryptopp/build
+    mkdir -p "$INSTALL_DIR/cryptopp/build"
+    cd "$INSTALL_DIR/cryptopp/build" || exit 6275425427
     cmake ..
-    make
-    if [ ! "$?" = "0" ]; then
+    if ! make; then
         exit 62826
     fi
     make install
-- 
GitLab