From 3c52e818b1658cb00ccae0351f24b02089f15c34 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sat, 8 Aug 2020 19:02:17 +0530 Subject: [PATCH] Add support for cubrid and pdo_cubrid on Ubuntu --- __tests__/extensions.test.ts | 5 ++++ dist/index.js | 2 ++ src/extensions.ts | 4 +++ src/scripts/ext/cubrid.sh | 50 ++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 src/scripts/ext/cubrid.sh diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 9401795d..740928a1 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -95,6 +95,11 @@ describe('Extension tests', () => { linux = await extensions.addExtension('gearman', '7.4', 'linux'); expect(linux).toContain('add_gearman'); + linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux'); + expect(linux).toContain('add_cubrid pdo_cubrid'); + linux = await extensions.addExtension('cubrid', '7.4', 'linux'); + expect(linux).toContain('add_cubrid cubrid'); + linux = await extensions.addExtension('xdebug', '7.2', 'fedora'); expect(linux).toContain('Platform fedora is not supported'); diff --git a/dist/index.js b/dist/index.js index 84628966..e017e9a7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3803,11 +3803,13 @@ async function addExtensionLinux(extension_csv, version, pipe) { return; // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 + // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid // 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 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\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): diff --git a/src/extensions.ts b/src/extensions.ts index 49c26070..cb6ec11a 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -233,6 +233,7 @@ export async function addExtensionLinux( return; // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 + // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid // match pdo_oci and oci8 // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 @@ -240,6 +241,9 @@ export async function addExtensionLinux( 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\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): diff --git a/src/scripts/ext/cubrid.sh b/src/scripts/ext/cubrid.sh new file mode 100644 index 00000000..b49c7f09 --- /dev/null +++ b/src/scripts/ext/cubrid.sh @@ -0,0 +1,50 @@ +# Function to log license details. +add_license_log() { + printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information" + printf "Cubrid CCI package is required for %s extension.\n" "$ext" + printf "The extension %s and Cubrid CCI are provided under the license linked below.\n" "$ext" + printf "Refer to: \033[35;1m%s \033[0m\n" "https://github.com/CUBRID/cubrid-cci/blob/develop/COPYING" + echo "::endgroup::" +} + +# Function to set cubrid repo for the extension. +set_cubrid_repo() { + case "${ext:?}" in + "cubrid") cubrid_repo="cubrid-php";; + "pdo_cubrid") cubrid_repo="cubrid-pdo";; + esac +} + +# Function to set cubrid branch for a PHP version. +set_cubrid_branch() { + case "${version:?}" in + 5.[3-6]) cubrid_branch="RB-9.3.0";; + *) cubrid_branch="develop";; + esac +} + +add_cubrid_helper() { + if ! [ -e "${ext_dir:?}/$ext.so" ]; then + status='Installed and enabled' + set_cubrid_repo + set_cubrid_branch + ( + git clone -b "$cubrid_branch" --recursive "https://github.com/CUBRID/$cubrid_repo" "/tmp/$cubrid_repo" + cd "/tmp/$cubrid_repo" || exit + ! [[ "$version" =~ ${old_versions:?} ]] && add_devtools + phpize && ./configure --with-php-config="$(command -v php-config)" --with-"${ext/_/-}"=shared + make -j"$(nproc)" + sudo make install + ) + echo "extension=$ext.so" | sudo tee "${scan_dir:?}/$ext.ini" + fi +} + +# Function to add cubrid and pdo_cubrid. +add_cubrid() { + ext=$1 + status='Enabled' + add_cubrid_helper >/dev/null 2>&1 + add_extension_log "$ext" "$status" + check_extension "$ext" && add_license_log +} \ No newline at end of file