|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Useful variables |
| 4 | +DEST=${PWD}/local |
| 5 | +export PKG_CONFIG_PATH=${DEST}/lib/pkgconfig |
| 6 | +export GOBIN=${DEST}/bin |
| 7 | + |
| 8 | +# If this script is passed an argument of "clean", then delete the |
| 9 | +# locally compiled pieces |
| 10 | +if [ "$1" = "clean" ]; then |
| 11 | + echo "Removing local SQLite and compiled DBHub.io executables" |
| 12 | + rm -rf ${DEST} other/cache |
| 13 | + exit |
| 14 | +fi |
| 15 | + |
| 16 | +# Builds a local SQLite |
| 17 | +if [ ! -e "${DEST}/lib/libsqlite3.so" ]; then |
| 18 | + if [ ! -d "other/cache" ]; then |
| 19 | + mkdir -p other/cache |
| 20 | + fi |
| 21 | + cd other/cache || exit 1 |
| 22 | + if [ ! -f sqlite.tar.gz ]; then |
| 23 | + echo "Downloading SQLite source code" |
| 24 | + TARBALL=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 3) |
| 25 | + SHA3=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 5) |
| 26 | + curl -LsS -o sqlite.tar.gz https://sqlite.org/${TARBALL} |
| 27 | + VERIFY=$(openssl dgst -sha3-256 sqlite.tar.gz | cut -d ' ' -f 2) |
| 28 | + if [ "$SHA3" != "$VERIFY" ]; then exit 2 ; fi |
| 29 | + fi |
| 30 | + if [ ! -f sqlite.tar.gz ]; then |
| 31 | + echo "Downloading the SQLite source code did not work" |
| 32 | + exit 3 |
| 33 | + fi |
| 34 | + echo "Compiling local SQLite" |
| 35 | + tar xfz sqlite.tar.gz |
| 36 | + cd sqlite-autoconf-* || exit 4 |
| 37 | + CPPFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_STAT4=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DSQLITE_MAX_ATTACHED=125 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_SNAPSHOT=1" ./configure --prefix=${DEST} --enable-dynamic-extensions=no |
| 38 | + make -j "$(nproc)" |
| 39 | + make install |
| 40 | + cd .. |
| 41 | + rm -rf sqlite-autoconf-* |
| 42 | + cd ../.. |
| 43 | +fi |
| 44 | + |
| 45 | +# Builds the Go binaries |
| 46 | +echo "Compiling DB4S downloader daemon" |
| 47 | +go install . |
0 commit comments