Skip to content

Commit

Permalink
Add a build script which downloads the latest SQLite source
Browse files Browse the repository at this point in the history
Recent SQLite source seems to be needed by gwenn/gosqlite, so this
script gets it all done.  This script is mostly just a copy of the
build script in the DBHub.io source code repo.
  • Loading branch information
justinclift committed Jan 7, 2024
1 parent 195b421 commit 4566cb4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ data/
.idea
config.toml
db4s_cluster_downloader
DB4S_downloads.sqlite
DB4S_downloads.sqlite
local
other
47 changes: 47 additions & 0 deletions build_db4s_downloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

# Useful variables
DEST=${PWD}/local
export PKG_CONFIG_PATH=${DEST}/lib/pkgconfig
export GOBIN=${DEST}/bin

# If this script is passed an argument of "clean", then delete the
# locally compiled pieces
if [ "$1" = "clean" ]; then
echo "Removing local SQLite and compiled DBHub.io executables"
rm -rf ${DEST} other/cache
exit
fi

# Builds a local SQLite
if [ ! -e "${DEST}/lib/libsqlite3.so" ]; then
if [ ! -d "other/cache" ]; then
mkdir -p other/cache
fi
cd other/cache || exit 1
if [ ! -f sqlite.tar.gz ]; then
echo "Downloading SQLite source code"
TARBALL=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 3)
SHA3=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 5)
curl -LsS -o sqlite.tar.gz https://sqlite.org/${TARBALL}
VERIFY=$(openssl dgst -sha3-256 sqlite.tar.gz | cut -d ' ' -f 2)
if [ "$SHA3" != "$VERIFY" ]; then exit 2 ; fi
fi
if [ ! -f sqlite.tar.gz ]; then
echo "Downloading the SQLite source code did not work"
exit 3
fi
echo "Compiling local SQLite"
tar xfz sqlite.tar.gz
cd sqlite-autoconf-* || exit 4
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
make -j "$(nproc)"
make install
cd ..
rm -rf sqlite-autoconf-*
cd ../..
fi

# Builds the Go binaries
echo "Compiling DB4S downloader daemon"
go install .

0 comments on commit 4566cb4

Please sign in to comment.