Skip to content

Commit bbae5d0

Browse files
committed
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
1 parent b2a2bb8 commit bbae5d0

File tree

4 files changed

+8
-40
lines changed

4 files changed

+8
-40
lines changed

builds/cmake/ci_build.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,8 @@ if [ -z $CURVE ]; then
2323
elif [ $CURVE == "libsodium" ]; then
2424
CMAKE_OPTS+=("-DWITH_LIBSODIUM=ON")
2525

26-
if command -v dpkg-query >/dev/null 2>&1; then
27-
dpkg-query --list libsodium-dev >/dev/null 2>&1
28-
HAVE_SODIUM=$?
29-
elif command -v brew >/dev/null 2>&1; then
30-
brew ls --versions libsodium >/dev/null 2>&1
31-
HAVE_SODIUM=$?
32-
else
33-
HAVE_SODIUM=1
34-
fi
35-
if [ $HAVE_SODIUM -ne 0 ]; then
26+
if ! ((command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libsodium-dev >/dev/null 2>&1) || \
27+
(command -v brew >/dev/null 2>&1 && brew ls --versions libsodium >/dev/null 2>&1)); then
3628
git clone --depth 1 -b stable git://github.com/jedisct1/libsodium.git
3729
( cd libsodium; ./autogen.sh; ./configure --prefix=$BUILD_PREFIX; make check; make install)
3830
fi

builds/coverage/ci_build.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,8 @@ if [ -z $CURVE ]; then
1919
elif [ $CURVE == "libsodium" ]; then
2020
CMAKE_OPTS+=("-DWITH_LIBSODIUM=ON")
2121

22-
if command -v dpkg-query >/dev/null 2>&1; then
23-
dpkg-query --list libsodium-dev >/dev/null 2>&1
24-
HAVE_SODIUM=$?
25-
elif command -v brew >/dev/null 2>&1; then
26-
brew ls --versions libsodium >/dev/null 2>&1
27-
HAVE_SODIUM=$?
28-
else
29-
HAVE_SODIUM=1
30-
fi
31-
if [ $HAVE_SODIUM -ne 0 ]; then
22+
if ! ((command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libsodium-dev >/dev/null 2>&1) || \
23+
(command -v brew >/dev/null 2>&1 && brew ls --versions libsodium >/dev/null 2>&1)); then
3224
git clone --depth 1 -b stable git://github.com/jedisct1/libsodium.git
3325
( cd libsodium; ./autogen.sh; ./configure --prefix=$BUILD_PREFIX; make check; make install)
3426
fi

builds/valgrind/ci_build.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,8 @@ if [ -z $CURVE ]; then
1919
elif [ $CURVE == "libsodium" ]; then
2020
CONFIG_OPTS+=("--with-libsodium=yes")
2121

22-
if command -v dpkg-query >/dev/null 2>&1; then
23-
dpkg-query --list libsodium-dev >/dev/null 2>&1
24-
HAVE_SODIUM=$?
25-
elif command -v brew >/dev/null 2>&1; then
26-
brew ls --versions libsodium >/dev/null 2>&1
27-
HAVE_SODIUM=$?
28-
else
29-
HAVE_SODIUM=1
30-
fi
31-
if [ $HAVE_SODIUM -ne 0 ]; then
22+
if ! ((command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libsodium-dev >/dev/null 2>&1) || \
23+
(command -v brew >/dev/null 2>&1 && brew ls --versions libsodium >/dev/null 2>&1)); then
3224
git clone --depth 1 -b stable git://github.com/jedisct1/libsodium.git
3325
( cd libsodium; ./autogen.sh; ./configure --prefix=$BUILD_PREFIX; make check; make install)
3426
fi

ci_build.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,8 @@ if [ $BUILD_TYPE == "default" ]; then
2020
elif [ $CURVE == "libsodium" ]; then
2121
CONFIG_OPTS+=("--with-libsodium=yes")
2222

23-
if command -v dpkg-query >/dev/null 2>&1; then
24-
dpkg-query --list libsodium-dev >/dev/null 2>&1
25-
HAVE_SODIUM=$?
26-
elif command -v brew >/dev/null 2>&1; then
27-
brew ls --versions libsodium >/dev/null 2>&1
28-
HAVE_SODIUM=$?
29-
else
30-
HAVE_SODIUM=1
31-
fi
32-
if [ $HAVE_SODIUM -ne 0 ]; then
23+
if ! ((command -v dpkg-query >/dev/null 2>&1 && dpkg-query --list libsodium-dev >/dev/null 2>&1) || \
24+
(command -v brew >/dev/null 2>&1 && brew ls --versions libsodium >/dev/null 2>&1)); then
3325
git clone --depth 1 -b stable git://github.com/jedisct1/libsodium.git
3426
( cd libsodium; ./autogen.sh; ./configure --prefix=$BUILD_PREFIX; make check; make install)
3527
fi

0 commit comments

Comments
 (0)