Skip to content

Commit

Permalink
build: new script for building own libsodium version.
Browse files Browse the repository at this point in the history
Plus connected to GA.
  • Loading branch information
furszy committed May 3, 2021
1 parent e7ca048 commit 4306b54
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
config:
- name: Linux
os: ubuntu-16.04
packages: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
packages: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev cargo
cc: gcc
cxx: g++

Expand Down Expand Up @@ -298,7 +298,7 @@ jobs:
- name: x86_64 Linux [GOAL:install] [xenial] [no depends only system libs]
os: ubuntu-16.04
host: x86_64-unknown-linux-gnu
apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev cargo
unit_tests: true
functional_tests: true
no_depends: 1
Expand All @@ -309,7 +309,7 @@ jobs:
- name: x86_64 Linux [GOAL:install] [bionic] [no depends only system libs]
os: ubuntu-18.04
host: x86_64-unknown-linux-gnu
apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev cargo
unit_tests: true
no_depends: 1
goal: install
Expand Down Expand Up @@ -399,6 +399,10 @@ jobs:
PARAMS_FLAGS="--with-params-dir=$PARAMS_DIR"
fi
echo "Installing libsodium.."
sudo ./contrib/install_sodium.sh `pwd`
echo "libsodium install finished.."
echo ::group::Autogen
./autogen.sh
echo ::endgroup::
Expand Down
84 changes: 84 additions & 0 deletions contrib/install_sodium.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/sh

# Install patched libsodium 1.0.17.

export LC_ALL=C
set -e

if [ -z "${1}" ]; then
echo "Usage: $0 <base-dir> [<extra-sodium-configure-flag> ...]"
echo
echo "Must specify a single argument: the directory in which sodium will be built."
echo "This is probably \`pwd\` if you're at the root of the pivx repository."
exit 1
fi

expand_path() {
echo "$(cd "${1}" && pwd -P)"
}

ROOT_PREFIX="$(expand_path ${1})";
SODIUM_PREFIX="$ROOT_PREFIX/sodium"; shift;
echo $SODIUM_PREFIX
echo $ROOT_PREFIX
SODIUM_VERSION='1.0.17'
SODIUM_HASH='0cc3dae33e642cc187b5ceb467e0ad0e1b51dcba577de1190e9ffa17766ac2b1'
SODIUM_URL="https://download.libsodium.org/libsodium/releases/libsodium-${SODIUM_VERSION}.tar.gz"

check_exists() {
which "$1" >/dev/null 2>&1
}

sha256_check() {
# Args: <sha256_hash> <filename>
#
if check_exists sha256sum; then
echo "${1} ${2}" | sha256sum -c
elif check_exists sha256; then
if [ "$(uname)" = "FreeBSD" ]; then
sha256 -c "${1}" "${2}"
else
echo "${1} ${2}" | sha256 -c
fi
else
echo "${1} ${2}" | shasum -a 256 -c
fi
}

http_get() {
# Args: <url> <filename> <sha256_hash>
#
# It's acceptable that we don't require SSL here because we manually verify
# content hashes below.
#
if [ -f "${2}" ]; then
echo "File ${2} already exists; not downloading again"
elif check_exists curl; then
curl --insecure --retry 5 "${1}" -o "${2}"
else
wget --no-check-certificate "${1}" -O "${2}"
fi

sha256_check "${3}" "${2}"
}

mkdir -p "${SODIUM_PREFIX}"
http_get "${SODIUM_URL}" "libsodium-${SODIUM_VERSION}.tar.gz" "${SODIUM_HASH}"
tar -xzvf libsodium-${SODIUM_VERSION}.tar.gz -C "$SODIUM_PREFIX"
cd "${SODIUM_PREFIX}/libsodium-${SODIUM_VERSION}/"

# Apply patches
echo "Applying patches.."
patch -p1 < "${ROOT_PREFIX}/depends/patches/libsodium/1.0.15-pubkey-validation.diff" && \
patch -p1 < "${ROOT_PREFIX}/depends/patches/libsodium/1.0.15-signature-validation.diff" && \
./autogen.sh

# make
"${SODIUM_PREFIX}/libsodium-${SODIUM_VERSION}/configure" --enable-static --disable-shared
make && make check

make install

echo
echo "sodium build complete."
echo

0 comments on commit 4306b54

Please sign in to comment.