From bbae5d0f9a113385faa5bbcf62b21814066df63b Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Tue, 27 Dec 2016 14:45:45 +0100 Subject: [PATCH] Problem: dpkg-query might fail in CI build and fail the build Solution: rework the bash test to avoid build failures as intended and make it an easier one-liner --- builds/cmake/ci_build.sh | 12 ++---------- builds/coverage/ci_build.sh | 12 ++---------- builds/valgrind/ci_build.sh | 12 ++---------- ci_build.sh | 12 ++---------- 4 files changed, 8 insertions(+), 40 deletions(-) diff --git a/builds/cmake/ci_build.sh b/builds/cmake/ci_build.sh index b50bf9e2..53189ac7 100755 --- a/builds/cmake/ci_build.sh +++ b/builds/cmake/ci_build.sh @@ -23,16 +23,8 @@ if [ -z $CURVE ]; then elif [ $CURVE == "libsodium" ]; then CMAKE_OPTS+=("-DWITH_LIBSODIUM=ON") - if command -v dpkg-query >/dev/null 2>&1; then - dpkg-query --list libsodium-dev >/dev/null 2>&1 - HAVE_SODIUM=$? - elif command -v brew >/dev/null 2>&1; then - brew ls --versions libsodium >/dev/null 2>&1 - HAVE_SODIUM=$? - else - HAVE_SODIUM=1 - fi - if [ $HAVE_SODIUM -ne 0 ]; then + if ! ((command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libsodium-dev >/dev/null 2>&1) || \ + (command -v brew >/dev/null 2>&1 && brew ls --versions libsodium >/dev/null 2>&1)); then git clone --depth 1 -b stable git://github.com/jedisct1/libsodium.git ( cd libsodium; ./autogen.sh; ./configure --prefix=$BUILD_PREFIX; make check; make install) fi diff --git a/builds/coverage/ci_build.sh b/builds/coverage/ci_build.sh index c74b36a2..6b791e75 100755 --- a/builds/coverage/ci_build.sh +++ b/builds/coverage/ci_build.sh @@ -19,16 +19,8 @@ if [ -z $CURVE ]; then elif [ $CURVE == "libsodium" ]; then CMAKE_OPTS+=("-DWITH_LIBSODIUM=ON") - if command -v dpkg-query >/dev/null 2>&1; then - dpkg-query --list libsodium-dev >/dev/null 2>&1 - HAVE_SODIUM=$? - elif command -v brew >/dev/null 2>&1; then - brew ls --versions libsodium >/dev/null 2>&1 - HAVE_SODIUM=$? - else - HAVE_SODIUM=1 - fi - if [ $HAVE_SODIUM -ne 0 ]; then + if ! ((command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libsodium-dev >/dev/null 2>&1) || \ + (command -v brew >/dev/null 2>&1 && brew ls --versions libsodium >/dev/null 2>&1)); then git clone --depth 1 -b stable git://github.com/jedisct1/libsodium.git ( cd libsodium; ./autogen.sh; ./configure --prefix=$BUILD_PREFIX; make check; make install) fi diff --git a/builds/valgrind/ci_build.sh b/builds/valgrind/ci_build.sh index e9fea912..a90fb3c5 100755 --- a/builds/valgrind/ci_build.sh +++ b/builds/valgrind/ci_build.sh @@ -19,16 +19,8 @@ if [ -z $CURVE ]; then elif [ $CURVE == "libsodium" ]; then CONFIG_OPTS+=("--with-libsodium=yes") - if command -v dpkg-query >/dev/null 2>&1; then - dpkg-query --list libsodium-dev >/dev/null 2>&1 - HAVE_SODIUM=$? - elif command -v brew >/dev/null 2>&1; then - brew ls --versions libsodium >/dev/null 2>&1 - HAVE_SODIUM=$? - else - HAVE_SODIUM=1 - fi - if [ $HAVE_SODIUM -ne 0 ]; then + if ! ((command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libsodium-dev >/dev/null 2>&1) || \ + (command -v brew >/dev/null 2>&1 && brew ls --versions libsodium >/dev/null 2>&1)); then git clone --depth 1 -b stable git://github.com/jedisct1/libsodium.git ( cd libsodium; ./autogen.sh; ./configure --prefix=$BUILD_PREFIX; make check; make install) fi diff --git a/ci_build.sh b/ci_build.sh index 353bd6bd..15d2720d 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -20,16 +20,8 @@ if [ $BUILD_TYPE == "default" ]; then elif [ $CURVE == "libsodium" ]; then CONFIG_OPTS+=("--with-libsodium=yes") - if command -v dpkg-query >/dev/null 2>&1; then - dpkg-query --list libsodium-dev >/dev/null 2>&1 - HAVE_SODIUM=$? - elif command -v brew >/dev/null 2>&1; then - brew ls --versions libsodium >/dev/null 2>&1 - HAVE_SODIUM=$? - else - HAVE_SODIUM=1 - fi - if [ $HAVE_SODIUM -ne 0 ]; then + if ! ((command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libsodium-dev >/dev/null 2>&1) || \ + (command -v brew >/dev/null 2>&1 && brew ls --versions libsodium >/dev/null 2>&1)); then git clone --depth 1 -b stable git://github.com/jedisct1/libsodium.git ( cd libsodium; ./autogen.sh; ./configure --prefix=$BUILD_PREFIX; make check; make install) fi