From a094f682be8b2542570b3351124ef230a1f8f2a7 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 16 Nov 2020 18:05:08 +0530 Subject: [PATCH] Add support for couchbase --- __tests__/extensions.test.ts | 13 +++++++++++- dist/index.js | 6 ++++-- src/extensions.ts | 6 ++++-- src/scripts/ext/couchbase.sh | 40 ++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 src/scripts/ext/couchbase.sh diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 29d9ed94..aaac702b 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -81,11 +81,16 @@ describe('Extension tests', () => { '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'); linux = await extensions.addExtension('gearman', '7.4', 'linux'); 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'); expect(linux).toContain('add_cubrid pdo_cubrid'); linux = await extensions.addExtension('cubrid', '7.4', 'linux'); @@ -142,6 +147,12 @@ describe('Extension tests', () => { darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin'); 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'); expect(darwin).toContain('add_ioncube'); diff --git a/dist/index.js b/dist/index.js index 92522fbe..83dc03c9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2884,10 +2884,12 @@ async function addExtensionDarwin(extension_csv, version) { // match pdo_oci and oci8 // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // 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 /^pdo_oci$|^oci8$/.test(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 /^5\.6couchbase$|^7\.[0-4]couchbase$/.test(version_extension): add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin'); return; // match pre-release versions. For example - xdebug-beta @@ -3024,14 +3026,14 @@ async function addExtensionLinux(extension_csv, version) { // match pdo_oci and oci8 // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // 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-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension): case /^pdo_oci$|^oci8$/.test(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 /^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'); return; // match pre-release versions. For example - xdebug-beta diff --git a/src/extensions.ts b/src/extensions.ts index 7a0017e8..bb6f9e39 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -27,12 +27,14 @@ export async function addExtensionDarwin( // match pdo_oci and oci8 // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // 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 /^pdo_oci$|^oci8$/.test(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 /^5\.6couchbase$|^7\.[0-4]couchbase$/.test(version_extension): add_script += await utils.customPackage( ext_name, 'ext', @@ -219,7 +221,7 @@ export async function addExtensionLinux( // match pdo_oci and oci8 // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // 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 ): @@ -232,7 +234,7 @@ export async function addExtensionLinux( ): 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 /^((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', diff --git a/src/scripts/ext/couchbase.sh b/src/scripts/ext/couchbase.sh new file mode 100644 index 00000000..6b4829be --- /dev/null +++ b/src/scripts/ext/couchbase.sh @@ -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 +}