@@ -12,17 +12,42 @@ GREEN="\e[92m"
1212RED=" \e[91m"
1313DEFAULT=" \e[0m"
1414
15+ # Function to extract version using pkg-config
16+ extract_version_from_pkgconfig () {
17+ local pkgconfig_path=" cpp/.ext/deeplake_api/lib/pkgconfig"
18+
19+ if [ ! -d " $pkgconfig_path " ]; then
20+ echo -e " ${RED} Error: pkg-config directory not found at $pkgconfig_path ${DEFAULT} " >&2
21+ echo -e " ${RED} Make sure the DeepLake API library is downloaded first.${DEFAULT} " >&2
22+ exit 1
23+ fi
24+
25+ # Set PKG_CONFIG_PATH and query version
26+ local version=$( PKG_CONFIG_PATH=" $pkgconfig_path " pkg-config --modversion deeplake_api 2> /dev/null)
27+
28+ if [ -z " $version " ]; then
29+ echo -e " ${RED} Error: Could not extract version using pkg-config${DEFAULT} " >&2
30+ exit 1
31+ fi
32+
33+ echo " $version "
34+ }
35+
1536# Define usage function
1637usage () {
17- echo -e " Usage: bash $0 <version-release> <repository> <architecture> <gpg-keyid> <supported-versions>\n\
18- For example: bash $0 1.2.5-2 /tmp/repo arm64 1F8B584DBEA11E9D"
38+ echo -e " Usage: bash $0 [version-release] <repository> <architecture> <gpg-keyid> <supported-versions>"
39+ echo -e " \nArguments:"
40+ echo -e " version-release: Optional. Version with release suffix (e.g., 4.4.4-1)."
41+ echo -e " If not provided, version is extracted from DeepLake API pkg-config."
42+ echo -e " repository: Repository directory path"
43+ echo -e " architecture: amd64 or arm64"
44+ echo -e " gpg-keyid: GPG key ID for signing"
45+ echo -e " supported-versions: Comma-separated PostgreSQL versions (e.g., 16,17,18)"
46+ echo -e " \nExamples:"
47+ echo -e " bash $0 4.4.4-1 /tmp/repo arm64 1F8B584DBEA11E9D 16,17,18"
48+ echo -e " bash $0 /tmp/repo arm64 1F8B584DBEA11E9D 16,17,18 # Auto-detect version"
1949}
2050
21- # Check if the arguments are passed
22- if [ " $# " -ne 5 ]; then
23- usage && exit 1
24- fi
25-
2651# Error handling function
2752if_failed () {
2853 if [ $? -ne 0 ]; then
@@ -32,12 +57,30 @@ if_failed() {
3257 fi
3358}
3459
35- VERSION=$1
36- REPOSITORY=$2
37- ARCH=$3
38- GPG_KEY=$4
60+ # Parse arguments (support both 4 and 5 argument formats)
61+ if [ " $# " -eq 4 ]; then
62+ # Auto-extract version from pkg-config
63+ echo -e " ${YELLOW} Extracting version from DeepLake API pkg-config...${DEFAULT} "
64+ AUTO_VERSION=$( extract_version_from_pkgconfig)
65+ VERSION=" ${AUTO_VERSION} -1" # Default to -1 release suffix
66+ echo -e " ${GREEN} Detected version: ${VERSION}${DEFAULT} \n"
67+ REPOSITORY=$1
68+ ARCH=$2
69+ GPG_KEY=$3
70+ SUPPORTED_VERSIONS_ARG=$4
71+ elif [ " $# " -eq 5 ]; then
72+ # Use provided version
73+ VERSION=$1
74+ REPOSITORY=$2
75+ ARCH=$3
76+ GPG_KEY=$4
77+ SUPPORTED_VERSIONS_ARG=$5
78+ else
79+ usage && exit 1
80+ fi
81+
3982CLEAN_VERSION=${VERSION/ -*/ }
40- readarray -t -d' ,' SUPPORTED_VERSIONS < <( printf " %s" " $5 " )
83+ readarray -t -d' ,' SUPPORTED_VERSIONS < <( printf " %s" " $SUPPORTED_VERSIONS_ARG " )
4184
4285# Determine artifact directory
4386if [ " ${ARCH} " == " amd64" ]; then
0 commit comments