Add support for couchbase

This commit is contained in:
Shivam Mathur 2020-11-16 18:05:08 +05:30
parent 45213ad923
commit a094f682be
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
4 changed files with 60 additions and 5 deletions

View File

@ -81,11 +81,16 @@ describe('Extension tests', () => {
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"' 'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
); );
linux = await extensions.addExtension('gearman', '7.0', 'linux'); linux = await extensions.addExtension('gearman', '5.6', 'linux');
expect(linux).toContain('add_gearman'); expect(linux).toContain('add_gearman');
linux = await extensions.addExtension('gearman', '7.4', 'linux'); linux = await extensions.addExtension('gearman', '7.4', 'linux');
expect(linux).toContain('add_gearman'); expect(linux).toContain('add_gearman');
linux = await extensions.addExtension('couchbase', '5.6', 'linux');
expect(linux).toContain('add_couchbase');
linux = await extensions.addExtension('couchbase', '7.4', 'linux');
expect(linux).toContain('add_couchbase');
linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux'); linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux');
expect(linux).toContain('add_cubrid pdo_cubrid'); expect(linux).toContain('add_cubrid pdo_cubrid');
linux = await extensions.addExtension('cubrid', '7.4', 'linux'); linux = await extensions.addExtension('cubrid', '7.4', 'linux');
@ -142,6 +147,12 @@ describe('Extension tests', () => {
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin'); darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
expect(darwin).toContain('add_phalcon phalcon4'); expect(darwin).toContain('add_phalcon phalcon4');
darwin = await extensions.addExtension('couchbase', '5.6', 'darwin');
expect(darwin).toContain('add_couchbase');
darwin = await extensions.addExtension('couchbase', '7.3', 'darwin');
expect(darwin).toContain('add_couchbase');
darwin = await extensions.addExtension('ioncube', '7.3', 'darwin'); darwin = await extensions.addExtension('ioncube', '7.3', 'darwin');
expect(darwin).toContain('add_ioncube'); expect(darwin).toContain('add_ioncube');

6
dist/index.js vendored
View File

@ -2884,10 +2884,12 @@ async function addExtensionDarwin(extension_csv, version) {
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6couchbase...7.4couchbase
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^5\.6couchbase$|^7\.[0-4]couchbase$/.test(version_extension):
add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin'); add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin');
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
@ -3024,14 +3026,14 @@ async function addExtensionLinux(extension_csv, version) {
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6gearman..7.4gearman // match 5.6gearman...7.4gearman, 5.6couchbase...7.4couchbase
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension): case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension):
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
case /^5\.6intl-[\d]+\.[\d]+$|^7\.[0-4]intl-[\d]+\.[\d]+$/.test(version_extension): case /^5\.6intl-[\d]+\.[\d]+$|^7\.[0-4]intl-[\d]+\.[\d]+$/.test(version_extension):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))(gearman|couchbase)$/.test(version_extension):
add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux'); add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux');
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta

View File

@ -27,12 +27,14 @@ export async function addExtensionDarwin(
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6couchbase...7.4couchbase
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^5\.6couchbase$|^7\.[0-4]couchbase$/.test(version_extension):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'ext', 'ext',
@ -219,7 +221,7 @@ export async function addExtensionLinux(
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6gearman..7.4gearman // match 5.6gearman...7.4gearman, 5.6couchbase...7.4couchbase
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
@ -232,7 +234,7 @@ export async function addExtensionLinux(
): ):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))(gearman|couchbase)$/.test(version_extension):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'ext', 'ext',

View File

@ -0,0 +1,40 @@
# Function to install libraries required by couchbase
add_couchbase_libs() {
if [ "$(uname -s)" = "Linux" ]; then
if [[ ${version:?} =~ 5.6|7.[0-1] ]]; then
trunk="http://packages.couchbase.com/ubuntu"
list="deb $trunk ${DISTRIB_CODENAME:?} ${DISTRIB_CODENAME:?}/main"
else
trunk="http://packages.couchbase.com/clients/c/repos/deb"
list="deb $trunk/ubuntu${DISTRIB_RELEASE/./} ${DISTRIB_CODENAME:?} ${DISTRIB_CODENAME:?}/main"
fi
add_pecl
get -s -n "" "$trunk/couchbase.key" | sudo apt-key add
echo "$list" | sudo tee /etc/apt/sources.list.d/couchbase.list
sudo apt-get update
${apt_install:?} libcouchbase-dev
else
if [[ ${version:?} =~ 5.6|7.[0-1] ]]; then
brew install libcouchbase@2
brew link --overwrite --force libcouchbase@2
else
brew install libcouchbase
fi
fi
}
# Function to add couchbase.
add_couchbase() {
add_couchbase_libs >/dev/null 2>&1
enable_extension "couchbase" "extension"
if check_extension "couchbase"; then
add_log "${tick:?}" "couchbase" "Enabled"
else
if [[ ${version:?} =~ 5.6|7.[0-1] ]]; then
pecl_install couchbase-2.6.2 >/dev/null 2>&1
else
pecl_install couchbase >/dev/null 2>&1
fi
add_extension_log "couchbase" "Installed and enabled"
fi
}