mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-11-26 00:56:45 +07:00
Add support for ibm extensions [skip ci]
This commit is contained in:
@ -215,7 +215,7 @@ This disables all core and third-party shared extensions and thus, can break som
|
||||
- These extensions have custom support:
|
||||
- `cubrid` and `pdo_cubrid` on `Ubuntu`.
|
||||
- `event`, `gearman`, `geos` and `relay` on `Ubuntu` and `macOS`.
|
||||
- `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4`, `phalcon5`, and `zephir_parser` on all supported OS.
|
||||
- `blackfire`, `couchbase`, `ibm_db2`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_ibm`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4`, `phalcon5`, and `zephir_parser` on all supported OS.
|
||||
|
||||
- By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
|
||||
|
||||
|
||||
@ -18,6 +18,8 @@ describe('Extension tests', () => {
|
||||
${'oci8'} | ${'7.4'} | ${'Add-Oci oci8'}
|
||||
${'pcov'} | ${'5.6'} | ${'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
|
||||
${'pdo_oci'} | ${'7.4'} | ${'Add-Oci pdo_oci'}
|
||||
${'ibm_db2'} | ${'7.4'} | ${'Add-Ibm ibm_db2'}
|
||||
${'pdo_ibm'} | ${'7.4'} | ${'Add-Ibm pdo_ibm'}
|
||||
${'pecl_http'} | ${'7.4'} | ${'Add-Http'}
|
||||
${'pdo_sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv pdo_sqlsrv'}
|
||||
${'phalcon3'} | ${'7.2'} | ${'Add-Phalcon phalcon3'}
|
||||
@ -56,11 +58,13 @@ describe('Extension tests', () => {
|
||||
${'mongodb-mongodb/mongo-php-driver@master'} | ${'7.3'} | ${'add_extension_from_source mongodb https://github.com mongodb mongo-php-driver master extension'}
|
||||
${'oci8'} | ${'7.3'} | ${'add_oci oci8'}
|
||||
${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6'}
|
||||
${'ibm_db2'} | ${'7.3'} | ${'add_ibm ibm_db2'}
|
||||
${'pdo-odbc'} | ${'7.4'} | ${'add_pdo_extension odbc'}
|
||||
${'pdo_cubrid'} | ${'7.0'} | ${'add_cubrid pdo_cubrid'}
|
||||
${'pdo_cubrid'} | ${'7.4'} | ${'add_pdo_extension cubrid'}
|
||||
${'pdo_mysql'} | ${'7.4'} | ${'add_pdo_extension mysql'}
|
||||
${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'}
|
||||
${'pdo_ibm'} | ${'7.3'} | ${'add_ibm pdo_ibm'}
|
||||
${'pdo_sqlsrv'} | ${'7.4'} | ${'add_sqlsrv pdo_sqlsrv'}
|
||||
${'pecl_http'} | ${'7.3'} | ${'add_http'}
|
||||
${'phalcon3'} | ${'7.3'} | ${'add_phalcon phalcon3'}
|
||||
|
||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -34,7 +34,7 @@ export async function addExtensionDarwin(
|
||||
// match 7.4relay...8.5relay
|
||||
// match 5.3blackfire...8.4blackfire
|
||||
// match 5.3blackfire-(semver)...8.4blackfire-(semver)
|
||||
// match couchbase, event, geos, pdo_oci, oci8, http, pecl_http
|
||||
// match couchbase, event, geos, ibm_db2, pdo_ibm, pdo_oci, oci8, http, pecl_http
|
||||
// match 5.3ioncube...8.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.4phalcon5
|
||||
// match 7.0zephir_parser...8.4zephir_parser
|
||||
@ -44,7 +44,7 @@ export async function addExtensionDarwin(
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||
version_extension
|
||||
):
|
||||
case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
|
||||
case /^couchbase|^event|^gearman$|^geos$|^ibm_db2$|^pdo_ibm$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
|
||||
extension
|
||||
):
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.[0-4])ioncube$/.test(version_extension):
|
||||
@ -138,7 +138,7 @@ export async function addExtensionWindows(
|
||||
break;
|
||||
// match 5.3blackfire...8.4blackfire
|
||||
// match 5.3blackfire-(semver)...8.4blackfire-(semver)
|
||||
// match pdo_oci and oci8
|
||||
// match ibm_db2, pdo_ibm, pdo_oci and oci8
|
||||
// match 5.3ioncube...8.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.4phalcon5
|
||||
// match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http
|
||||
@ -146,7 +146,9 @@ export async function addExtensionWindows(
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||
version_extension
|
||||
):
|
||||
case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
|
||||
case /^ibm_db2$|^pdo_ibm$|^pdo_oci$|^oci8$|^pdo_firebird$/.test(
|
||||
extension
|
||||
):
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.[0-4])ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-4])phalcon5?$/.test(
|
||||
version_extension
|
||||
@ -269,7 +271,7 @@ export async function addExtensionLinux(
|
||||
// match 5.3blackfire...8.4blackfire
|
||||
// match 5.3blackfire-(semver)...8.4blackfire-(semver)
|
||||
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
|
||||
// match couchbase, geos, pdo_oci, oci8, http, pecl_http
|
||||
// match couchbase, geos, ibm_db2, pdo_ibm, pdo_oci, oci8, http, pecl_http
|
||||
// match 5.3ioncube...8.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.4phalcon5
|
||||
// match 7.0zephir_parser...8.4zephir_parser
|
||||
@ -282,7 +284,7 @@ export async function addExtensionLinux(
|
||||
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(
|
||||
version_extension
|
||||
):
|
||||
case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
|
||||
case /^couchbase|^event|^gearman$|^geos$|^ibm_db2$|^pdo_ibm$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
|
||||
extension
|
||||
):
|
||||
case /(?<!5\.[3-5])intl-\d+\.\d+$/.test(version_extension):
|
||||
|
||||
52
src/scripts/extensions/ibm.ps1
Normal file
52
src/scripts/extensions/ibm.ps1
Normal file
@ -0,0 +1,52 @@
|
||||
# Function to log license information for ibm extensions.
|
||||
Function Add-LicenseLog() {
|
||||
printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information"
|
||||
printf "IBM Db2 ODBC and CLI Driver is required for %s extension.\n" $extension
|
||||
printf "It is provided under the IBM International Program License Agreement.\n"
|
||||
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.ibm.com/support/pages/db2-odbc-cli-driver-download-and-installation-information"
|
||||
$licensePath = "$php_dir\clidriver\license\odbc_notices.txt"
|
||||
if (Test-Path $licensePath) {
|
||||
Get-Content -Path $licensePath
|
||||
}
|
||||
Write-Output "$env:END_GROUP"
|
||||
}
|
||||
|
||||
# Function to install IBM Db2 CLI driver.
|
||||
Function Add-IbmCli() {
|
||||
$cliPath = "$php_dir\clidriver"
|
||||
if (-not (Test-Path "$cliPath\bin")) {
|
||||
$suffix = if ($arch -eq 'x86') { 'nt32' } else { 'ntx64' }
|
||||
$archive = "$suffix`_odbc_cli.zip"
|
||||
$destination = "$ENV:RUNNER_TOOL_CACHE\ibm_cli.zip"
|
||||
Get-File -Url "https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/$archive" -OutFile $destination > $null 2>&1
|
||||
Expand-Archive -Path $destination -DestinationPath $php_dir -Force > $null 2>&1
|
||||
}
|
||||
$env:IBM_DB_HOME = $cliPath
|
||||
$env:PATH = "$cliPath\bin;$env:PATH"
|
||||
$env:LD_LIBRARY_PATH = "$cliPath\bin;$cliPath\lib;$env:LD_LIBRARY_PATH"
|
||||
}
|
||||
|
||||
# Function to install ibm_db2 and pdo_ibm.
|
||||
Function Add-Ibm() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[ValidateSet('ibm_db2', 'pdo_ibm')]
|
||||
[string]
|
||||
$extension
|
||||
)
|
||||
try {
|
||||
$status = 'Enabled'
|
||||
Add-IbmCli
|
||||
if (Test-Path "$ext_dir\php_$extension.dll") {
|
||||
Enable-PhpExtension -Extension $extension -Path $php_dir
|
||||
} else {
|
||||
Add-Extension $extension >$null 2>&1
|
||||
$status = 'Installed and enabled'
|
||||
}
|
||||
Add-ExtensionLog $extension $status
|
||||
Add-LicenseLog
|
||||
} catch {
|
||||
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
|
||||
}
|
||||
}
|
||||
106
src/scripts/extensions/ibm.sh
Normal file
106
src/scripts/extensions/ibm.sh
Normal file
@ -0,0 +1,106 @@
|
||||
# Function to log license details for ibm extensions.
|
||||
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 "IBM Db2 ODBC and CLI Driver is required for %s extension.\n" "$ext"
|
||||
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.ibm.com/support/pages/db2-odbc-cli-driver-download-and-installation-information"
|
||||
local license_file="$ibm_cli/license/odbc_notices.txt"
|
||||
if [ -f "$license_file" ]; then
|
||||
cat "$license_file"
|
||||
fi
|
||||
echo "$END_GROUP"
|
||||
}
|
||||
|
||||
# Function to determine the driver archive for the current platform.
|
||||
get_cli_archive() {
|
||||
local os=$1
|
||||
local arch=$2
|
||||
case $os in
|
||||
Linux)
|
||||
case $arch in
|
||||
x86_64|amd64) echo "linuxx64_odbc_cli.tar.gz";;
|
||||
i?86) echo "linuxia32_odbc_cli.tar.gz";;
|
||||
*) return 1;;
|
||||
esac
|
||||
;;
|
||||
Darwin)
|
||||
case $arch in
|
||||
x86_64) echo "macos64_odbc_cli.tar.gz";;
|
||||
arm64|aarch64) echo "macarm64_odbc_cli.tar.gz";;
|
||||
*) return 1;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to install IBM Db2 CLI driver.
|
||||
add_cli_driver() {
|
||||
local os arch archive url tmp libs
|
||||
if [ -d "$ibm_cli" ]; then
|
||||
return 0
|
||||
fi
|
||||
os=$(uname -s)
|
||||
arch=$(uname -m)
|
||||
archive=$(get_cli_archive "$os" "$arch") || return 1
|
||||
url="https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/$archive"
|
||||
tmp=/tmp/$archive
|
||||
get -q -n "$tmp" "$url"
|
||||
sudo mkdir -p "$ibm_home"
|
||||
sudo tar -xzf "$tmp" -C "$ibm_home"
|
||||
sudo rm -f "$tmp"
|
||||
if [ ! -d "$ibm_cli" ]; then
|
||||
local extracted
|
||||
extracted=$(find "$ibm_home" -maxdepth 1 -type d -name 'clidriver*' | head -n 1)
|
||||
[ -n "$extracted" ] && sudo mv "$extracted" "$ibm_cli"
|
||||
fi
|
||||
if [ "$os" = "Linux" ]; then
|
||||
echo "$ibm_cli/lib" | sudo tee /etc/ld.so.conf.d/ibm_db2.conf >/dev/null
|
||||
sudo ldconfig
|
||||
else
|
||||
libs='/usr/local/lib'
|
||||
sudo mkdir -p "$libs"
|
||||
sudo ln -sf "$ibm_cli"/lib/*.dylib "$libs" >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to install ibm_db2 and pdo_ibm.
|
||||
add_ibm_helper() {
|
||||
if ! shared_extension "$ext"; then
|
||||
status='Installed and enabled'
|
||||
export IBM_DB_HOME="$ibm_cli"
|
||||
export LD_LIBRARY_PATH="$IBM_DB_HOME/lib:${LD_LIBRARY_PATH:-}"
|
||||
export DYLD_LIBRARY_PATH="$IBM_DB_HOME/lib:${DYLD_LIBRARY_PATH:-}"
|
||||
local configure_flag
|
||||
if [ "$ext" = 'ibm_db2' ]; then
|
||||
configure_flag="--with-IBM_DB2=$IBM_DB_HOME"
|
||||
else
|
||||
configure_flag="--with-pdo-ibm=$IBM_DB_HOME"
|
||||
fi
|
||||
read -r "${ext}_CONFIGURE_OPTS" <<< "--with-php-config=$(command -v php-config) $configure_flag"
|
||||
patch_phpize
|
||||
add_extension_from_source "$ext" https://github.com php "pecl-database-$ext" master extension get
|
||||
restore_phpize
|
||||
else
|
||||
enable_extension "$ext" extension
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to add ibm_db2 and pdo_ibm.
|
||||
add_ibm() {
|
||||
ext=$1
|
||||
status='Enabled'
|
||||
ibm_home='/opt/ibm'
|
||||
ibm_cli=$ibm_home/clidriver
|
||||
if ! add_cli_driver >/dev/null 2>&1; then
|
||||
add_log "${cross:?}" "$ext" "IBM Db2 CLI driver is not available on $(uname -s)/$(uname -m)"
|
||||
return 1
|
||||
fi
|
||||
add_ibm_helper >/dev/null 2>&1
|
||||
add_extension_log "$ext" "$status"
|
||||
check_extension "$ext" && add_license_log
|
||||
}
|
||||
|
||||
# shellcheck source=.
|
||||
. "${scripts:?}"/extensions/patches/phpize.sh
|
||||
@ -400,7 +400,7 @@ export async function customPackage(
|
||||
version: string,
|
||||
os: string
|
||||
): Promise<string> {
|
||||
const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
||||
const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]|[_-]db2/, '');
|
||||
const script_extension: string = await scriptExtension(os);
|
||||
const script: string = path.join(
|
||||
__dirname,
|
||||
|
||||
Reference in New Issue
Block a user