From 25d9bbc737cc7b35be057e173ce28e7b1354015b Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 20 Jul 2020 11:50:58 +0530 Subject: [PATCH] Update README and licensing information --- README.md | 15 +++----- src/scripts/ext/ioncube.ps1 | 12 ++++-- src/scripts/ext/ioncube.sh | 5 ++- src/scripts/ext/oci.ps1 | 75 ++++++++++++++++++++++++------------- src/scripts/ext/oci.sh | 9 ++++- 5 files changed, 76 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 0153e036..d5d1cd9a 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ with: extensions: xdebug-beta ``` -- Non-default extensions can be removed by prefixing it with a `:`. +- Shared extensions can be removed by prefixing them with a `:`. ```yaml uses: shivammathur/setup-php@v2 @@ -143,7 +143,7 @@ with: - Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted. -- These extensions have custom support - `gearman` on ubuntu, `blackfire`, `phalcon3` and `phalcon4` on all supported OS. +- These extensions have custom support - `gearman` on `Ubuntu`, `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS. ## :wrench: Tools Support @@ -178,13 +178,11 @@ with: ``` **Notes** -- Both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified. +- Both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. - Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted. ## :signal_strength: Coverage Support - - ### Xdebug Specify `coverage: xdebug` to use `Xdebug`. @@ -637,6 +635,7 @@ Examples of using `setup-php` with various PHP Frameworks and Packages. - The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php"). - This project has multiple [dependencies](#bookmark-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories. +- The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License"). ## :+1: Contributions @@ -649,10 +648,8 @@ Examples of using `setup-php` with various PHP Frameworks and Packages. If this action helped you. -- Sponsor the project by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") or by contributing using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal"). -- Please star the project and share it with the community. -- If you blog, write about your experience of using this action. -- If you need any help using this, please contact me using [Codementor](https://www.codementor.io/shivammathur "Shivam Mathur Codementor") +- Sponsor the project by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") or by contributing using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal"). This project is also available as part of the [Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-setup-php?utm_source=npm-setup-php&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Tidelift Subscription for setup-php") to support delivering enterprise-level maintenance. +- Please star the project and dependencies. If you blog, please share your experience of using this action with the community. ## :package: Dependencies diff --git a/src/scripts/ext/ioncube.ps1 b/src/scripts/ext/ioncube.ps1 index 6e920ebe..53c78ed0 100644 --- a/src/scripts/ext/ioncube.ps1 +++ b/src/scripts/ext/ioncube.ps1 @@ -8,8 +8,14 @@ Param ( # Function to log result of a operation. Function Add-Log($mark, $subject, $message) { - $code = if ($mark -eq $cross) { "31" } else { "32" } - printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message + if ($mark -eq $tick) { + printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $mark $subject $message + printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information" + Get-Content $ext_dir\ioncube\LICENSE.txt + Write-Output "::endgroup::" + } else { + printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "31" $mark $subject $message + } } $tick = ([char]8730) @@ -36,7 +42,7 @@ try { Copy-Item $ext_dir\ioncube\ioncube_loader_win_$version.dll $ext_dir\php_ioncube.dll } "zend_extension=$ext_dir\php_ioncube.dll`r`n" + (Get-Content $php_dir\php.ini -Raw) | Set-Content $php_dir\php.ini - printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick "ioncube" $status + Add-Log $tick "ioncube" $status } catch { Add-Log $cross "ioncube" "Could not install ioncube on PHP $($installed.FullVersion)" } \ No newline at end of file diff --git a/src/scripts/ext/ioncube.sh b/src/scripts/ext/ioncube.sh index 93b18202..a5d1108e 100644 --- a/src/scripts/ext/ioncube.sh +++ b/src/scripts/ext/ioncube.sh @@ -5,6 +5,9 @@ add_log() { message=$3 if [ "$mark" = "$tick" ]; then printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" + printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information" + cat /tmp/ioncube/LICENSE.txt + echo "::endgroup::" else printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" fi @@ -18,7 +21,7 @@ check_extension() { # Function to install ioncube. install_ioncube() { - if [ ! -e $ext_dir/ioncube.so ]; then + if [ ! -e "$ext_dir/ioncube.so" ]; then os_name='lin' status='Installed and enabled' [ "$(uname -s)" = "Darwin" ] && os_name='mac' diff --git a/src/scripts/ext/oci.ps1 b/src/scripts/ext/oci.ps1 index d107deb5..c94bd5f9 100644 --- a/src/scripts/ext/oci.ps1 +++ b/src/scripts/ext/oci.ps1 @@ -11,35 +11,58 @@ Param ( $version ) +# Function to log result of a operation. +Function Add-Log($mark, $subject, $message) { + if ($mark -eq $tick) { + printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $mark $subject $message + printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information" + printf "Oracle Instant Client package is required for %s extension.\n" $extension + printf "It is provided under the Oracle Technology Network Development and Distribution License.\n" + printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html" + Write-Output "::endgroup::" + } else { + printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "31" $mark $subject $message + } +} + $tick = ([char]8730) +$cross = ([char]10007) $php_dir = 'C:\tools\php' +$status = 'Enabled' if($env:RUNNER -eq 'self-hosted') { $php_dir = "$php_dir$version" } $ext_dir = "$php_dir\ext" -if(-not(Test-Path $php_dir\oci.dll)) { - $suffix = 'windows' - if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') { - $suffix = 'nt' +$installed = Get-Php -Path $php_dir +try +{ + if (-not(Test-Path $php_dir\oci.dll)) { + $suffix = 'windows' + if (-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') + { + $suffix = 'nt' + } + Invoke-WebRequest -UseBasicParsing -Uri https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip + Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force + Copy-Item $php_dir\instantclient*\* $php_dir } - Invoke-WebRequest -UseBasicParsing -Uri https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip - Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force - Copy-Item $php_dir\instantclient*\* $php_dir + if ($extension -eq "pdo_oci") { + Enable-PhpExtension pdo_oci -Path $php_dir + } else { + $status = 'Installed and enabled' + $ociVersion = '2.2.0' + if ($version -eq '7.0') + { + $ociVersion = '2.1.8' + } + elseif ($version -lt '7.0') + { + $ociVersion = '2.0.12' + } + $ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed + Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip + Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force + Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini + } + Add-Log $tick $extension $status +} catch { + Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)" } -if ($extension -eq "pdo_oci") { - Enable-PhpExtension pdo_oci -Path $php_dir -} else { - $ociVersion = '2.2.0' - if ($version -eq '7.0') - { - $ociVersion = '2.1.8' - } - elseif ($version -lt '7.0') - { - $ociVersion = '2.0.12' - } - $PhpVersion = Get-Php -Path $php_dir - $ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $phpVersion - Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip - Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force - Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini -} -printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Enabled" \ No newline at end of file diff --git a/src/scripts/ext/oci.sh b/src/scripts/ext/oci.sh index fb18709b..a54aaff2 100644 --- a/src/scripts/ext/oci.sh +++ b/src/scripts/ext/oci.sh @@ -5,6 +5,11 @@ add_log() { message=$3 if [ "$mark" = "$tick" ]; then printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" + 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 "Oracle Instant Client package is required for %s extension.\n" "$ext" + printf "It is provided under the Oracle Technology Network Development and Distribution License.\n" + printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html" + echo "::endgroup::" else printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" fi @@ -102,6 +107,7 @@ install_dependencies() { install_extension() { if ! [ -e "$ext_dir/$ext.so" ]; then ( + status='Installed and enabled' phpize_orig=$(get_phpize) tag=$(get_tag) get_php @@ -121,6 +127,7 @@ ext=$1 version=$2 tick='✓' cross='✗' +status='Enabled' oracle_home='/opt/oracle' oracle_client=$oracle_home/instantclient runner="${runner:-github}" && RUNNER="${RUNNER:-github}" @@ -130,4 +137,4 @@ ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||") install_client >/dev/null 2>&1 install_dependencies >/dev/null 2>&1 install_extension >/dev/null 2>&1 -(check_extension "$ext" && add_log "$tick" "$ext" "Installed and enabled") || add_log "$cross" "$ext" "Could not install $ext" \ No newline at end of file +(check_extension "$ext" && add_log "$tick" "$ext" "$status") || add_log "$cross" "$ext" "Could not install $ext" \ No newline at end of file