mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support to install sqlsrv and pdo_sqlsrv from GitHub releases
This commit is contained in:
parent
661ad4bf75
commit
319feb83c2
@ -19,9 +19,12 @@ describe('Extension tests', () => {
|
|||||||
${'pcov'} | ${'5.6'} | ${'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
|
${'pcov'} | ${'5.6'} | ${'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
|
||||||
${'pdo_oci'} | ${'7.4'} | ${'Add-Oci pdo_oci'}
|
${'pdo_oci'} | ${'7.4'} | ${'Add-Oci pdo_oci'}
|
||||||
${'pecl_http'} | ${'7.4'} | ${'Add-Http'}
|
${'pecl_http'} | ${'7.4'} | ${'Add-Http'}
|
||||||
|
${'pdo_sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv pdo_sqlsrv'}
|
||||||
${'phalcon3'} | ${'7.2'} | ${'Add-Phalcon phalcon3'}
|
${'phalcon3'} | ${'7.2'} | ${'Add-Phalcon phalcon3'}
|
||||||
${'phalcon4'} | ${'7.4'} | ${'Add-Phalcon phalcon4'}
|
${'phalcon4'} | ${'7.4'} | ${'Add-Phalcon phalcon4'}
|
||||||
${'sqlite'} | ${'7.4'} | ${'Add-Extension sqlite3'}
|
${'sqlite'} | ${'7.4'} | ${'Add-Extension sqlite3'}
|
||||||
|
${'sqlsrv'} | ${'5.6'} | ${'Add-Extension sqlsrv'}
|
||||||
|
${'sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv sqlsrv'}
|
||||||
${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'}
|
${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'}
|
||||||
${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'}
|
${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'}
|
||||||
${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'}
|
${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'}
|
||||||
|
1
dist/index.js
vendored
1
dist/index.js
vendored
@ -304,6 +304,7 @@ async function addExtensionWindows(extension_csv, version) {
|
|||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
||||||
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
||||||
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32');
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32');
|
||||||
return;
|
return;
|
||||||
|
@ -150,6 +150,7 @@ export async function addExtensionWindows(
|
|||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
||||||
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
|
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
|
||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
# Function to check if extension is enabled.
|
||||||
|
Function Test-Extension() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[string]
|
||||||
|
$extension
|
||||||
|
)
|
||||||
|
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
||||||
|
return $null -ne $extension_info
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add extension log.
|
||||||
Function Add-ExtensionLog() {
|
Function Add-ExtensionLog() {
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
@ -7,8 +20,7 @@ Function Add-ExtensionLog() {
|
|||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
$message
|
$message
|
||||||
)
|
)
|
||||||
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
if (Test-Extension $extension) {
|
||||||
if ($null -ne $extension_info -and ($extension_info.State -eq 'Enabled' -or $extension_info.State -eq 'Builtin')) {
|
|
||||||
Add-Log $tick $extension $message
|
Add-Log $tick $extension $message
|
||||||
} else {
|
} else {
|
||||||
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
|
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
|
||||||
|
69
src/scripts/extensions/sqlsrv.ps1
Normal file
69
src/scripts/extensions/sqlsrv.ps1
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# Function to get sqlsrv extension version.
|
||||||
|
Function Get-SqlsrvReleaseVersion() {
|
||||||
|
if ($version -le '7.2') {
|
||||||
|
# Use the releases from PECL for these versions
|
||||||
|
return null;
|
||||||
|
} elseif($version -eq '7.3') {
|
||||||
|
return '5.9.0'
|
||||||
|
} elseif ($version -eq '7.4') {
|
||||||
|
return '5.10.1'
|
||||||
|
} else {
|
||||||
|
return 'latest'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get sqlsrv extension release URL.
|
||||||
|
Function Get-SqlsrvReleaseUrl()
|
||||||
|
{
|
||||||
|
$extensionVersion = Get-SqlsrvReleaseVersion
|
||||||
|
if($extensionVersion) {
|
||||||
|
$repo = "$github/microsoft/msphpsql"
|
||||||
|
if($extensionVersion -eq 'latest') {
|
||||||
|
return "$repo/releases/latest/download/Windows-$version.zip"
|
||||||
|
} else {
|
||||||
|
return "$repo/releases/download/v$extensionVersion/Windows-$version.zip"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add sqlsrv extension from GitHub.
|
||||||
|
Function Add-SqlsrvFromGithub()
|
||||||
|
{
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[string]
|
||||||
|
$extension
|
||||||
|
)
|
||||||
|
$zipUrl = SqlsrvReleaseUrl
|
||||||
|
if($zipUrl) {
|
||||||
|
$nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" }
|
||||||
|
$noDotVersion = $version.replace('.', '')
|
||||||
|
$extensionFilePath = "Windows-$version\$arch\php_${extension}_${noDotVersion}_${nts}.dll"
|
||||||
|
Get-File -Url $zipUrl -OutFile $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip > $null 2>&1
|
||||||
|
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\sqlsrv -Force > $null 2>&1
|
||||||
|
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\sqlsrv\$extensionFilePath" -Destination "$ext_dir\php_$extension.dll"
|
||||||
|
Enable-PhpExtension -Extension $extension -Path $php_dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add sqlsrv extension.
|
||||||
|
Function Add-Sqlsrv() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[string]
|
||||||
|
$extension
|
||||||
|
)
|
||||||
|
$status = 'Enabled'
|
||||||
|
if (Test-Path $ext_dir\php_$extension.dll) {
|
||||||
|
Enable-PhpExtension -Extension $extension -Path $php_dir
|
||||||
|
} else {
|
||||||
|
Add-SqlsrvFromGithub $extension >$null 2>&1
|
||||||
|
if (-not(Test-Extension $extension)) {
|
||||||
|
Add-Extension $extension >$null 2>&1
|
||||||
|
}
|
||||||
|
$status = 'Installed and enabled'
|
||||||
|
}
|
||||||
|
Add-ExtensionLog $extension $status
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user