Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use non sudo update_libchdb.sh #16

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chdb",
"version": "1.2.0",
"version": "1.2.1",
"description": "chDB bindings for nodejs",
"main": "index.js",
"repository": {
Expand All @@ -10,8 +10,8 @@
"scripts": {
"install": "npm run libchdb && npm run build",
"test": "mocha --timeout 15000",
"libchdb": "curl -sL https://lib.chdb.io | bash && cp -a /usr/local/lib/libchdb.so ./ && cp -a /usr/local/include/chdb.h ./",
"fixloaderpath": "./fix_loader_path.sh",
"libchdb": "bash ./update_libchdb.sh",
"fixloaderpath": "bash ./fix_loader_path.sh",
"build": "node-gyp configure build --verbose && npm run fixloaderpath"
},
"author": {
Expand Down
51 changes: 51 additions & 0 deletions update_libchdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# This script will download the latest libchdb release from GitHub and extract
# the libchdb.so file to the current directory. This script is intended to be
# used by the build process to ensure that the latest version of libchdb is
# used.

# Change directory to the script's directory
cd "$(dirname "$0")"

# Get the newest release version
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/chdb-io/chdb/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
# LATEST_RELEASE=v2.0.0b0

# Download the correct version based on the platform
case "$(uname -s)" in
Linux)
if [[ $(uname -m) == "aarch64" ]]; then
PLATFORM="linux-aarch64-libchdb.tar.gz"
else
PLATFORM="linux-x86_64-libchdb.tar.gz"
fi
;;
Darwin)
if [[ $(uname -m) == "arm64" ]]; then
PLATFORM="macos-arm64-libchdb.tar.gz"
else
PLATFORM="macos-x86_64-libchdb.tar.gz"
fi
;;
*)
echo "Unsupported platform"
exit 1
;;
esac

DOWNLOAD_URL="https://github.com/chdb-io/chdb/releases/download/$LATEST_RELEASE/$PLATFORM"

echo "Downloading $PLATFORM from $DOWNLOAD_URL"

# Download the file
curl -L -o libchdb.tar.gz $DOWNLOAD_URL

# Untar the file
tar -xzf libchdb.tar.gz

# Set execute permission for libchdb.so
chmod +x libchdb.so

# Clean up
rm -f libchdb.tar.gz
Loading