Skip to content

Commit 9ecdb6d

Browse files
authored
Merge pull request #16 from chdb-io/fix-update-libchdb
Use non sudo update_libchdb.sh
2 parents f75803c + 4b9346a commit 9ecdb6d

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chdb",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "chDB bindings for nodejs",
55
"main": "index.js",
66
"repository": {
@@ -10,8 +10,8 @@
1010
"scripts": {
1111
"install": "npm run libchdb && npm run build",
1212
"test": "mocha --timeout 15000",
13-
"libchdb": "curl -sL https://lib.chdb.io | bash && cp -a /usr/local/lib/libchdb.so ./ && cp -a /usr/local/include/chdb.h ./",
14-
"fixloaderpath": "./fix_loader_path.sh",
13+
"libchdb": "bash ./update_libchdb.sh",
14+
"fixloaderpath": "bash ./fix_loader_path.sh",
1515
"build": "node-gyp configure build --verbose && npm run fixloaderpath"
1616
},
1717
"author": {

update_libchdb.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# This script will download the latest libchdb release from GitHub and extract
4+
# the libchdb.so file to the current directory. This script is intended to be
5+
# used by the build process to ensure that the latest version of libchdb is
6+
# used.
7+
8+
# Change directory to the script's directory
9+
cd "$(dirname "$0")"
10+
11+
# Get the newest release version
12+
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/chdb-io/chdb/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
13+
# LATEST_RELEASE=v2.0.0b0
14+
15+
# Download the correct version based on the platform
16+
case "$(uname -s)" in
17+
Linux)
18+
if [[ $(uname -m) == "aarch64" ]]; then
19+
PLATFORM="linux-aarch64-libchdb.tar.gz"
20+
else
21+
PLATFORM="linux-x86_64-libchdb.tar.gz"
22+
fi
23+
;;
24+
Darwin)
25+
if [[ $(uname -m) == "arm64" ]]; then
26+
PLATFORM="macos-arm64-libchdb.tar.gz"
27+
else
28+
PLATFORM="macos-x86_64-libchdb.tar.gz"
29+
fi
30+
;;
31+
*)
32+
echo "Unsupported platform"
33+
exit 1
34+
;;
35+
esac
36+
37+
DOWNLOAD_URL="https://github.com/chdb-io/chdb/releases/download/$LATEST_RELEASE/$PLATFORM"
38+
39+
echo "Downloading $PLATFORM from $DOWNLOAD_URL"
40+
41+
# Download the file
42+
curl -L -o libchdb.tar.gz $DOWNLOAD_URL
43+
44+
# Untar the file
45+
tar -xzf libchdb.tar.gz
46+
47+
# Set execute permission for libchdb.so
48+
chmod +x libchdb.so
49+
50+
# Clean up
51+
rm -f libchdb.tar.gz

0 commit comments

Comments
 (0)