mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Refactor extension functions to add_extensions scripts
This commit is contained in:
parent
d189609ea9
commit
2fd8046c9d
@ -110,7 +110,7 @@ describe('Extension tests', () => {
|
|||||||
const [formula, extension]: string[] = line.split('=');
|
const [formula, extension]: string[] = line.split('=');
|
||||||
const prefix: string =
|
const prefix: string =
|
||||||
extension == 'xdebug' ? 'zend_extension' : 'extension';
|
extension == 'xdebug' ? 'zend_extension' : 'extension';
|
||||||
const output: string = fs.existsSync(`src/scripts/ext/${extension}.sh`)
|
const output: string = fs.existsSync(`src/scripts/extensions/${extension}.sh`)
|
||||||
? `add_${extension}`
|
? `add_${extension}`
|
||||||
: `add_brew_extension ${formula} ${prefix}`;
|
: `add_brew_extension ${formula} ${prefix}`;
|
||||||
return [formula, '7.3', output];
|
return [formula, '7.3', output];
|
||||||
|
6
dist/index.js
vendored
6
dist/index.js
vendored
@ -238,7 +238,7 @@ async function addExtensionDarwin(extension_csv, version) {
|
|||||||
case /^couchbase$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension):
|
case /^couchbase$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension):
|
||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension):
|
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin');
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'darwin');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||||
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
||||||
@ -286,7 +286,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$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
case /^(7\.[1-4]|8\.0)(pecl_)?http/.test(version_extension):
|
case /^(7\.[1-4]|8\.0)(pecl_)?http/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'win32');
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension):
|
||||||
add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version.replace('stable', ''));
|
add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version.replace('stable', ''));
|
||||||
@ -352,7 +352,7 @@ async function addExtensionLinux(extension_csv, version) {
|
|||||||
case /(?<!5\.[3-5])intl-[\d]+\.[\d]+$/.test(version_extension):
|
case /(?<!5\.[3-5])intl-[\d]+\.[\d]+$/.test(version_extension):
|
||||||
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$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux');
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'linux');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||||
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
||||||
|
@ -46,7 +46,7 @@ export async function addExtensionDarwin(
|
|||||||
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension):
|
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'ext',
|
'extensions',
|
||||||
extension,
|
extension,
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
@ -142,7 +142,7 @@ export async function addExtensionWindows(
|
|||||||
case /^(7\.[1-4]|8\.0)(pecl_)?http/.test(version_extension):
|
case /^(7\.[1-4]|8\.0)(pecl_)?http/.test(version_extension):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'ext',
|
'extensions',
|
||||||
extension,
|
extension,
|
||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
@ -269,7 +269,7 @@ export async function addExtensionLinux(
|
|||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'ext',
|
'extensions',
|
||||||
extension,
|
extension,
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
|
@ -30,13 +30,6 @@ add_log() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to log result of installing extension.
|
|
||||||
add_extension_log() {
|
|
||||||
(
|
|
||||||
check_extension "$(echo "$1" | cut -d '-' -f 1)" && add_log "$tick" "$1" "$2"
|
|
||||||
) || add_log "$cross" "$1" "Could not install $1 on PHP ${semver:?}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to read env inputs.
|
# Function to read env inputs.
|
||||||
read_env() {
|
read_env() {
|
||||||
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
|
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
|
||||||
@ -88,99 +81,6 @@ self_hosted_setup() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to test if extension is loaded.
|
|
||||||
check_extension() {
|
|
||||||
local extension=$1
|
|
||||||
if [ "$extension" != "mysql" ]; then
|
|
||||||
php -m | grep -i -q -w "$extension"
|
|
||||||
else
|
|
||||||
php -m | grep -i -q "$extension"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to check if extension is shared
|
|
||||||
shared_extension() {
|
|
||||||
[ -e "${ext_dir:?}/$1.so" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable cached extension's dependencies.
|
|
||||||
enable_cache_extension_dependencies() {
|
|
||||||
if [ -d /tmp/extcache ] && shared_extension "$1"; then
|
|
||||||
cache_dir=$(find /tmp/extcache -maxdepth 1 -type d -regex ".*$1[0-9]*")
|
|
||||||
if [[ -n "$cache_dir" ]]; then
|
|
||||||
IFS=" " read -r -a deps <<<"$(find "$cache_dir" -maxdepth 1 -type f -name "*" -exec basename {} \; | tr '\n' ' ')"
|
|
||||||
if [[ -n "${deps[*]}" ]] && php "${deps[@]/#/-d ${2}=}" -d "${2}=$1" -m 2>/dev/null | grep -i -q "$1"; then
|
|
||||||
for ext in "${deps[@]}"; do
|
|
||||||
sudo rm -rf /tmp/extcache/"$ext"
|
|
||||||
enable_extension "$ext" "$2"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable existing extensions.
|
|
||||||
enable_extension() {
|
|
||||||
modules_dir="/var/lib/php/modules/$version"
|
|
||||||
[ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
|
|
||||||
enable_extension_dependencies "$1" "$2"
|
|
||||||
enable_cache_extension_dependencies "$1" "$2"
|
|
||||||
if ! check_extension "$1" && shared_extension "$1"; then
|
|
||||||
echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get a map of extensions and their dependent shared extensions.
|
|
||||||
get_extension_map() {
|
|
||||||
php -d'error_reporting=0' "${dist:?}"/../src/scripts/ext/extension_map.php
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable extension dependencies which are also extensions.
|
|
||||||
enable_extension_dependencies() {
|
|
||||||
local extension=$1
|
|
||||||
prefix=$2
|
|
||||||
if ! [ -e /tmp/map.orig ]; then
|
|
||||||
get_extension_map | sudo tee /tmp/map.orig >/dev/null
|
|
||||||
fi
|
|
||||||
for dependency in $(grep "$extension:" /tmp/map.orig | cut -d ':' -f 2 | tr '\n' ' '); do
|
|
||||||
enable_extension "$dependency" "$prefix"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable dependent extensions.
|
|
||||||
disable_extension_dependents() {
|
|
||||||
local extension=$1
|
|
||||||
for dependent in $(get_extension_map | grep -E ".*:.*\s$extension(\s|$)" | cut -d ':' -f 1 | tr '\n' ' '); do
|
|
||||||
disable_extension_helper "$dependent" true
|
|
||||||
add_log "${tick:?}" ":$extension" "Disabled $dependent as it depends on $extension"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable an extension.
|
|
||||||
disable_extension() {
|
|
||||||
local extension=$1
|
|
||||||
if check_extension "$extension"; then
|
|
||||||
if shared_extension "$extension"; then
|
|
||||||
disable_extension_helper "$extension" true
|
|
||||||
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Disabled") ||
|
|
||||||
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP ${semver:?}"
|
|
||||||
else
|
|
||||||
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP $semver as it not a shared extension"
|
|
||||||
fi
|
|
||||||
elif shared_extension "$extension"; then
|
|
||||||
add_log "${tick:?}" ":$extension" "Disabled"
|
|
||||||
else
|
|
||||||
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable shared extensions.
|
|
||||||
disable_all_shared() {
|
|
||||||
sudo sed -i.orig -E -e "/^(zend_)?extension\s*=/d" "${ini_file[@]}" "$pecl_file" 2>/dev/null || true
|
|
||||||
sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
|
||||||
add_log "${tick:?}" "none" "Disabled all shared extensions"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to configure PHP
|
# Function to configure PHP
|
||||||
configure_php() {
|
configure_php() {
|
||||||
(
|
(
|
||||||
@ -190,65 +90,6 @@ configure_php() {
|
|||||||
) | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
|
) | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to configure PECL.
|
|
||||||
configure_pecl() {
|
|
||||||
if ! [ -e /tmp/pecl_config ]; then
|
|
||||||
for script in pear pecl; do
|
|
||||||
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
|
|
||||||
sudo "$script" channel-update "$script".php.net
|
|
||||||
done
|
|
||||||
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get the PECL version of an extension.
|
|
||||||
get_pecl_version() {
|
|
||||||
local extension=$1
|
|
||||||
stability="$(echo "$2" | grep -m 1 -Eio "(stable|alpha|beta|rc|snapshot|preview)")"
|
|
||||||
pecl_rest='https://pecl.php.net/rest/r/'
|
|
||||||
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
|
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
|
|
||||||
if [ ! "$pecl_version" ]; then
|
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)")
|
|
||||||
fi
|
|
||||||
echo "$pecl_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install PECL extensions and accept default options
|
|
||||||
pecl_install() {
|
|
||||||
local extension=$1
|
|
||||||
add_pecl >/dev/null 2>&1
|
|
||||||
yes '' 2>/dev/null | sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install a specific version of PECL extension.
|
|
||||||
add_pecl_extension() {
|
|
||||||
local extension=$1
|
|
||||||
pecl_version=$2
|
|
||||||
prefix=$3
|
|
||||||
enable_extension "$extension" "$prefix"
|
|
||||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
|
||||||
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
|
||||||
fi
|
|
||||||
ext_version=$(php -r "echo phpversion('$extension');")
|
|
||||||
if [ "${ext_version/-/}" = "$pecl_version" ]; then
|
|
||||||
add_log "${tick:?}" "$extension" "Enabled"
|
|
||||||
else
|
|
||||||
disable_extension_helper "$extension" >/dev/null 2>&1
|
|
||||||
pecl_install "$extension-$pecl_version"
|
|
||||||
add_extension_log "$extension-$pecl_version" "Installed and enabled"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup pre-release extensions using PECL.
|
|
||||||
add_unstable_extension() {
|
|
||||||
local extension=$1
|
|
||||||
stability=$2
|
|
||||||
prefix=$3
|
|
||||||
pecl_version=$(get_pecl_version "$extension" "$stability")
|
|
||||||
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get PHP version in semver format.
|
# Function to get PHP version in semver format.
|
||||||
php_semver() {
|
php_semver() {
|
||||||
php -v | grep -Eo -m 1 "[0-9]+\.[0-9]+\.[0-9]+((-?[a-zA-Z]+([0-9]+)?)?){2}" | head -n 1
|
php -v | grep -Eo -m 1 "[0-9]+\.[0-9]+\.[0-9]+((-?[a-zA-Z]+([0-9]+)?)?){2}" | head -n 1
|
||||||
@ -260,6 +101,6 @@ php_src_tag() {
|
|||||||
if [[ -n "${commit}" ]]; then
|
if [[ -n "${commit}" ]]; then
|
||||||
echo "$commit"
|
echo "$commit"
|
||||||
else
|
else
|
||||||
echo "php-$semver"
|
echo "php-${semver:?}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -250,8 +250,9 @@ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
|||||||
|
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/common.sh
|
. "${scripts:?}"/common.sh
|
||||||
. "${scripts:?}"/ext/source.sh
|
|
||||||
. "${scripts:?}"/tools/add_tools.sh
|
. "${scripts:?}"/tools/add_tools.sh
|
||||||
|
. "${scripts:?}"/extensions/source.sh
|
||||||
|
. "${scripts:?}"/extensions/add_extensions.sh
|
||||||
read_env
|
read_env
|
||||||
self_hosted_setup
|
self_hosted_setup
|
||||||
setup_php
|
setup_php
|
||||||
|
184
src/scripts/extensions/add_extensions.ps1
Normal file
184
src/scripts/extensions/add_extensions.ps1
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
# Function to link dependencies to PHP directory.
|
||||||
|
Function Set-ExtensionPrerequisites
|
||||||
|
{
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$deps_dir
|
||||||
|
)
|
||||||
|
$deps = Get-ChildItem -Recurse -Path $deps_dir
|
||||||
|
if ($deps.Count -ne 0) {
|
||||||
|
# Symlink dependencies instead of adding the directory to PATH ...
|
||||||
|
# as other actions change the PATH thus breaking extensions.
|
||||||
|
$deps | ForEach-Object {
|
||||||
|
New-Item -Itemtype SymbolicLink -Path $php_dir -Name $_.Name -Target $_.FullName -Force > $null 2>&1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Remove-Item $deps_dir -Recurse -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add PHP extensions.
|
||||||
|
Function Add-Extension {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension,
|
||||||
|
[Parameter(Position = 1, Mandatory = $false)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
|
||||||
|
[string]
|
||||||
|
$stability = 'stable',
|
||||||
|
[Parameter(Position = 2, Mandatory = $false)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidatePattern('^\d+(\.\d+){0,2}$')]
|
||||||
|
[string]
|
||||||
|
$extension_version = ''
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
||||||
|
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
|
||||||
|
New-Item $deps_dir -Type Directory -Force > $null 2>&1
|
||||||
|
if ($null -ne $extension_info) {
|
||||||
|
switch ($extension_info.State) {
|
||||||
|
'Builtin' {
|
||||||
|
Add-Log $tick $extension "Enabled"
|
||||||
|
}
|
||||||
|
'Enabled' {
|
||||||
|
Add-Log $tick $extension "Enabled"
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
Enable-ExtensionDependencies $extension
|
||||||
|
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
||||||
|
Set-ExtensionPrerequisites $deps_dir
|
||||||
|
Add-Log $tick $extension "Enabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Patch till PHP 8.1 DLLs are released as stable.
|
||||||
|
$minimumStability = 'stable'
|
||||||
|
if($version -eq '8.1' -and $stability -eq 'stable') {
|
||||||
|
$minimumStability = 'snapshot'
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
|
||||||
|
if($extension_version -ne '') {
|
||||||
|
$params["Version"] = $extension_version
|
||||||
|
}
|
||||||
|
Install-PhpExtension @params
|
||||||
|
Set-ExtensionPrerequisites $deps_dir
|
||||||
|
Add-Log $tick $extension "Installed and enabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get a map of extensions and their dependent shared extensions.
|
||||||
|
Function Get-ExtensionMap {
|
||||||
|
php -d'error_reporting=0' $dist\..\src\scripts\ext\extension_map.php
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable extension dependencies which are also extensions.
|
||||||
|
Function Enable-ExtensionDependencies {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension
|
||||||
|
)
|
||||||
|
if (-not(Test-Path $env:TEMP\map.orig)) {
|
||||||
|
Get-ExtensionMap | Set-Content -Path $env:TEMP\map.orig
|
||||||
|
}
|
||||||
|
$entry = findstr /r "$extension`:.*" $env:TEMP\map.orig
|
||||||
|
if($entry) {
|
||||||
|
$entry.split(':')[1].trim().split(' ') | ForEach-Object {
|
||||||
|
if (-not(php -m | findstr -i $_)) {
|
||||||
|
Enable-PhpExtension -Extension $_ -Path $php_dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable dependent extensions.
|
||||||
|
Function Disable-DependentExtensions() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension
|
||||||
|
)
|
||||||
|
Get-ExtensionMap | Select-String -Pattern ".*:.*\s$extension(\s|$)" | ForEach-Object {
|
||||||
|
$dependent = $_.Matches[0].Value.split(':')[0];
|
||||||
|
Disable-ExtensionHelper -Extension $dependent -DisableDependents
|
||||||
|
Add-Log $tick ":$extension" "Disabled $dependent as it depends on $extension"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Helper function to disable an extension.
|
||||||
|
Function Disable-ExtensionHelper() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension,
|
||||||
|
[switch] $DisableDependents
|
||||||
|
)
|
||||||
|
if($DisableDependents) {
|
||||||
|
Disable-DependentExtensions $extension
|
||||||
|
}
|
||||||
|
Disable-PhpExtension -Extension $extension -Path $php_dir
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable an extension.
|
||||||
|
Function Disable-Extension() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension,
|
||||||
|
[Parameter(Position = 1, Mandatory = $false)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$DisableDependents
|
||||||
|
)
|
||||||
|
if(php -m | findstr -i $extension) {
|
||||||
|
if(Test-Path $ext_dir\php_$extension.dll) {
|
||||||
|
try {
|
||||||
|
$params = @{ Extension = $extension; DisableDependents = ($DisableDependents -ne 'false') }
|
||||||
|
Disable-ExtensionHelper @params
|
||||||
|
Add-Log $tick ":$extension" "Disabled"
|
||||||
|
} catch {
|
||||||
|
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion)"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion) as it not a shared extension"
|
||||||
|
}
|
||||||
|
} elseif(Test-Path $ext_dir\php_$extension.dll) {
|
||||||
|
Add-Log $tick ":$extension" "Disabled"
|
||||||
|
} else {
|
||||||
|
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable shared extensions.
|
||||||
|
Function Disable-AllShared() {
|
||||||
|
(Get-Content $php_dir\php.ini) | Where-Object {$_ -notmatch '^(zend_)?extension\s*='} | Set-Content $php_dir\php.ini
|
||||||
|
Add-Log $tick "none" "Disabled all shared extensions"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to handle request to add PECL.
|
||||||
|
Function Add-Pecl() {
|
||||||
|
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
||||||
|
}
|
158
src/scripts/extensions/add_extensions.sh
Normal file
158
src/scripts/extensions/add_extensions.sh
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
# Function to log result of installing extension.
|
||||||
|
add_extension_log() {
|
||||||
|
(
|
||||||
|
check_extension "$(echo "$1" | cut -d '-' -f 1)" && add_log "${tick:?}" "$1" "$2"
|
||||||
|
) || add_log "${cross:?}" "$1" "Could not install $1 on PHP ${semver:?}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to test if extension is loaded.
|
||||||
|
check_extension() {
|
||||||
|
local extension=$1
|
||||||
|
if [ "$extension" != "mysql" ]; then
|
||||||
|
php -m | grep -i -q -w "$extension"
|
||||||
|
else
|
||||||
|
php -m | grep -i -q "$extension"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to check if extension is shared
|
||||||
|
shared_extension() {
|
||||||
|
[ -e "${ext_dir:?}/$1.so" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable cached extension's dependencies.
|
||||||
|
enable_cache_extension_dependencies() {
|
||||||
|
if [ -d /tmp/extcache ] && shared_extension "$1"; then
|
||||||
|
cache_dir=$(find /tmp/extcache -maxdepth 1 -type d -regex ".*$1[0-9]*")
|
||||||
|
if [[ -n "$cache_dir" ]]; then
|
||||||
|
IFS=" " read -r -a deps <<<"$(find "$cache_dir" -maxdepth 1 -type f -name "*" -exec basename {} \; | tr '\n' ' ')"
|
||||||
|
if [[ -n "${deps[*]}" ]] && php "${deps[@]/#/-d ${2}=}" -d "${2}=$1" -m 2>/dev/null | grep -i -q "$1"; then
|
||||||
|
for ext in "${deps[@]}"; do
|
||||||
|
sudo rm -rf /tmp/extcache/"$ext"
|
||||||
|
enable_extension "$ext" "$2"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable existing extensions.
|
||||||
|
enable_extension() {
|
||||||
|
modules_dir="/var/lib/php/modules/${version:?}"
|
||||||
|
[ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
|
||||||
|
enable_extension_dependencies "$1" "$2"
|
||||||
|
enable_cache_extension_dependencies "$1" "$2"
|
||||||
|
if ! check_extension "$1" && shared_extension "$1"; then
|
||||||
|
echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get a map of extensions and their dependent shared extensions.
|
||||||
|
get_extension_map() {
|
||||||
|
php -d'error_reporting=0' "${dist:?}"/../src/scripts/extensions/extension_map.php
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable extension dependencies which are also extensions.
|
||||||
|
enable_extension_dependencies() {
|
||||||
|
local extension=$1
|
||||||
|
prefix=$2
|
||||||
|
if ! [ -e /tmp/map.orig ]; then
|
||||||
|
get_extension_map | sudo tee /tmp/map.orig >/dev/null
|
||||||
|
fi
|
||||||
|
for dependency in $(grep "$extension:" /tmp/map.orig | cut -d ':' -f 2 | tr '\n' ' '); do
|
||||||
|
enable_extension "$dependency" "$prefix"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable dependent extensions.
|
||||||
|
disable_extension_dependents() {
|
||||||
|
local extension=$1
|
||||||
|
for dependent in $(get_extension_map | grep -E ".*:.*\s$extension(\s|$)" | cut -d ':' -f 1 | tr '\n' ' '); do
|
||||||
|
disable_extension_helper "$dependent" true
|
||||||
|
add_log "${tick:?}" ":$extension" "Disabled $dependent as it depends on $extension"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable an extension.
|
||||||
|
disable_extension() {
|
||||||
|
local extension=$1
|
||||||
|
if check_extension "$extension"; then
|
||||||
|
if shared_extension "$extension"; then
|
||||||
|
disable_extension_helper "$extension" true
|
||||||
|
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Disabled") ||
|
||||||
|
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP ${semver:?}"
|
||||||
|
else
|
||||||
|
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP $semver as it not a shared extension"
|
||||||
|
fi
|
||||||
|
elif shared_extension "$extension"; then
|
||||||
|
add_log "${tick:?}" ":$extension" "Disabled"
|
||||||
|
else
|
||||||
|
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable shared extensions.
|
||||||
|
disable_all_shared() {
|
||||||
|
sudo sed -i.orig -E -e "/^(zend_)?extension\s*=/d" "${ini_file[@]}" "$pecl_file" 2>/dev/null || true
|
||||||
|
sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
||||||
|
add_log "${tick:?}" "none" "Disabled all shared extensions"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to configure PECL.
|
||||||
|
configure_pecl() {
|
||||||
|
if ! [ -e /tmp/pecl_config ]; then
|
||||||
|
for script in pear pecl; do
|
||||||
|
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
|
||||||
|
sudo "$script" channel-update "$script".php.net
|
||||||
|
done
|
||||||
|
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get the PECL version of an extension.
|
||||||
|
get_pecl_version() {
|
||||||
|
local extension=$1
|
||||||
|
stability="$(echo "$2" | grep -m 1 -Eio "(stable|alpha|beta|rc|snapshot|preview)")"
|
||||||
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
|
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
|
||||||
|
if [ ! "$pecl_version" ]; then
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)")
|
||||||
|
fi
|
||||||
|
echo "$pecl_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install PECL extensions and accept default options
|
||||||
|
pecl_install() {
|
||||||
|
local extension=$1
|
||||||
|
add_pecl >/dev/null 2>&1
|
||||||
|
yes '' 2>/dev/null | sudo pecl install -f "$extension" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install a specific version of PECL extension.
|
||||||
|
add_pecl_extension() {
|
||||||
|
local extension=$1
|
||||||
|
pecl_version=$2
|
||||||
|
prefix=$3
|
||||||
|
enable_extension "$extension" "$prefix"
|
||||||
|
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
||||||
|
fi
|
||||||
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "${ext_version/-/}" = "$pecl_version" ]; then
|
||||||
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
disable_extension_helper "$extension" >/dev/null 2>&1
|
||||||
|
pecl_install "$extension-$pecl_version"
|
||||||
|
add_extension_log "$extension-$pecl_version" "Installed and enabled"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup pre-release extensions using PECL.
|
||||||
|
add_unstable_extension() {
|
||||||
|
local extension=$1
|
||||||
|
stability=$2
|
||||||
|
prefix=$3
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
|
}
|
@ -57,4 +57,4 @@ add_cubrid() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/ext/patches/phpize.sh
|
. "${scripts:?}"/extensions/patches/phpize.sh
|
@ -62,4 +62,4 @@ add_oci() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/ext/patches/phpize.sh
|
. "${scripts:?}"/extensions/patches/phpize.sh
|
@ -76,9 +76,9 @@ run_group() {
|
|||||||
|
|
||||||
patch_extension() {
|
patch_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
if [ -e "${scripts:?}"/ext/patches/"$extension".sh ]; then
|
if [ -e "${scripts:?}"/extensions/patches/"$extension".sh ]; then
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/ext/patches/"$extension".sh
|
. "${scripts:?}"/extensions/patches/"$extension".sh
|
||||||
patch_"${extension}"
|
patch_"${extension}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
@ -231,9 +231,10 @@ scripts="${dist}"/../src/scripts
|
|||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/common.sh
|
. "${scripts:?}"/common.sh
|
||||||
. "${scripts:?}"/ext/source.sh
|
|
||||||
. "${scripts:?}"/tools/ppa.sh
|
. "${scripts:?}"/tools/ppa.sh
|
||||||
. "${scripts:?}"/tools/add_tools.sh
|
. "${scripts:?}"/tools/add_tools.sh
|
||||||
|
. "${scripts:?}"/extensions/source.sh
|
||||||
|
. "${scripts:?}"/extensions/add_extensions.sh
|
||||||
read_env
|
read_env
|
||||||
self_hosted_setup
|
self_hosted_setup
|
||||||
setup_php
|
setup_php
|
||||||
|
@ -119,28 +119,6 @@ Function Install-PSPackage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to link dependencies to PHP directory.
|
|
||||||
Function Set-ExtensionPrerequisites
|
|
||||||
{
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$deps_dir
|
|
||||||
)
|
|
||||||
$deps = Get-ChildItem -Recurse -Path $deps_dir
|
|
||||||
if ($deps.Count -ne 0) {
|
|
||||||
# Symlink dependencies instead of adding the directory to PATH ...
|
|
||||||
# as other actions change the PATH thus breaking extensions.
|
|
||||||
$deps | ForEach-Object {
|
|
||||||
New-Item -Itemtype SymbolicLink -Path $php_dir -Name $_.Name -Target $_.FullName -Force > $null 2>&1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Remove-Item $deps_dir -Recurse -Force
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to add CA certificates to PHP.
|
# Function to add CA certificates to PHP.
|
||||||
Function Add-PhpCAInfo {
|
Function Add-PhpCAInfo {
|
||||||
try {
|
try {
|
||||||
@ -151,169 +129,6 @@ Function Add-PhpCAInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add PHP extensions.
|
|
||||||
Function Add-Extension {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension,
|
|
||||||
[Parameter(Position = 1, Mandatory = $false)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
|
|
||||||
[string]
|
|
||||||
$stability = 'stable',
|
|
||||||
[Parameter(Position = 2, Mandatory = $false)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidatePattern('^\d+(\.\d+){0,2}$')]
|
|
||||||
[string]
|
|
||||||
$extension_version = ''
|
|
||||||
)
|
|
||||||
try {
|
|
||||||
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
|
||||||
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
|
|
||||||
New-Item $deps_dir -Type Directory -Force > $null 2>&1
|
|
||||||
if ($null -ne $extension_info) {
|
|
||||||
switch ($extension_info.State) {
|
|
||||||
'Builtin' {
|
|
||||||
Add-Log $tick $extension "Enabled"
|
|
||||||
}
|
|
||||||
'Enabled' {
|
|
||||||
Add-Log $tick $extension "Enabled"
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
Enable-ExtensionDependencies $extension
|
|
||||||
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
|
||||||
Set-ExtensionPrerequisites $deps_dir
|
|
||||||
Add-Log $tick $extension "Enabled"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Patch till PHP 8.1 DLLs are released as stable.
|
|
||||||
$minimumStability = 'stable'
|
|
||||||
if($version -eq '8.1' -and $stability -eq 'stable') {
|
|
||||||
$minimumStability = 'snapshot'
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
|
|
||||||
if($extension_version -ne '') {
|
|
||||||
$params["Version"] = $extension_version
|
|
||||||
}
|
|
||||||
Install-PhpExtension @params
|
|
||||||
Set-ExtensionPrerequisites $deps_dir
|
|
||||||
Add-Log $tick $extension "Installed and enabled"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get a map of extensions and their dependent shared extensions.
|
|
||||||
Function Get-ExtensionMap {
|
|
||||||
php -d'error_reporting=0' $dist\..\src\scripts\ext\extension_map.php
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable extension dependencies which are also extensions.
|
|
||||||
Function Enable-ExtensionDependencies {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension
|
|
||||||
)
|
|
||||||
if (-not(Test-Path $env:TEMP\map.orig)) {
|
|
||||||
Get-ExtensionMap | Set-Content -Path $env:TEMP\map.orig
|
|
||||||
}
|
|
||||||
$entry = findstr /r "$extension`:.*" $env:TEMP\map.orig
|
|
||||||
if($entry) {
|
|
||||||
$entry.split(':')[1].trim().split(' ') | ForEach-Object {
|
|
||||||
if (-not(php -m | findstr -i $_)) {
|
|
||||||
Enable-PhpExtension -Extension $_ -Path $php_dir
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable dependent extensions.
|
|
||||||
Function Disable-DependentExtensions() {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension
|
|
||||||
)
|
|
||||||
Get-ExtensionMap | Select-String -Pattern ".*:.*\s$extension(\s|$)" | ForEach-Object {
|
|
||||||
$dependent = $_.Matches[0].Value.split(':')[0];
|
|
||||||
Disable-ExtensionHelper -Extension $dependent -DisableDependents
|
|
||||||
Add-Log $tick ":$extension" "Disabled $dependent as it depends on $extension"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Helper function to disable an extension.
|
|
||||||
Function Disable-ExtensionHelper() {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension,
|
|
||||||
[switch] $DisableDependents
|
|
||||||
)
|
|
||||||
if($DisableDependents) {
|
|
||||||
Disable-DependentExtensions $extension
|
|
||||||
}
|
|
||||||
Disable-PhpExtension -Extension $extension -Path $php_dir
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable an extension.
|
|
||||||
Function Disable-Extension() {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension,
|
|
||||||
[Parameter(Position = 1, Mandatory = $false)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$DisableDependents
|
|
||||||
)
|
|
||||||
if(php -m | findstr -i $extension) {
|
|
||||||
if(Test-Path $ext_dir\php_$extension.dll) {
|
|
||||||
try {
|
|
||||||
$params = @{ Extension = $extension; DisableDependents = ($DisableDependents -ne 'false') }
|
|
||||||
Disable-ExtensionHelper @params
|
|
||||||
Add-Log $tick ":$extension" "Disabled"
|
|
||||||
} catch {
|
|
||||||
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion)"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion) as it not a shared extension"
|
|
||||||
}
|
|
||||||
} elseif(Test-Path $ext_dir\php_$extension.dll) {
|
|
||||||
Add-Log $tick ":$extension" "Disabled"
|
|
||||||
} else {
|
|
||||||
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable shared extensions.
|
|
||||||
Function Disable-AllShared() {
|
|
||||||
(Get-Content $php_dir\php.ini) | Where-Object {$_ -notmatch '^(zend_)?extension\s*='} | Set-Content $php_dir\php.ini
|
|
||||||
Add-Log $tick "none" "Disabled all shared extensions"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to handle request to add PECL.
|
|
||||||
Function Add-Pecl() {
|
|
||||||
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
$tick = ([char]8730)
|
$tick = ([char]8730)
|
||||||
$cross = ([char]10007)
|
$cross = ([char]10007)
|
||||||
@ -363,6 +178,7 @@ if($env:RUNNER -eq 'self-hosted') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
. $dist\..\src\scripts\tools\add_tools.ps1
|
. $dist\..\src\scripts\tools\add_tools.ps1
|
||||||
|
. $dist\..\src\scripts\extensions\add_extensions.ps1
|
||||||
|
|
||||||
Add-Printf >$null 2>&1
|
Add-Printf >$null 2>&1
|
||||||
Step-Log "Setup PhpManager"
|
Step-Log "Setup PhpManager"
|
||||||
|
Loading…
Reference in New Issue
Block a user