Browse Source

Add error checking to libsodium build

pull/38/head
Duke Leto 3 years ago
parent
commit
fc474d797d
  1. 27
      res/libsodium/buildlibsodium.sh

27
res/libsodium/buildlibsodium.sh

@ -1,33 +1,45 @@
#!/bin/bash #!/bin/bash
# Copyright 2019-2021 The Hush developers # Copyright 2019-2021 The Hush developers
# Released under the GPLv3 # Released under the GPLv3
VERSION=1.0.18
# First thing to do is see if libsodium.a exists in the res folder. If it does, then there's nothing to do # First thing to do is see if libsodium.a exists in the res folder. If it does, then there's nothing to do
if [ -f res/libsodium.a ]; then if [ -f res/libsodium.a ]; then
echo "libsodium is already built! Nothing to do" echo "libsodium $VERSION is already built! Nothing to do"
exit 0 exit 0
fi fi
echo "Building libsodium" echo "Building libsodium $VERSION"
# Go into the lib sodium directory # Go into the lib sodium directory
cd res/libsodium cd res/libsodium
if [ ! -f libsodium-1.0.18.tar.gz ]; then if [ ! -f libsodium-1.0.18.tar.gz ]; then
echo "Downloading libsodium" echo "Downloading libsodium $VERSION"
curl -LO https://github.com/MyHush/libsodium/releases/download/1.0.18/libsodium-1.0.18.tar.gz curl -LO https://github.com/MyHush/libsodium/releases/download/1.0.18/libsodium-1.0.18.tar.gz
fi fi
# TODO: check libsodium downloaded correctly if [ ! -f libsodium-1.0.18.tar.gz ]; then
echo "Unable to download libsodium $VERSION !!! Aborting"
exit 1
fi
if [ ! -d libsodium-1.0.18 ]; then if [ ! -d libsodium-1.0.18 ]; then
echo "Unpacking libsodium" echo "Unpacking libsodium $VERSION"
tar xf libsodium-1.0.18.tar.gz tar xf libsodium-1.0.18.tar.gz
fi fi
if [ ! -d libsodium-1.0.18 ]; then
echo "Unable to unpack libsodium $VERSION !!! Aborting"
exit 1
fi
# Now build it # Now build it
cd libsodium-1.0.18 cd libsodium-1.0.18
echo "Configuring libsodium $VERSION"
LIBS="" ./configure LIBS="" ./configure
make clean make clean
echo "Compiling libsodium $VERSION"
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
make CFLAGS="-mmacosx-version-min=10.11" CPPFLAGS="-mmacosx-version-min=10.11" -j4 make CFLAGS="-mmacosx-version-min=10.11" CPPFLAGS="-mmacosx-version-min=10.11" -j4
else else
@ -35,5 +47,10 @@ else
fi fi
cd .. cd ..
if [ ! -e libsodium-1.0.18/src/libsodium/.libs/libsodium.a ]; then
echo "Unable to compile libsodium $VERSION !!! Aborting"
exit 1
fi
# copy the library to the parents's res/ folder # copy the library to the parents's res/ folder
cp libsodium-1.0.18/src/libsodium/.libs/libsodium.a ../ cp libsodium-1.0.18/src/libsodium/.libs/libsodium.a ../

Loading…
Cancel
Save