Fix support for couchbase 4.x

This commit is contained in:
Shivam Mathur 2022-05-24 15:45:18 +05:30
parent 1dfe0dc4a4
commit 67ff09364d
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 58 additions and 63 deletions

View File

@ -1,5 +1,6 @@
amqp=amqp amqp=amqp
apcu=apcu apcu=apcu
couchbase=couchbase
expect=expect expect=expect
gnupg=gnupg gnupg=gnupg
grpc=grpc grpc=grpc

View File

@ -1,84 +1,78 @@
# Function to install libraries required by couchbase # Function to install libraries required by couchbase
add_couchbase_clibs() { add_couchbase_clibs() {
ext=$1 ext=$1
if [ "$(uname -s)" = "Linux" ]; then trunk="https://github.com/couchbase/libcouchbase/releases"
trunk="https://github.com/couchbase/libcouchbase/releases" if [[ "$ext" =~ couchbase-2.+ ]]; then
if [[ "$ext" =~ couchbase-2.+ ]]; then release="2.10.9"
release="2.10.9"
else
release="$(curl -sL $trunk/latest | grep -Eo "libcouchbase-[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 | cut -d'-' -f 2)"
fi
[ "$VERSION_ID" = "22.04" ] && vid=20.04 || vid="$VERSION_ID"
[ "$VERSION_CODENAME" = "jammy" ] && vcn=focal || vcn="$VERSION_CODENAME"
deb_url="$trunk/download/$release/libcouchbase-${release}_ubuntu${vid/./}_${vcn}_amd64.tar"
get -q -n /tmp/libcouchbase.tar "$deb_url"
sudo tar -xf /tmp/libcouchbase.tar -C /tmp
install_packages libev4 libevent-dev
sudo dpkg -i /tmp/libcouchbase-*/*.deb
else else
if [[ "$ext" =~ couchbase-2.+ ]]; then release="$(curl -sL $trunk/latest | grep -Eo "libcouchbase-[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 | cut -d'-' -f 2)"
brew install libcouchbase@2
brew link --overwrite --force libcouchbase@2
else
brew install libcouchbase
fi
fi fi
[ "$VERSION_ID" = "22.04" ] && vid=20.04 || vid="$VERSION_ID"
[ "$VERSION_CODENAME" = "jammy" ] && vcn=focal || vcn="$VERSION_CODENAME"
deb_url="$trunk/download/$release/libcouchbase-${release}_ubuntu${vid/./}_${vcn}_amd64.tar"
get -q -n /tmp/libcouchbase.tar "$deb_url"
sudo tar -xf /tmp/libcouchbase.tar -C /tmp
install_packages libev4 libevent-dev
sudo dpkg -i /tmp/libcouchbase-*/*.deb
} }
add_couchbase_cxxlibs() { add_couchbase_cxxlibs() {
if [ "$(uname -s)" = "Linux" ]; then if [ "$VERSION_ID" = "18.04" ]; then
if [ "$VERSION_ID" = "18.04" ]; then if ! command -v gcc-8 >/dev/null || ! command -v g++-8 >/dev/null; then
if ! command -v gcc-8 >/dev/null || ! command -v g++-8 >/dev/null; then install_packages gcc-8 g++-8 -y
install_packages gcc-8 g++-8 -y
fi
printf "gcc g++" | xargs -d ' ' -I {} sudo update-alternatives --install /usr/bin/{} {} /usr/bin/{}-8 8
fi fi
if [ "${runner:?}" = "self-hosted" ]; then printf "gcc g++" | xargs -d ' ' -I {} sudo update-alternatives --install /usr/bin/{} {} /usr/bin/{}-8 8
add_list cmake https://apt.kitware.com/ubuntu/ https://apt.kitware.com/keys/kitware-archive-latest.asc "$VERSION_CODENAME" main
fi
install_packages cmake ccache
else
brew install cmake ccache gcc
OPENSSL_ROOT_DIR="$(brew --prefix openssl@1.1)"
export OPENSSL_ROOT_DIR
export CC=gcc
export CXX=g++
fi fi
if [ "${runner:?}" = "self-hosted" ]; then
add_list cmake https://apt.kitware.com/ubuntu/ https://apt.kitware.com/keys/kitware-archive-latest.asc "$VERSION_CODENAME" main
fi
install_packages cmake ccache
} }
get_couchbase_version() { get_couchbase_version() {
if [[ "${version:?}" =~ ${old_versions:?} ]]; then if [[ "${version:?}" =~ ${old_versions:?} ]]; then
echo couchbase-2.2.3 echo couchbase-2.2.3
elif [[ "${version:?}" =~ 5.6|7.[0-1] ]]; then elif [[ "${version:?}" =~ 5.6|7.[0-1] ]]; then
echo couchbase-2.6.2 echo couchbase-2.6.2
elif [ "${version:?}" = '7.2' ]; then elif [ "${version:?}" = '7.2' ]; then
echo couchbase-3.0.4 echo couchbase-3.0.4
else elif [ "${version:?}" = '7.3' ]; then
echo couchbase-3.2.2 echo couchbase-3.2.2
fi else
# elif [ "${version:?}" = '7.3' ]; then echo couchbase
# echo couchbase-3.2.2 fi
# else
# echo couchbase
# fi
} }
# Function to add couchbase. # Function to add couchbase.
add_couchbase() { add_couchbase() {
ext=$1 ext=$1
if [ "$ext" = "couchbase" ]; then if [ "$(uname -s)" = "Linux" ]; then
ext=$(get_couchbase_version) if [ "$ext" = "couchbase" ]; then
fi ext=$(get_couchbase_version)
if [[ "$ext" =~ couchbase-[2-3].+ ]]; then fi
add_couchbase_clibs "$ext" >/dev/null 2>&1 if [[ "$ext" =~ couchbase-[2-3].+ ]]; then
add_couchbase_clibs "$ext" >/dev/null 2>&1
else
add_couchbase_cxxlibs >/dev/null 2>&1
fi
enable_extension "couchbase" "extension"
if check_extension "couchbase"; then
add_log "${tick:?}" "couchbase" "Enabled"
else
if [ "$ext" = "couchbase" ]; then
ext="couchbase-$(get_pecl_version "couchbase" "stable")"
add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl >/dev/null 2>&1
else
pecl_install "${ext}" >/dev/null 2>&1
fi
add_extension_log "couchbase" "Installed and enabled"
fi
else else
add_couchbase_cxxlibs >/dev/null 2>&1 if [ -e "${ext_dir:?}"/libcouchbase_php_core.dylib ]; then
fi couchbase_prefix="${brew_prefix:?}"/opt/couchbase@"$version"
enable_extension "couchbase" "extension" sudo mkdir -p "$couchbase_prefix"
if check_extension "couchbase"; then sudo cp "${ext_dir:?}"/libcouchbase_php_core.dylib "$couchbase_prefix"
add_log "${tick:?}" "couchbase" "Enabled" fi
else add_brew_extension couchbase extension
pecl_install "${ext}" >/dev/null 2>&1
add_extension_log "couchbase" "Installed and enabled"
fi fi
} }